[PLUGIN] Pandora Plugin 2.0

@Jim_Edwards
Ok. You may be my first premium tester.

Try this. SSH to your volumio machine and type:

sed -i 's/tuner/internal-tuner/' /data/plugins/music_service/pandora/node_modules/anesidora/anesidora.js

That’s all on one line. It just changes one URL in that source file.

If that works, I can work out a fix. This is not my code; it’s the main dependency for the plugin.

If this doesn’t work, revert the change with:

sed -i 's/internal-tuner/tuner/' /data/plugins/music_service/pandora/node_modules/anesidora/anesidora.js

For anyone who does not have a premium Pandora account, this change will not work for you.

This works as long as the pandora one toggle is off, but gives the same error if I try to toggle it on.

@Jim_Edwards
Did the plugin ever work for you with the Pandora One switch set to on?

Yes it was working before around 9/16, I think that pandora pushed an update around that time - I noticed an update in my (official) pandora app.

@Jim_Edwards
What the plugin switch does is to change the additional credentials used to log in to the Pandora servers. You may well be right – the keys for Pandora One may have changed. Unfortunately I don’t know what the new ones are. I’m not sure I’m going to know, either.

I guess you’ll have to turn that switch off for a loss in audio quality (128 Kbps). If I become aware of a fix, I can implement it but I think we’re stuck at the moment.

Thanks for being a trouper and helping me debug this. That error logging section had to be fixed anyway, so for me it wasn’t a waste of time.

I’ll make a note on that switch option or perhaps remove it for the next plugin release.

@truckershitch Thank you very much. If I can do more to help debug please let me know.

@truckershitch I spoke too soon wrt to the sed change to internal-tuner, after a reboot that did not work. I changed back to tuner and it’s working but without the premium features that I should have. Let me know if you want to try anything else.

@Jim_Edwards
Well, the thing is, all that sed command did was to change the address the client connects to. The anesidora code sends either the premium credentials or the standard ones (depending on that boolean switch) to one address – the “tuner” prefix address, or the “internal-tuner” prefix address if you manually change it.

In the API, the “internal-tuner” address is specified for the premium account, and that’s what I see in other client implementations, but for some reason, “tuner” was working just fine until now. Go figure.

I thought the problem was the address, but since it was working for you before a few days ago, that doesn’t seem to be the case. It seems like the credentials are no longer working. I verfied that the simple sed substitution works so I’m not sure what’s going on.

@Jim_Edwards
One more thing:

Did you switch to ‘internal-tuner’ and then reboot, and then restart the plugin, enabling Pandora One? Maybe this didn’t happen.

Definitely check the anesidora.js file after the substitution. If you want, you can just edit the file with nano.

Just do:

grep tuner /data/plugins/music_service/pandora/node_modules/anesidora.js

Make sure it says:

Anesidora.ENDPOINT = "://internal-tuner.pandora.com/services/json/";

Reboot. Make sure the Pandora One switch is set and that you save the options.

See, the anesidora library is loaded when the plugin starts, and it won’t be unloaded until the plugin is unloaded, or possibly after a reboot. It might take a reboot to unload that library due to caching; I’m not sure. A reboot would be best.

Just for kicks, I’d try that one more time before you rule everything out.

Debugging is a hassle.

@truckershitch Tried once more: made the change in anesidora.js, set the pandora one switch, rebooted. It’s working! Thanks

@Jim_Edwards Great! Okay, then, I’ll fork anesidora and have the plugin load my version.

v2.5.3 (beta) has been updated on my GitHub fork. If you want to test it, you will have to clone it first, change to the pandora directory and run volumio plugin update Simply dragging and dropping the new files won’t do the job.

The link is in the first post of the thread.

I’ve been quiet - when I copied the file over my problem didn’t go away and today when I tied updating to 2.5.1 through the UI I couldn’t uninstall the plugin, had to factory reset (no worries, just pandora setup lost). I’ll do the clone and update tonite.

