[scrobblers] Actually lookup the album ID
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user