Skip to content

Commit

Permalink
Scrobble when metadata changes
Browse files Browse the repository at this point in the history
- Also fixed markdown issue in README.md
  • Loading branch information
GioF71 committed Dec 21, 2024
1 parent 3712759 commit 7a39c69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A simple LAST.fm scrobbler for WiiM devices.

I started taking the code published in [this post](https://forum.wiimhome.com/threads/last-fm.3144/post-44653) as the starting point.
It seems that I cannot get a valid link to the user profile on that board, but anyway the nickname is `cc_rider`.
A big thank you goes to him/her for the code he/she shared.
A big thank you goes to him/her for the code he/she shared.
I then used [pylast](https://github.com/pylast/pylast), as suggested in that thread, for the actual operations on [last.fm](https://www.last.fm/).

## Links
Expand Down Expand Up @@ -86,6 +86,7 @@ Start the container with the following:

DATE|DESCRIPTION
:---|:---
2024-12-21|Scrobble when metadata changes
2024-12-20|More granular handling of events
2024-12-19|Algorithm reviewed, should be working now
2024-12-18|Now playing is executed when appropriate only
Expand Down
1 change: 1 addition & 0 deletions upnp_scrobbler/player_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PlayerState(Enum):
PAUSED_PLAYBACK = "PAUSED_PLAYBACK"
STOPPED = "STOPPED"
TRANSITIONING = "TRANSITIONING"
NO_MEDIA_PRESENT = "NO_MEDIA_PRESENT"


def get_player_state(transport_state: str) -> PlayerState:
Expand Down
5 changes: 5 additions & 0 deletions upnp_scrobbler/scrobbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ def on_event(
print("Updating Now Playing with song information because we have new metadata ...")
on_playing(from_metadata)
now_playing_updated = True
# did the song change?
if g_previous_song and not same_song(g_previous_song, g_current_song):
maybe_scrobble(current_song=g_current_song)
# we scrobbled so we reset g_current_song
g_current_song = None
else:
print("Not updating g_current_song")
else:
Expand Down

0 comments on commit 7a39c69

Please sign in to comment.