Skip to content

Commit

Permalink
Remove handling of impossible situation
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 committed Dec 22, 2024
1 parent 3575854 commit 8dd1023
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ Start the container with the following:

DATE|DESCRIPTION
:---|:---
2024-12-22|Remove handling of impossible situation
2024-12-22|Catch empty metadata
2024-12-22|Don't consider track_uri as a difference between tracks
2024-12-22|Add logs on maybe_scrobble in order to verify calculations
2024-12-22|Explicitly return None in get_items
2024-12-22|Add logs on maybe_scrobble in order to verify calculations
2024-12-22|Add timestamp to log lines, more logging
2024-12-21|Add log before scrobbling when metadata changes
Expand Down
22 changes: 1 addition & 21 deletions upnp_scrobbler/scrobbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def on_event(
last_change = service_variables[0]
dlna_handle_notify_last_change(last_change)
else:
now_playing_updated: bool = False
sv_dict: dict[str, any] = service_variables_by_name(service_variables)
# must have transport state
previous_player_state: PlayerState = g_player_state
Expand Down Expand Up @@ -300,7 +299,6 @@ def on_event(
# notify now playing if configured
print("Updating Now Playing with song information because we have new metadata ...")
on_playing(new_metadata)
now_playing_updated = True
# did the song change?
if g_previous_song and not same_song(g_previous_song, g_current_song):
print("Scrobbling because we have a new song in incoming metadata (new_metadata)")
Expand All @@ -316,7 +314,7 @@ def on_event(
print(f"Player state is [{g_player_state.value}] previous [{previous_player_state.value}] "
f"metadata_key [{metadata_key}] new_metadata [{new_metadata is not None}] "
f"g_current_song [{g_current_song is not None}]")
if metadata_key:
if new_metadata:
# song changed
song_changed: bool = g_previous_song is None or not same_song(new_metadata, g_previous_song)
print(f"Song changed: [{song_changed}] "
Expand All @@ -326,24 +324,6 @@ def on_event(
maybe_scrobble(current_song=g_previous_song)
print(f"Resetting g_current_song while handling [{PlayerState.PLAYING.value}] ...")
g_current_song = None
else:
# we update the now playing
if new_metadata:
if not now_playing_updated:
print("Updating Now Playing with song information from incoming metadata ...")
on_playing(new_metadata)
else:
print("Now Playing (case #1) has been updated already ...")
else:
# just update if we have a g_current_song
if g_current_song:
if not now_playing_updated:
print("Updating Now Playing with song information from g_current_song ...")
on_playing(g_current_song)
else:
print("Now Playing (case #2) has been updated already ...")
else:
print("Empty g_current_song, cannot update Now Playing")
elif PlayerState.PAUSED_PLAYBACK.value == g_player_state.value:
print(f"Player state is [{g_player_state.value}] previous [{previous_player_state.value}] "
f"metadata_key [{metadata_key}] new_metadata [{new_metadata is not None}] "
Expand Down

0 comments on commit 8dd1023

Please sign in to comment.