I have been watching my queue for the last few hours, I was listening to pandora with the queue displayed. I clicked pause and the music stopped and slowly the songs have expired from the queue and it has cleared. The song that was “in play” is still on the queue…maybe dequeueing it would solve some issues?

I just used the ui to upgrade to 2.5.3. The update seems to have take (running 2.5.3 now) but thee was an error during install…as of now I’m not having any other issues…horray!!!

v2.6.0 RC (release candidate – I’ve been testing all day and I think it’s fine)

I just pushed this to my GitHub fork. Link and instructions are in the first post in the thread.

You’re going to have to install from the command line, I’m afraid, unless you want to copy all of the new files. If you do that, make sure you get them all, even the i18n/strings.json file, or you’ll have a broken plugin.

REBOOT the machine after updating for best results. Sometimes the libraries stick around in memory.

Fix:

  • That d#$% green Play arrow wasn’t refreshing when tracks were removed from the queue. The plugin now pushes the state after each deletion. Now it works without refreshing the browser window.

New:

  • Serious queue voodoo. I spent a few days getting this part right. When you change stations, and then change back, you’ll see the older tracks moved behind the current station tracks:
  • Station track ‘max’: Plugin will use this value as a guideline when downloading tracks. Sometimes there will be a few more, sometimes less (no more than max + 3 tracks per station. Set this in the plugin options.

Ax and Bx are tracks from station A and B
Currently playing track in [brackets]

Now on station B:
Queue: A1 A2 A3 A4 [B1] B2 B3 B4
Change back to A station:
Queue: B1 B2 B3 B4 A1 A2 A3 A4 [A5] A6 A7 A8

If the total goes over the max, then tracks are removed from the rear of the station tracks (starting at A1 in this case).

Getting this to work involved a lot of moving numbers and letters around on spreadsheets to learn the proper criteria for moving tracks. For some reason, the built-in Volumio self.commandRouter.stateMachine.moveQueueItem(from, to) function was not moving the currentPosition. I may have done this wrong – maybe I have to bind the function to self? I just grabbed that part of the function and wrapped my call.

Give it a shot if you want! Remember, you can just uninstall it.

I’m going to take it easy on it tonight but I’ll have one more good look at it tomorrow before I file a pull request.

v2.7.1 Release

This release adds the API error codes with explanations (best information is in the systemd log). Starting and stopping the plugin was fixed. Changing the settings should not require a restart of the plugin now.

The code base is now broken into three main files: index.js, timers.js, and handler.js, and the API error codes are in errorcodes.json. I wrapped the built-in setTimeout function to return a Promise. There are several other refactoring changes. Most are listed in the Readme.md file.

It’s been ready on the Plugins menu for about a week. Good luck with it.

After about 45 minutes pandora creds get refreshed and everything in the queue gets expired and volumio goes silent. clicking on a station starts play, after 45 minutes repeat…

@downtownHippie

I rewrote the timers in the plugin to try and consolidate the code, and the track expiration got a little more complicated. It was crashing the plugin and causing Volumio to restart. I patched it up. It seems to be working now.

I’ll take one more look at it tomorrow morning and post my changes on GitHub. I’ll leave a note here when I’m done.

1 Like

@downtownHippie

Version 2.7.2 pushed to my GitHub fork, linked in first post in this thread.

timers.js is really the only file that changed here and index.js have changed if you just want to copy that those files over, or do the full plugin install if you want.

Let me know how this works for you.

EDIT: index.js also changed after my initial fix this morning.

Version 2.7.2 is now available in the Plugin menu.

Besides addressing the bug found by @downtownHippie, a change was made to the queue logic when changing stations without flushing the tracks. It is much simpler now. There may have been a bug there before – I am not certain – but this change should take care of that.

I don’t have any really big ideas left. I’m not sure what else I can implement given the limited interface GUI options available to the plugins (I can’t just add a button, for example). I could explore sending instructions to the plugin in some network fashion, but I don’t think that’s really needed.

If one really wants better control of Pandora, he/she can go to the Pandora website. And there is pianod, a powerful alternate client. Check it out.

Let me know if you have any problems and I’ll try to fix them.

Enjoy!