[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
|
from typing import Any, Optional
|
||||||
|
|
||||||
import pendulum
|
import pendulum
|
||||||
|
from pylast import Album
|
||||||
import pytz
|
import pytz
|
||||||
import requests
|
import requests
|
||||||
from beers.models import Beer
|
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)
|
media_obj = PodcastEpisode.find_or_create(**parsed_data)
|
||||||
else:
|
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(
|
media_obj = Track.find_or_create(
|
||||||
title=post_data.get("name", ""),
|
title=post_data.get("name", ""),
|
||||||
artist_name=post_data.get("artist", ""),
|
artist_name=post_data.get("artist", ""),
|
||||||
album_name=post_data.get("album", ""),
|
album_name=post_data.get("album", ""),
|
||||||
run_time_seconds=post_data.get("run_time", 900000),
|
run_time_seconds=post_data.get("run_time", 900000),
|
||||||
)
|
)
|
||||||
album_id = media_obj.album_id
|
|
||||||
|
|
||||||
log = {}
|
log = {}
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user