mirror of
https://github.com/Xevion/spotify-explicit.git
synced 2025-12-08 22:08:42 -06:00
processing date with date and explicit marker
This commit is contained in:
16
process.py
16
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()
|
||||
Reference in New Issue
Block a user