[scrobblers] Actually lookup the album ID
Some checks failed
build & deploy / test (push) Failing after 1m15s
build & deploy / deploy (push) Has been skipped

This commit is contained in:
2026-03-11 16:34:48 -04:00
parent 744e9f1d38
commit e3364d15ce

View File

@ -4,6 +4,7 @@ from datetime import datetime, timedelta
from typing import Any, Optional
import pendulum
from pylast import Album
import pytz
import requests
from beers.models import Beer
@ -76,13 +77,21 @@ def mopidy_scrobble_media(post_data: dict, user_id: int) -> Scrobble:
media_obj = PodcastEpisode.find_or_create(**parsed_data)
else:
# TODO this kind of sucks, there's gotta be a way to get this in one shot
try:
album_id = (
Album.objects.filter(name=post_data.get("album", ""))
.first()
.id
)
except Exception:
pass
media_obj = Track.find_or_create(
title=post_data.get("name", ""),
artist_name=post_data.get("artist", ""),
album_name=post_data.get("album", ""),
run_time_seconds=post_data.get("run_time", 900000),
)
album_id = media_obj.album_id
log = {}
try: