[tasks] Fix scrobbling tasks
This commit is contained in:
@ -957,7 +957,7 @@ class Scrobble(TimeStampedModel):
|
||||
|
||||
# GeoLocations are a special case scrobble
|
||||
if mtype == cls.MediaType.GEO_LOCATION:
|
||||
logger.warn(
|
||||
logger.warning(
|
||||
f"[create_or_update] geoloc requires create_or_update_location"
|
||||
)
|
||||
scrobble = cls.create_or_update_location(
|
||||
@ -981,7 +981,7 @@ class Scrobble(TimeStampedModel):
|
||||
scrobble.can_be_updated
|
||||
or scrobble_data["playback_status"] == "stopped"
|
||||
):
|
||||
if "log" in scrobble_data.keys():
|
||||
if "log" in scrobble_data.keys() and scrobble.log:
|
||||
scrobble_data["log"] = scrobble.log | scrobble_data["log"]
|
||||
return scrobble.update(scrobble_data)
|
||||
|
||||
@ -997,7 +997,8 @@ class Scrobble(TimeStampedModel):
|
||||
},
|
||||
)
|
||||
|
||||
return cls.create(scrobble_data)
|
||||
scrobble = cls.create(scrobble_data)
|
||||
return scrobble
|
||||
|
||||
@classmethod
|
||||
def create_or_update_location(
|
||||
@ -1151,7 +1152,6 @@ class Scrobble(TimeStampedModel):
|
||||
cls,
|
||||
scrobble_data: dict,
|
||||
) -> "Scrobble":
|
||||
scrobble_data["log"] = {}
|
||||
scrobble = cls.objects.create(
|
||||
**scrobble_data,
|
||||
)
|
||||
|
||||
@ -313,11 +313,11 @@ def manual_scrobble_task(url: str, user_id: int):
|
||||
if "shortcut" in url:
|
||||
source = "Shortcut"
|
||||
title = "Generic Shortcut task"
|
||||
description = url.split("/")[-1]
|
||||
description = " ".join(url.split("/")[-1].split("-")).capitalize
|
||||
if "todoist" in url:
|
||||
source = "Todoist"
|
||||
title = "Generic Todoist task"
|
||||
description = url.split("-")[-1]
|
||||
description = " ".join(url.split("/")[-1].split("-")[:-1]).capitalize
|
||||
|
||||
task = Task.find_or_create(title)
|
||||
|
||||
@ -337,7 +337,6 @@ def manual_scrobble_task(url: str, user_id: int):
|
||||
"media_type": Scrobble.MediaType.WEBPAGE,
|
||||
},
|
||||
)
|
||||
|
||||
scrobble = Scrobble.create_or_update(task, user_id, scrobble_dict)
|
||||
return scrobble
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ from scrobbles.models import (
|
||||
RetroarchImport,
|
||||
Scrobble,
|
||||
)
|
||||
from scrobbles.scrobblers import manual_scrobble_from_url
|
||||
from scrobbles.scrobblers import *
|
||||
from scrobbles.tasks import (
|
||||
process_koreader_import,
|
||||
process_lastfm_import,
|
||||
|
||||
@ -14,6 +14,7 @@ BNULL = {"blank": True, "null": True}
|
||||
|
||||
@dataclass
|
||||
class TaskLogData(LongPlayLogData):
|
||||
description: Optional[str] = None
|
||||
source_id: Optional[str] = None
|
||||
serial_scrobble_id: Optional[int] = None
|
||||
long_play_complete: Optional[bool] = None
|
||||
|
||||
Reference in New Issue
Block a user