[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,11 +111,13 @@ def get_or_create_track(post_data: dict, post_keys: dict) -> Track:
artist_name,
mbid=artist_mb_id,
)
album = get_or_create_album(
album_title,
artist=artist,
mbid=album_mb_id,
)
album = None
if album_mb_id:
album = get_or_create_album(
album_title,
artist=artist,
mbid=album_mb_id,
)
track = None
if not track_mb_id and album:
@ -128,6 +130,13 @@ def get_or_create_track(post_data: dict, post_keys: dict) -> Track:
except TypeError:
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:
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",
},
)
if not track:
logger.info(f"Skipping track {track} because not found")
continue
# TODO Set all this up as constants
if row[AsTsvColumn["COMPLETE"].value] == "S":
logger.info(f"Skipping track {track} because not finished")