Skip to content

Commit

Permalink
Backup: output optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
raiden-e committed Feb 11, 2023
1 parent 300f7d1 commit 23a22f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from util import dc, gist, playlist
from util.spotify import get_spotify_client

msg = ""

def print_exceptions(exepts):
err_msg = f"Exceptions ({len(exepts)}):\n" + pformat(exepts)
Expand Down Expand Up @@ -36,6 +37,9 @@ def backup_playlist(pl: dict):
playlist.addAsync(_spotify, ToAdd, pl['set'])
print(f"Added: {len(ToAdd)}")
pprint(ToAdd, depth=2)
msg = "get:\n " + "\n ".join([x for x in pl["get"]])
msg += "\nset\n " + pl["set"]
print(f"Backed:\n{msg}")
except Exception as e:
print(e)
exceptions.append(e)
Expand All @@ -48,7 +52,9 @@ def main():
if data["backup"][pl]['set'].strip() == "":
print(f"Empty set: {pl}")
continue
print(f"Backing up: {pl}")
msg = pl + "\nget:\n " + "\n ".join([x for x in data["backup"][pl]["get"]])
msg += "\nset:\n " + data["backup"][pl]["set"]
print(f"Backing up: {msg}")
backup_playlist(data["backup"][pl])

print_exceptions(exceptions)
Expand Down
4 changes: 2 additions & 2 deletions util/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def print_diff(a, b):
art_a += f", {artist_a['name']}"
art_b += f", {artist_b}"
print(" Duplicate Meta:")
print(f" {a['id']} {a['name']}{' ':>30}| {art_a}")
print(f" {b['id']} {b['name']}{' ':>30}| {art_b}")
print(f" {a['id']} {a['name']} | {art_a}")
print(f" {b['id']} {b['name']} | {art_b}")

def inner(xt):
for y in seen_tracks:
Expand Down

0 comments on commit 23a22f8

Please sign in to comment.