Added field names to export

Added header row to CSV.
Added field names for simple export.
This commit is contained in:
Nitemice 2020-10-04 17:09:41 +11:00
parent 679bcdd633
commit a0a84a212f
1 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import os.path
import requests import requests
__author__ = 'Alexander Popov' __author__ = 'Alexander Popov'
__version__ = '2.0.1' __version__ = '2.1.0'
__license__ = 'Unlicense' __license__ = 'Unlicense'
@ -67,9 +67,10 @@ def scrobbling_export(tracks, username, export_format='is as'):
_ = [] _ = []
for track in tracks: for track in tracks:
_.append([ _.append({'artist': track['artist']['#text'],
track['artist']['#text'], track['name'], track['date']['uts'] 'name': track['name'],
]) 'album': track['album']['#text'],
'date': track['date']['uts']})
with open('%s.json' % (username), 'w', encoding='utf-8') as f: with open('%s.json' % (username), 'w', encoding='utf-8') as f:
data = json.dumps(_, indent=4, data = json.dumps(_, indent=4,
@ -78,6 +79,11 @@ def scrobbling_export(tracks, username, export_format='is as'):
elif export_format == 'csv': elif export_format == 'csv':
_ = [] _ = []
_.append([
'artist',
'track',
'date'
])
for track in tracks: for track in tracks:
_.append([ _.append([