[tasks] Fix scrobbling tasks
This commit is contained in:
@ -957,7 +957,7 @@ class Scrobble(TimeStampedModel):
|
|||||||
|
|
||||||
# GeoLocations are a special case scrobble
|
# GeoLocations are a special case scrobble
|
||||||
if mtype == cls.MediaType.GEO_LOCATION:
|
if mtype == cls.MediaType.GEO_LOCATION:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
f"[create_or_update] geoloc requires create_or_update_location"
|
f"[create_or_update] geoloc requires create_or_update_location"
|
||||||
)
|
)
|
||||||
scrobble = cls.create_or_update_location(
|
scrobble = cls.create_or_update_location(
|
||||||
@ -981,7 +981,7 @@ class Scrobble(TimeStampedModel):
|
|||||||
scrobble.can_be_updated
|
scrobble.can_be_updated
|
||||||
or scrobble_data["playback_status"] == "stopped"
|
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"]
|
scrobble_data["log"] = scrobble.log | scrobble_data["log"]
|
||||||
return scrobble.update(scrobble_data)
|
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
|
@classmethod
|
||||||
def create_or_update_location(
|
def create_or_update_location(
|
||||||
@ -1151,7 +1152,6 @@ class Scrobble(TimeStampedModel):
|
|||||||
cls,
|
cls,
|
||||||
scrobble_data: dict,
|
scrobble_data: dict,
|
||||||
) -> "Scrobble":
|
) -> "Scrobble":
|
||||||
scrobble_data["log"] = {}
|
|
||||||
scrobble = cls.objects.create(
|
scrobble = cls.objects.create(
|
||||||
**scrobble_data,
|
**scrobble_data,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -313,11 +313,11 @@ def manual_scrobble_task(url: str, user_id: int):
|
|||||||
if "shortcut" in url:
|
if "shortcut" in url:
|
||||||
source = "Shortcut"
|
source = "Shortcut"
|
||||||
title = "Generic Shortcut task"
|
title = "Generic Shortcut task"
|
||||||
description = url.split("/")[-1]
|
description = " ".join(url.split("/")[-1].split("-")).capitalize
|
||||||
if "todoist" in url:
|
if "todoist" in url:
|
||||||
source = "Todoist"
|
source = "Todoist"
|
||||||
title = "Generic Todoist task"
|
title = "Generic Todoist task"
|
||||||
description = url.split("-")[-1]
|
description = " ".join(url.split("/")[-1].split("-")[:-1]).capitalize
|
||||||
|
|
||||||
task = Task.find_or_create(title)
|
task = Task.find_or_create(title)
|
||||||
|
|
||||||
@ -337,7 +337,6 @@ def manual_scrobble_task(url: str, user_id: int):
|
|||||||
"media_type": Scrobble.MediaType.WEBPAGE,
|
"media_type": Scrobble.MediaType.WEBPAGE,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
scrobble = Scrobble.create_or_update(task, user_id, scrobble_dict)
|
scrobble = Scrobble.create_or_update(task, user_id, scrobble_dict)
|
||||||
return scrobble
|
return scrobble
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ from scrobbles.models import (
|
|||||||
RetroarchImport,
|
RetroarchImport,
|
||||||
Scrobble,
|
Scrobble,
|
||||||
)
|
)
|
||||||
from scrobbles.scrobblers import manual_scrobble_from_url
|
from scrobbles.scrobblers import *
|
||||||
from scrobbles.tasks import (
|
from scrobbles.tasks import (
|
||||||
process_koreader_import,
|
process_koreader_import,
|
||||||
process_lastfm_import,
|
process_lastfm_import,
|
||||||
|
|||||||
@ -14,6 +14,7 @@ BNULL = {"blank": True, "null": True}
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class TaskLogData(LongPlayLogData):
|
class TaskLogData(LongPlayLogData):
|
||||||
|
description: Optional[str] = None
|
||||||
source_id: Optional[str] = None
|
source_id: Optional[str] = None
|
||||||
serial_scrobble_id: Optional[int] = None
|
serial_scrobble_id: Optional[int] = None
|
||||||
long_play_complete: Optional[bool] = None
|
long_play_complete: Optional[bool] = None
|
||||||
|
|||||||
@ -290,6 +290,7 @@
|
|||||||
{% if scrobble.media_obj.primary_image_url %}<div style="float:left;padding-right:10px;padding-bottom:10px;"><img src="{{scrobble.media_obj.primary_image_url}}" /></div>{% endif %}
|
{% if scrobble.media_obj.primary_image_url %}<div style="float:left;padding-right:10px;padding-bottom:10px;"><img src="{{scrobble.media_obj.primary_image_url}}" /></div>{% endif %}
|
||||||
<p><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></p>
|
<p><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></p>
|
||||||
{% if scrobble.media_obj.subtitle %}<p><em><a href="{{scrobble.media_obj.subtitle.get_absolute_url}}">{{scrobble.media_obj.subtitle}}</a></em></p>{% endif %}
|
{% if scrobble.media_obj.subtitle %}<p><em><a href="{{scrobble.media_obj.subtitle.get_absolute_url}}">{{scrobble.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||||
|
{% if scrobble.logdata.description %}<p><em>{{scrobble.logdata.description}}</em></p>{% endif %}
|
||||||
<p><small>{{scrobble.timestamp|naturaltime}} from {{scrobble.source}}</small></p>
|
<p><small>{{scrobble.timestamp|naturaltime}} from {{scrobble.source}}</small></p>
|
||||||
<div class="progress-bar" style="margin-right:5px;">
|
<div class="progress-bar" style="margin-right:5px;">
|
||||||
<span class="progress-bar-fill" style="width: {{scrobble.percent_played}}%;"></span>
|
<span class="progress-bar-fill" style="width: {{scrobble.percent_played}}%;"></span>
|
||||||
|
|||||||
@ -52,16 +52,16 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Date</th>
|
<th scope="col">Date</th>
|
||||||
|
<th scope="col">Description</th>
|
||||||
<th scope="col">Source</th>
|
<th scope="col">Source</th>
|
||||||
<th scope="col">ID</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
|
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{scrobble.timestamp}}</td>
|
<td>{{scrobble.timestamp}}</td>
|
||||||
<td>{{scrobble.media_obj.source}}</td>
|
<td><a href="{{scrobble.source_url_for_user}}">{{scrobble.logdata.description}}</a></td>
|
||||||
<td><a href="{{scrobble.source_url_for_user}}">{{scrobble.logdata.source_url_pattern.label}}</a></td>
|
<td>{{scrobble.source}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user