[PLUGIN] Pandora Plugin 2.0

just got the red error flag again, rPi has had it’s date fixed. I also uninstalled the old plugin, rebooted and installed v2.3.4 I was working earlier this morning. Played some local music then tried to get a station to load.

Aug 13 13:06:45 dhvani volumio[1013]: info: [1597324005801] ControllerPandora::PandoraHandler::fetchTracks

Aug 13 13:06:45 dhvani volumio[1013]: info: [1597324005802] ControllerPandora::PandoraHandler::fetchTracks::fetchStationPlaylist

Aug 13 13:06:46 dhvani volumio[1013]: error: [1597324006220] [Pandora] Error in PandoraHandler::fetchTracks::fetchStationPlaylist: Error: An unexpected error occurred [1001]

Aug 13 13:06:46 dhvani volumio[1013]: error: [1597324006222] [Pandora] Error in PandoraHandler::fetchTracks::fillNewTracks: Error: [1597324006221] [Pandora] PandoraHandler::fetchTracks::fetchStationPlaylist error: Error: An unexpected error occurred [1001]

Aug 13 13:06:46 dhvani volumio[1013]: error: Failed to execute browseSource: Error: [1597324006223] [Pandora] PandoraHandler::fetchTracks::fillNewTracks error: Error: [1597324006221] [Pandora] PandoraHandler::fetchTracks::fetchStationPlaylist error: Error: An unexpected error occurred [1001]

stopping and starting the plugin and it’s working now.

there is also an occasional long delay between songs…eh, maybe only once at the beginning, been going strong all day.

Error 1001 is a timeout on the login authorization. Maybe you left the plugin logged in for a long time? I’m not sure how long it takes to time out, but I’ve had it running for about three hours before.

For now, switch off the plugin and switch it back on once in a while to prevent the timeout error.

After a fixed amount of time, the user could be logged out and logged back in. The queue would need to be cleared of all Pandora tracks and started again. I’ll take a look at it tomorrow.

I’ll grab that error message when it occurs during fillTracks() and give a proper error message in the GUI.

Version 2.4.0 is on the way. I pushed it to my GitHub fork (linked in the first post). It should be available in the main Volumio Plugin menu soon.

If you’re itching to try it, check out the GitHub page. Instructions are in the Readme.md file. I’d probably back up Volumio to be safe, but you can always uninstall the plugin from the Plugins menu and go back to the old version if you want. You’ll be okay.

Version 2.4.0 is ready for you to break.
Update through the Volumio Plugins menu. Do your worst.

There are several changes:

  • Choosing a station starts playback. The first track is automatically chosen. Switch to the Queue view as before to change tracks, etc.
  • New option to keep old station tracks or flush them on a station change. Choose your poison in the plugin configuration.
  • Stale logins should be handled now. The plugin logs back in every three hours or so. Playback continues as usual.
  • Login errors are handled better. The error code is shown and the code is interpreted.
  • Some refactoring / code cleanup.

To Do:

  • Handle other Pandora error codes with appropriate error toasts in the GUI.
    The errors are presently shown in the log. Type journalctl --help for other options.
  • The queue fills up after a few tracks are played (tracks download unless queue size >= 20 which seems good since tracks expire eventually). If the user keeps tracks between station changes, new tracks will not download until some space is made in the queue.
    Perhaps a few old tracks could be removed to make room for the new ones. Thoughts?
    Does anyone care?

Okay, signing off. Throw a rock if you need me.

when in contemporary mode, with the queue displayed - when a song dequeues at the end of play the panel refreshes. the queue always refreshes 1/2 of a song scrolled from the top. It’s just a display thing, and it might not be the plugin, essentially the queue page display the current song, but the panel is scrolled just a bit and the current song stays above the viewable region.

Is that you or volumio?

there’s a details dialog for plugins, Pandora has no details

@downtownHippie:

  • Display glitch: That’s Volumio – I haven’t written any display code.
  • Details dialog: I’m not sure where that data is pulled from. It might be in package.json but I’m not sure. I notice the details are blank for several plugins.

Another Volumio glitch – when a track is removed from the queue, the wrong track is highlighted in the Queue with the green play triangle over the album art. The back end is fine; it’s just the GUI. The correct track is chosen for playback. A browser page refresh will fix the green play icon.

