I have the Squeezebox plug-in working with three Squeezebox radios, a duet, a single reciever and a squeezebox radio. Everything works great except that I cannot find out how to reference any of my Pandora stations. I know that I need to set an event to play a Pandora station, referenced as a playlist. My problem is, where do I get the reference number to point to the Pandora station? I tried using just the URL that Pandora list for each station but that didn't work.
Announcement
Collapse
No announcement yet.
Pandora station reference number/URL
Collapse
X
-
There are two methods that I am aware of.
1. Use squeezebox server web interface to play a pandora station. Then save to a playlist. You can then play the playlist.
2. If you save a station as a favorite then go click on the favorite. If you keep clicking through, evenutally you get a kind of favorite summary page that will show the url link to the station. You can call this url with a hs script and the appropriate squeezebox API command and it will play the station. I believe the station really streams to an .mp3 file that is played.
Comment
-
I've been tinkering with this recently too.
Using the CLI I can play the Pandora station with these commands and some manual parsing. I need more time to make a script. I've hilighted the items in red that you need to carry forward from one command to the other. These numbers seem to change often.
This example will play the Quickmix station
Code:Command: pandora items 0 10 Returns: pandora items 0 10 title%3APandora id%3A[COLOR=Red]6799a2a7.0[/COLOR] name%3AYour%20Stations type%3Alink isaudio%3A0 hasitems%3A1 id3A6799a2a7.1 name%... Command: pandora items 0 10 item_id:6799a2a7.0 Returns:pandora items 0 10 item_id%3A6799a2a7.0 title%3AYour %20Stations id%3A[COLOR=Red]6799a2a7.0.0[/COLOR] name%3AQuickMix type%3Alink image%3Ahttp%3A%2F%2Fwww.mysqueezebox.com%2Fstatic%2Fimages%2Ficons%2Fpandora.png isaudio%3A1 hasitems %3A1... Command: [mac address of the player to command] pandora playlist play item_id:6799a2a7.0.0
Comment
-
Here is a quick script for SB<->Pandora integration. Three main functions:
GetStationList -- gets the list of available Pandora stations and returns a Dictionary of station name and internal station id (used to tell SB what to play)
PlayStationOnPlayer("station name;player name") -- Will play Pandora station X on player Y.
PlayRandomStationOnPlayer("player name") -- Play any randomly chosen Pandora station on Player X
Code:Public Function GetStationList(ByVal param As Object) Dim sbPlugin As Object sbPlugin = hs.Plugin("SqueezeBox") GetStationList = _GetStationList(sbPlugin) End Function Private Function _GetStationList(ByVal sbPlugin As Object) Dim pandoraID As String Dim rtnVal As Object pandoraId = GetPandoraId(sbPlugin) rtnVal = GetStations(sbPlugin, pandoraId, NumChildAll(sbPlugin, pandoraId)) _GetStationList = rtnVal End Function Public Sub PlayStationOnPlayer(ByVal param As Object) Dim sbPlugin As Object sbPlugin = hs.Plugin("SqueezeBox") _PlayStationOnPlayer(sbPlugin, trim(hs.StringItem(param, 1, ";")), trim(hs.StringItem(param, 2, ";"))) End Sub Private Sub _PlayStationOnPlayer(ByVal sbPlugin As Object, ByVal stationName As String, ByVal player As String) Dim pandoraID As String Dim stationId As String pandoraId = GetPandoraId(sbPlugin) stationId = GetStationId(sbPlugin, pandoraId, stationName) PlayThisStationOnThisPlayer(sbPlugin, stationId, player) End Sub Private Sub PlayThisStationOnThisPlayer(ByVal sbPlugin As Object, ByVal stationId As String, ByVal player As String) sbPlugin.PlayerSendCLICommand(player, "pandora playlist play item_id:" & stationId) End Sub Public Sub PlayRandomStationOnPlayer(ByVal param As Object) Dim sbPlugin As Object Dim stations As Object Dim x As Integer Dim o As Object sbPlugin = hs.Plugin("SqueezeBox") stations = _GetStationList(sbPlugin) Randomize() x = SRound(stations.count() * rnd) o = stations.Items PlayThisStationOnThisPlayer(sbPlugin, o(x), trim(hs.StringItem(param, 1, ";"))) End Sub Function SRound(ByVal Real As Double) As Integer Dim tmp As Integer tmp = Val(Real) If Real - tmp >= 0.5 Then SRound = tmp + 1 Else SRound = tmp End If End Function Private Function GetPandoraId(ByVal sbPlugin As Object) Dim rtnVal ' get the top level list this should be ' 0: "You Stations" ' 1: "Create New Station" ' 2: "Genre Stations" ' 3: "Account" rtnVal = sbPlugin.ServerQueryCLICommand("pandora items 0 10") ' ec%3A60%3A8d%3A1c%3A30%3A40 pandora items 0 10 title%3APandora id%3Afd308e5e.0 name%3AYour%20Stations type%3Alink isaudio ' Split on %3A, :, and grab item 7 rtnVal = Split(rtnVal, "%3A") ' now we have "fd308e5e.0 name", get the first part rtnVal = Split(rtnVal(7), " ") GetPandoraId = rtnVal(0) End Function Private Function NumChildAll(ByVal sbPlugin As Object, ByVal id As String) Dim rtnVal ' get the number of items rtnVal = sbPlugin.ServerQueryCLICommand("pandora items 0 0 item_id:" & id) ' ec%3A60%3A8d%3A1c%3A30%3A40 pandora items 0 0 item_id%3A94d24d77.0 count%3A90 ' Split on %3A, :, and grab item 7 rtnVal = Split(rtnVal, "%3A") NumChildAll = rtnVal(7) End Function Private Function GetStations(ByVal sbPlugin As Object, ByVal pandoraId As String, ByVal num As Integer) Dim rtnVal As Object Dim rtnData As String Dim x As Integer Dim stationName As String Dim stationId As String rtnData = sbPlugin.ServerQueryCLICommand("pandora items 0 " & num & " item_id:" & pandoraId) rtnData = StripHeader(rtnData, 8) rtnVal = CreateObject("Scripting.Dictionary") For x = 1 To num stationName = ParseStation(rtnData, x - 1, 1) stationId = ParseStation(rtnData, x - 1, 2) rtnVal.Add(stationId, stationName) Next GetStations = rtnVal End Function Private Function StripHeader(ByVal data As String, ByVal skip As Integer) Dim data2 Dim rtnVal As String Dim x As Integer ' ec%3A60%3A8d%3A1c%3A30%3A40 pandora items 0 1 item_id%3A8bd1ce7d.0 title%3AYour%20Stations id%3A8bd1ce7d.0.0 name%3AQuickMix type%3Alink image%3Ahttp%3A%2F%2Fwww.mysqueezebox.com%2Fstatic%2Fimages%2Ficons%2Fpandora.png isaudio%3A1 hasitems%3A1 count%3A90 ' Split on %3A, :, and grab item 9 data2 = Split(data, "%3A") For x = skip To UBound(data2) rtnVal = rtnVal & "%3A" & data2(x) Next StripHeader = rtnVal End Function Private Function ParseStation(ByVal data As String, ByVal multiplier As Integer, ByVal offset As Integer) Dim rtnVal ' ec%3A60%3A8d%3A1c%3A30%3A40 pandora items 0 1 item_id%3A8bd1ce7d.0 title%3AYour%20Stations id%3A8bd1ce7d.0.0 name%3AQuickMix type%3Alink image%3Ahttp%3A%2F%2Fwww.mysqueezebox.com%2Fstatic%2Fimages%2Ficons%2Fpandora.png isaudio%3A1 hasitems%3A1 count%3A90 ' Split on %3A, :, and grab item 9 rtnVal = Split(data, "%3A") rtnVal = rtnVal(offset + (7 * multiplier)) rtnVal = Replace(rtnVal, "%26", "&") rtnVal = Replace(rtnVal, "%20", " ") rtnVal = Replace(rtnVal, " type", "") rtnVal = Replace(rtnVal, " name", "") ParseStation = rtnVal End Function Private Function GetStationId(ByVal sbPlugin As Object, ByVal pandoraId As String, ByVal stationName As String) Dim rtnVal As String Dim stations As Object Dim numStations As Integer numStations = NumChildAll(sbPlugin, pandoraId) stations = GetStations(sbPlugin, pandoraId, numStations) rtnVal = stations.Item(stationName) GetStationId = rtnVal End Function
Comment
Comment