Fix retroarch times not in UTC

This commit is contained in:
2023-05-26 23:12:43 -04:00
parent 6ee57cb7cd
commit 704409cf6e

View File

@ -94,21 +94,25 @@ def import_retroarch_lrtl_files(playlog_path: str, user_id: int) -> List[dict]:
if found_game: if found_game:
found_scrobble = found_game.scrobble_set.filter( found_scrobble = found_game.scrobble_set.filter(
timestamp=game_data["last_played"] stop_timestamp=game_data["last_played"]
) )
if found_scrobble: if found_scrobble:
logger.info( logger.info(
f"Found scrobble for {game_name} with timestamp {game_data['last_played']}, not scrobbling" f"Found scrobble for {game_name} with stop_timestamp {game_data['last_played']}, not scrobbling"
) )
continue continue
last_scrobble = found_game.scrobble_set.last() last_scrobble = found_game.scrobble_set.last()
delta_runtime = 0 delta_runtime = 0
if last_scrobble: if last_scrobble:
delta_runtime = last_scrobble.long_play_seconds delta_runtime = last_scrobble.long_play_seconds
playback_position_seconds = game_data["runtime"] - delta_runtime playback_position_seconds = game_data["runtime"] - delta_runtime
stop_timestamp = game_data["last_played"] + timedelta(
timestamp = game_data["last_played"] + timedelta(
seconds=playback_position_seconds seconds=playback_position_seconds
) )
if playback_position_seconds < 30: if playback_position_seconds < 30:
logger.info( logger.info(
f"Video game {found_game.id} played for less than 30 seconds, skipping" f"Video game {found_game.id} played for less than 30 seconds, skipping"
@ -116,8 +120,8 @@ def import_retroarch_lrtl_files(playlog_path: str, user_id: int) -> List[dict]:
new_scrobbles.append( new_scrobbles.append(
Scrobble( Scrobble(
video_game_id=found_game.id, video_game_id=found_game.id,
timestamp=game_data["last_played"], timestamp=timestamp,
stop_timestamp=stop_timestamp, stop_timestamp=game_data["last_played"],
playback_position_seconds=playback_position_seconds, playback_position_seconds=playback_position_seconds,
played_to_completion=True, played_to_completion=True,
in_progress=False, in_progress=False,