v2.5.0 is ready on my GitHub fork.

It has several new features. See the Readme.md file at my fork – I’m feeling lazy right now.

You might want to try it out. If you want to, you can clone the fork, change to the pandora directory and execute volumio plugin update to install it.

Remember, you can always just remove the plugin from the Plugins menu and install the version that is currently available. I’ve lost track of what version number that is right now! I’ve made a few updates over the past weeks.

If you would rather wait, I submitted a new pull request and it should be available after it gets approved in the Volumio Plugins menu as an update.

Thanks for your input, @downtownHippie . I encourage the rest of the viewers of this thread to do the same.

@downtownHippie: I just thought of something you could try:

ssh to your Volumio machine. Then:

sed -i 's/maxStationTracks = 20/maxStationTracks = 16/' /data/plugins/music_service/pandora/index.js

20 is the original maxStationTracks value. That sed one-liner will change it to 16.

When that number of individual station tracks is reached, no more tracks will be downloaded from that station (so you might have 19 tracks at one point in this example – no more that 4 tracks will ever download at once).

Bear in mind that each station will have that same maximum, so if you change stations and you aren’t clearing old station tracks (set in the options), you’ll have more than 16 (19?) for a little while until old tracks are removed.

I can add the max value to the options, but I wanted you to be able to do it yourself since you had a problem with larger queues.

Remember, if you do it twice, the line will look like:

sed -i 's/maxStationTracks = 16/maxStationTracks = 12/' /data/plugins/music_service/pandora/index.js

or similar.

v2.5.1 is up and ready for update from the Plugins menu.

You’ve built thumbs down into the ui, any consideration on how to implement thumbs up from the volumio ui?

running 2.5.1, no issues. I’ve not spent much time with the change stations and queue/dequeue feature yet, might mix it up today a little.

Just checking in. plugin seems to be amazing. I have still not played with the changing stations and how that affects queue yet - I get stuck on stations for hours. The only issue I ever have is since I never turn anything (computer wise) off, or whatever, I often need to stop and start the plugin if I’ve not listened in a day or so, and especially if the last thing I was doing in Volumio was listening to pandora…like quite awhile ago…

That is something I have not tested. I usually just flip it off after I’m done listening. I put a three hour timer in there that is supposed to refresh the login information periodically, but I’m not positive that it’s fixing the issue.

When this happens, you could grab a log. That might explain things. The thing is, it would run for a long time and the log would be extensive. The last three or four hours should be enough and I think the plugin will throw an error of some sort.

There might be personal information in there so it should be inspected before posting it anywhere or sending it to me via a direct message. The log wouldn’t show a password or email address for Pandora but other things might be shown.

Anyway, it sounds like it’s working out for you. I appreciate the input as currently (as far as I know) you’re the only one who is helping with the debugging.

Hey there. I am new to Volumio and was quite glad to find your Pandora plugin…! I have v2.5.1 installed with the latest version of Volumio. I initially had issues with “No results” regularly popping up but setting NPT resolved it. However, what I’m seeing is that after several hours inactivity, or if I listen to Pandora on another device, Volumio will report “No results” until after the plugin is restarted…

Is this something that you feel could be corrected? Or is there something on my default setup that needs modification? Thanks

Hey @gfisher

Like I said in my last post, I have a timer set every three hours that is supposed to refresh your Pandora login credentials. It would appear that this isn’t working or perhaps it isn’t working when the plugin is idle. Anyway, I’ll have to take a closer look at that. I think I only tested the login refresh when the plugin was actively playing music.

As far as it not working if you log into your Pandora account from another device, I’m not sure what happens there, either. That’s something I haven’t tried to do or thought of.

Basically, the plugin makes calls to an undocumented web API on the Pandora server. Pandora has this set up but they don’t support it, though it has worked for a few years as I understand it. This plugin basically makes requests to the server and it answers in kind. I did not see anything about login limits or timeouts – I’m really just guessing on how long a login might last.

What you could do, if you don’t mind, is to duplicate your error and send me the log privately. Or you can post it here if you want but you should scan it in case there is personal information in it. I don’t think the plugin really prints anything but perhaps the rest of the log will.

So what you need to do is this:

  • Reboot your Volumio machine. This is important because we want to grab the log after it has started to reboot.
  • Start the plugin and then let it go inactive. I suppose this means clearing the Pandora tracks from the queue. Or do whatever it is that is not working for you.
  • Get to a shell prompt by connecting to your Volumio machine via SSH. SSH may already be enabled but if not, you can go to http://volumio.local/dev or http://your-volumio-ip/dev and enable it.
  • To return all system messages since the last reboot:
    journalctl -b --no-pager > /home/volumio/volumio.log
  • You should be in the volumio home directory, /home/volumio Pardon me if this is too basic, but you can just type the file to the screen and paste it into an editor like Notepad if you are in Windows, though I strongly recommend Notepad+. Take a look at it and you can trim the unnecessary parts but try to leave at least three or four hours so we see if the login refresh routine is at least running. And of course you can transfer the file like any other Linux text file.
  • I’d probably compress the file when finished (but it’s not necessary):
    gzip volumio.log or whatever compression you want as long as you leave the proper extension on the file.

The fix will just be jumping through the right hoops to make sure Pandora logs back in. And I guess if that isn’t working, the plugin could unload itself. But I think there probably is a way.

In the 1.0.0 version, the plugin logged in every time a station was loaded. I don’t know if this is a good idea – there may be a limit on logins. Hence the name ‘Unofficial Pandora API’ :slight_smile:

Anyway, it will get sorted.

I really don’t know how I missed that previous post as it is asking the same thing…! Sorry about that.

Sure, I can get you the logging as I’m sure it will happen again tomorrow morning when I sit down to my desk.

Thanks again! I greatly appreciate your work on this. It is honestly the only reason I gave Volumio a try as Pandora is about all I use.

I see my error. I had the authorization timer in the play loop, so if there are no tracks playing, I assume the login timed out after an unknown interval. I’m going to stick with an update every three hours to be conservative and we can go from there. It’s clearly marked in the code if you want to try to fix it yourself.

I made a small fix but I haven’t posted it yet as I haven’t tried it. My house is a tad chaotic at the moment so I might not get to it for a couple of hours. The change isn’t radical so hopefully it will do the job.

1 Like

I pushed a commit to my GitHub fork. The URL is in the initial post. The only real change is to index.js and you can just replace it if you want to, or you can follow the instructions on my GitHub page and replace the whole thing. The only difference is that the second way increments the version number to 2.5.2 but it really makes no difference if you’re just testing it.

It would be great if you guys gave it a shot. It starts, logs in, and will log back in every three hours. The loop is about as simple as they come (setInterval loop) and the object modeled after an existing function.

Anyway, you don’t really need to know all that. I’m going to let it run idle for a while and check it later to see if the stations load up. To test it, load the plugin as usual and restart Volumio. Leave it alone for a good bit (at least three hours) and come back and try to load a station.

If you try it out, let me know if it works or fails.

Thanks!

fun time stamp - 4:20pm CT tuesday afternoon
git clone of the new tree
I stopped the plugin
I’ve copied your new index.js to
/data/plugins/music_service/pandora
restarted the plugin. I’ll stop pandora in awhile and awhile after that it’ll maybe not timeout - I should have a report by morning at the latest.

the community software is complaining I post too much (46% of posts)…ya’ll invite some friends and get them to say him once in awhile so I don’t get non-AI software complaining about my actions :- )

Thanks! I’ll give it a shot as soon as I’m back at my desk in the morning… Oh, and as far as the undocumented API… wouldn’t you supposed Sonos is using the same API? Or is there a newer, official API that maybe requires registration? Just curious…

My pandora plugin (2.5.1) is no longer working. The plugin shows as active but it is not appearing as an option on the home page. I noticed on the same day that the plugin quit working that the pandora app sent an update out. I wonder if the api has somehow changed to cause this problem?

1 Like

@Jim_Edwards
The plugin seems to be working here. I don’t think the connectivity to the Pandora servers has changed. I have a pretty vanilla setup, Pi 3B+, etc, and I live in the USA so I’m not doing any VPN/proxy magic. I just restarted the machine through the Volumio web page and playback is working.

@downtownHippie @gfisher
Regarding the 2.5.2 beta: I let it run for about six hours last night and I was able to select a station this morning, so it looks good on my end. How about you?

@Jim_Edwards
The beta only changes the problem with leaving the plugin inactive for several hours, but you’re welcome to try it if you want.