mirror of
https://github.com/Xevion/spotify-explicit.git
synced 2025-12-10 20:08:38 -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 os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import dateutil.parser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
def get_files():
|
def get_files():
|
||||||
@@ -19,6 +20,19 @@ def combine_files(files):
|
|||||||
items.extend(file['items'])
|
items.extend(file['items'])
|
||||||
return 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():
|
def main():
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logging.info("Reading track files")
|
logging.info("Reading track files")
|
||||||
@@ -27,4 +41,6 @@ def main():
|
|||||||
logging.info("Combining into single track file for ease of access")
|
logging.info("Combining into single track file for ease of access")
|
||||||
data = combine_files(files)
|
data = combine_files(files)
|
||||||
logging.info(f'File combined with {len(data)} items')
|
logging.info(f'File combined with {len(data)} items')
|
||||||
|
logging.info('Prcessing file...')
|
||||||
|
process(data)
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user