From 485fbd63a30d40f6fb1a95bb00aea8d9f86f9085 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 16 Feb 2023 23:42:25 -0500 Subject: [PATCH] Fix a few issues with TSV imports --- vrobbler/apps/scrobbles/models.py | 1 + vrobbler/apps/scrobbles/tsv.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 0d8d4c9..fee4017 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -56,6 +56,7 @@ class AudioScrobblerTSVImport(TimeStampedModel): scrobbles = process_audioscrobbler_tsv_file( self.tsv_file.path, user_tz=tz ) + self.process_log = "" if scrobbles: for count, scrobble in enumerate(scrobbles): scrobble_str = f"{scrobble.id}\t{scrobble.timestamp}\t{scrobble.track.title}" diff --git a/vrobbler/apps/scrobbles/tsv.py b/vrobbler/apps/scrobbles/tsv.py index d40610f..87a3cee 100644 --- a/vrobbler/apps/scrobbles/tsv.py +++ b/vrobbler/apps/scrobbles/tsv.py @@ -26,7 +26,7 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None): source_id = "" for row_num, row in enumerate(rows): if row_num in [0, 1, 2]: - if "Rockbox" in row[0]: + if "Rockbox" in row[2]: source = "Rockbox" source_id += row[0] + "\n" continue @@ -37,7 +37,7 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None): ) continue artist = get_or_create_artist(row[0]) - album = get_or_create_album(row[1]) + album = get_or_create_album(row[1], artist) track = get_or_create_track( title=row[2], @@ -45,11 +45,11 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None): artist=artist, album=album, run_time=row[4], - run_time_ticks=row[4] * 1000, + run_time_ticks=int(row[4]) * 1000, ) timestamp = ( - datetime.utcfromtimestamp(int(row[6])) + datetime.fromtimestamp(int(row[6])) .replace(tzinfo=user_tz) .astimezone(pytz.utc) )