Fix appending count to TSV log

This commit is contained in:
2023-02-12 17:03:30 -05:00
parent 36d7950859
commit 31907ed1b2
2 changed files with 6 additions and 6 deletions

View File

@ -56,10 +56,12 @@ class AudioScrobblerTSVImport(TimeStampedModel):
self.tsv_file.path, user_tz=tz self.tsv_file.path, user_tz=tz
) )
if scrobbles: if scrobbles:
self.process_log = f"Created {len(scrobbles)} scrobbles" for count, scrobble in enumerate(scrobbles):
for scrobble in scrobbles:
scrobble_str = f"{scrobble.id}\t{scrobble.timestamp}\t{scrobble.track.title}" scrobble_str = f"{scrobble.id}\t{scrobble.timestamp}\t{scrobble.track.title}"
self.process_log += f"\n{scrobble_str}" log_line = f"{scrobble_str}"
if count > 0:
log_line = "\n" + log_line
self.process_log += log_line
self.process_count = len(scrobbles) self.process_count = len(scrobbles)
else: else:
self.process_log = f"Created no new scrobbles" self.process_log = f"Created no new scrobbles"

View File

@ -124,9 +124,7 @@ def undo_audioscrobbler_tsv_import(process_log, dryrun=True):
logger.warning("No lines in process log found to undo") logger.warning("No lines in process log found to undo")
return return
for line_num, line in enumerate(process_log.split('\n')): for line in process_log.split('\n'):
if line_num == 0:
continue
scrobble_id = line.split("\t")[0] scrobble_id = line.split("\t")[0]
scrobble = Scrobble.objects.filter(id=scrobble_id).first() scrobble = Scrobble.objects.filter(id=scrobble_id).first()
if not scrobble: if not scrobble: