Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add real time now playing support #51

Open
ronilaukkarinen opened this issue May 30, 2017 · 11 comments
Open

Add real time now playing support #51

ronilaukkarinen opened this issue May 30, 2017 · 11 comments

Comments

@ronilaukkarinen
Copy link

Works fine, but scrobbles only afterwards, no progress seen on profile page. I noticed you use pylastfm, it has update_now_playing for this purpose. I have implemented it to my pianobar script here.

I'm not expert in python, but I can try to implement it if/when I got the time. Until then, the stage is yours, if you want this feature.

@duramato
Copy link

Yes please! Think is something I really want, and it's something the native plex scrobbler is missing aswell.

@ronilaukkarinen
Copy link
Author

Pinging this again, since it's been a while... I have occasionally googled about this again and can't believe nobody has implemented it yet. I guess I have to go and figure it out myself on holiday then. Hopefully someone will get inspired to work on this again.

@jesseward
Copy link
Owner

hey @ronilaukkarinen and @duramato as far as i can tell this would be a pretty straight forward change. I will take a look at it this week.

@ronilaukkarinen
Copy link
Author

Awesome! thanks for so quick answer. It would make my life more complete as I use Plexamp more and more. I don't know much about python so getting into it would be indeed a study-thing. However here's again (if you didn't spot my link earlier) how I did it on Pandora cli client.

@ronilaukkarinen
Copy link
Author

Not really experienced in python, but tried to give it a go today. I almost got it, but two things I'm struggling with:

  • How to get "song started" status in plex_monitor.py
  • How to get "duration" metadata

@ronilaukkarinen
Copy link
Author

ronilaukkarinen commented Jul 30, 2018

Update: Currently handling this with a simple python script on Tautulli + the official scrobbling for Plex.

@ronilaukkarinen
Copy link
Author

Repo is now online, if someone needs it..., check it out.

@outpoints
Copy link

Sorry to necro this but do you by any chance still have this file? @ronilaukkarinen

@ronilaukkarinen
Copy link
Author

#!/usr/bin/python3.7
import os
import sys
import time
import pylast
import subprocess

artist = sys.argv[1]
album = sys.argv[2]
title = sys.argv[3]
duration = int(sys.argv[4])

# You need to add to to Arguments Playback Start and Playback Resume:
# "{track_artist}" "{album_name}" "{track_name}" {remaining_duration_sec}

print("PLEX: Trying to get metadata for: {0} / {1} / {2} / {3}".format(artist, album, title, duration))

network = pylast.LastFMNetwork(api_key="API_KEY_HERE", api_secret="API_SECRET_HERE",
                               username="USERNAME_HERE", password_hash=pylast.md5("PASSWORD_HERE"))

network.update_now_playing(artist = artist, album = album, title = title, duration = duration)
print("LAST.FM: Updated now playing status successfully for {0} - {2} (from album {1})".format(artist, album, title))

@markbchavez
Copy link

Thank you Roni for sharing the Tautulii script. I saved it as a .py file, ensured I had python installed (I used windows store) and selected Triggers of Playback Start and Playback Resume (don't select others as the parameter requirements are different) and added the arguments as noted in the script for Playback Start and Playback Resume. I used the Tautulli logs to see it running. Note that it seems with the duration information, Last.fm automatically handles Pausing and Stopping by removing scrobbles that didn't finish.

This filled a gap in the built-in Plex last.fm integration which would eventually post to last.fm but didn't add the necessary details to cover the nowplaying functionality. I am using this to display my NowPlaying music on my DakBoard digital display leveraging other functionality shared by reddit user Psukez10 at https://www.reddit.com/r/dakboard/comments/11ri22t/made_a_widget_to_display_lastfm_now_scrobbling/ which shows the artist, track, and cover art while something is playing and doesn't show it when nothing is playing (and in my case reveals family photos) . This allows me to used Last.fm for the Now Playing and then just rely on music service integrations to Last.fm (for those that have it) like Plex and Spotify. Speed of updates seems to be based on the source service and last.fm update frequency.

LastFMScrobbling

@markbchavez
Copy link

Here is the code in a txt file for my prior comment.... As I mentioned above, I only modified slightly the code created by someone else and commented as such.

LastFMNowPlaying.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants