[tsv] Try fixing our lookup when titla and MB id are none

This commit is contained in:
2024-11-04 10:13:42 -05:00
parent b91c8b27d7
commit 68a6d58339
2 changed files with 18 additions and 5 deletions

View File

@ -111,6 +111,8 @@ def get_or_create_track(post_data: dict, post_keys: dict) -> Track:
artist_name, artist_name,
mbid=artist_mb_id, mbid=artist_mb_id,
) )
album = None
if album_mb_id:
album = get_or_create_album( album = get_or_create_album(
album_title, album_title,
artist=artist, artist=artist,
@ -128,6 +130,13 @@ def get_or_create_track(post_data: dict, post_keys: dict) -> Track:
except TypeError: except TypeError:
pass pass
if not track_title and not track_mb_id:
logger.info(
"Cannot find track without either title or MB ID",
extra={"post_data": post_data},
)
return
if track_mb_id: if track_mb_id:
track = Track.objects.filter(musicbrainz_id=track_mb_id).first() track = Track.objects.filter(musicbrainz_id=track_mb_id).first()

View File

@ -67,6 +67,10 @@ def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
"RUN_TIME": "run_time_seconds", "RUN_TIME": "run_time_seconds",
}, },
) )
if not track:
logger.info(f"Skipping track {track} because not found")
continue
# TODO Set all this up as constants # TODO Set all this up as constants
if row[AsTsvColumn["COMPLETE"].value] == "S": if row[AsTsvColumn["COMPLETE"].value] == "S":
logger.info(f"Skipping track {track} because not finished") logger.info(f"Skipping track {track} because not finished")