processing date with date and explicit marker

This commit is contained in:
Xevion
2019-10-27 15:05:02 -05:00
parent 51f76e3902
commit 050ca81fc9

View File

@@ -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()