|
@@ -15,6 +15,7 @@ from scrobbles.models import Scrobble
|
|
|
from scrobbles.utils import convert_to_seconds, parse_mopidy_uri
|
|
|
from sports.models import SportEvent
|
|
|
from videos.models import Video
|
|
|
+from videogames.models import VideoGame
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
@@ -200,3 +201,24 @@ def manual_scrobble_event(data_dict: dict, user_id: Optional[int]):
|
|
|
scrobble_dict = build_scrobble_dict(data_dict, user_id)
|
|
|
|
|
|
return Scrobble.create_or_update(event, user_id, scrobble_dict)
|
|
|
+
|
|
|
+
|
|
|
+def manual_scrobble_video_game(data_dict: dict, user_id: Optional[int]):
|
|
|
+ game = VideoGame.find_or_create(data_dict)
|
|
|
+
|
|
|
+ last_scrobble = Scrobble.objects.filter(
|
|
|
+ video_game=game, user_id=user_id, played_to_completion=True
|
|
|
+ ).last()
|
|
|
+
|
|
|
+ playback_position = 0
|
|
|
+ if last_scrobble and not last_scrobble.playback_position:
|
|
|
+ playback_position = last_scrobble.playback_position + (30 * 60)
|
|
|
+ scrobble_dict = {
|
|
|
+ "user_id": user_id,
|
|
|
+ "timestamp": timezone.now(),
|
|
|
+ "playback_position_ticks": playback_position * 1000,
|
|
|
+ "playback_position": playback_position,
|
|
|
+ "source": "Vrobbler",
|
|
|
+ }
|
|
|
+
|
|
|
+ return Scrobble.create_or_update(game, user_id, scrobble_dict)
|