mirror of
https://github.com/caseychu/spotify-backup.git
synced 2024-05-11 10:51:31 +00:00
json: Remove "available_markets" field
Otherwise, this makes the file needlessly larger
This commit is contained in:
@@ -126,6 +126,21 @@ class SpotifyAPI:
|
||||
self.access_token = access_token
|
||||
|
||||
|
||||
def maybe_delete(d, k):
|
||||
if k in d:
|
||||
del d[k]
|
||||
|
||||
|
||||
def scrub_cruft(obj):
|
||||
if isinstance(obj, dict):
|
||||
maybe_delete(obj, "available_markets")
|
||||
for _, v in obj.items():
|
||||
scrub_cruft(v)
|
||||
elif isinstance(obj, list):
|
||||
for v in obj:
|
||||
scrub_cruft(v)
|
||||
|
||||
|
||||
def main():
|
||||
# Parse arguments.
|
||||
parser = argparse.ArgumentParser(description='Exports your Spotify playlists. By default, opens a browser window '
|
||||
@@ -175,6 +190,9 @@ def main():
|
||||
logging.info('Loading playlist: {name} ({tracks[total]} songs)'.format(**playlist))
|
||||
playlist['tracks'] = spotify.list(playlist['tracks']['href'], {'limit': 100})
|
||||
playlists += playlist_data
|
||||
|
||||
logging.info(f"Scrubbing cruft...")
|
||||
scrub_cruft(playlists)
|
||||
|
||||
# Write the file.
|
||||
logging.info('Writing files...')
|
||||
|
||||
Reference in New Issue
Block a user