[puzzles] Add puzzle model and hooks
This commit is contained in:
@ -14,9 +14,9 @@ from locations.constants import LOCATION_PROVIDERS
|
||||
from locations.models import GeoLocation
|
||||
from music.constants import JELLYFIN_POST_KEYS, MOPIDY_POST_KEYS
|
||||
from music.models import Track
|
||||
from music.utils import get_or_create_track
|
||||
from podcasts.models import PodcastEpisode
|
||||
from podcasts.utils import parse_mopidy_uri
|
||||
from puzzles.models import Puzzle
|
||||
from scrobbles.constants import (
|
||||
JELLYFIN_AUDIO_ITEM_TYPES,
|
||||
MANUAL_SCROBBLE_FNS,
|
||||
@ -679,3 +679,32 @@ def manual_scrobble_beer(
|
||||
|
||||
# TODO Kick out a process to enrich the media here, and in every scrobble event
|
||||
return Scrobble.create_or_update(beer, user_id, scrobble_dict)
|
||||
|
||||
|
||||
def manual_scrobble_puzzle(
|
||||
ipdb_id: str, user_id: int, action: Optional[str] = None
|
||||
):
|
||||
puzzle = Puzzle.find_or_create(ipdb_id)
|
||||
|
||||
if not puzzle:
|
||||
logger.error(f"No puzzle found for IPDB ID {ipdb_id}")
|
||||
return
|
||||
|
||||
scrobble_dict = {
|
||||
"user_id": user_id,
|
||||
"timestamp": timezone.now(),
|
||||
"playback_position_seconds": 0,
|
||||
"source": "Vrobbler",
|
||||
}
|
||||
logger.info(
|
||||
"[vrobbler-scrobble] puzzle scrobble request received",
|
||||
extra={
|
||||
"puzzle_id": puzzle.id,
|
||||
"user_id": user_id,
|
||||
"scrobble_dict": scrobble_dict,
|
||||
"media_type": Scrobble.MediaType.PUZZLE,
|
||||
},
|
||||
)
|
||||
|
||||
# TODO Kick out a process to enrich the media here, and in every scrobble event
|
||||
return Scrobble.create_or_update(puzzle, user_id, scrobble_dict)
|
||||
|
||||
Reference in New Issue
Block a user