diff --git a/process.py b/process.py index 4196189..08903af 100644 --- a/process.py +++ b/process.py @@ -1,6 +1,7 @@ import os import sys import json +import dateutil.parser import logging def get_files(): @@ -19,6 +20,19 @@ def combine_files(files): items.extend(file['items']) return items +def process(data): + for i, item in enumerate(data): + date = dateutil.parser.parse(item['added_at']) + explicit = '!' if item['track']['explicit'] else ' ' + track_name = item['track']['name'] + artists = ' & '.join(artist['name'] for artist in item['track']['artists']) + print('[{}] {} "{}" by {}'.format( + date, + explicit, + track_name, + artists + )) + def main(): logging.basicConfig(level=logging.INFO) logging.info("Reading track files") @@ -27,4 +41,6 @@ def main(): logging.info("Combining into single track file for ease of access") data = combine_files(files) logging.info(f'File combined with {len(data)} items') + logging.info('Prcessing file...') + process(data) main() \ No newline at end of file