www.homeseer.com  
 

Go Back   HomeSeer Message Board > Audio & Video Support > Music Player and Service Plug-ins > SqueezeBox Plug-In (3P)

SqueezeBox Plug-In (3P) Discussion area for the SqueezeBox plug-in by PCP.

Reply
 
Thread Tools Display Modes
  #1  
Old November 20th, 2010, 10:05 AM
mwtroxell mwtroxell is offline
Seer
 
Join Date: Mar 2002
Location: Jasper, TN, USA
Posts: 37
Default Pandora station reference number/URL

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.
Reply With Quote
  #2  
Old December 1st, 2010, 11:18 PM
mwtroxell mwtroxell is offline
Seer
 
Join Date: Mar 2002
Location: Jasper, TN, USA
Posts: 37
Default Anyone have any idea about this?

Anyone have any idea about this?
Reply With Quote
  #3  
Old December 1st, 2010, 11:57 PM
heatvent's Avatar
heatvent heatvent is offline
Seer Master
 
Join Date: Nov 2007
Location: Chicago
Posts: 1,119
Default

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.
__________________
PC Hardware: Combined HS and SageTV Server on a ESXi 5.1 desktop, AMD FX-6300 3.5ghz Six-Core, 12GB RAM
PC OS: ESXi 5.1 VM Server, WHS 2011 64-bit for server/SageTV, WinXP for HS2
HS Version: HS2 Pro 2.latest
HA Hardware: Insteon Hub, Aeon Labs Z-Stick II, W800RF, RF8315, HAI RC-122 Thermostat, Insteon, X10, Z-Wave, Way2Call, SqueezeBox Boom (2) and Radio, Schlage Locks (2)
Reply With Quote
  #4  
Old December 2nd, 2010, 09:41 AM
mwtroxell mwtroxell is offline
Seer
 
Join Date: Mar 2002
Location: Jasper, TN, USA
Posts: 37
Default

Thanks, thats what I needed to know.

Mike
Reply With Quote
  #5  
Old February 5th, 2011, 05:30 PM
BootsC5 BootsC5 is offline
Seer Deluxe
 
Join Date: Jan 2008
Location: SoFla
Posts: 325
Default

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%3A6799a2a7.0 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%3A6799a2a7.0.0 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



Reply With Quote
  #6  
Old February 6th, 2011, 10:59 AM
BootsC5 BootsC5 is offline
Seer Deluxe
 
Join Date: Jan 2008
Location: SoFla
Posts: 325
Default

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
Reply With Quote
  #7  
Old February 8th, 2011, 08:51 AM
pcp pcp is offline
Seer Master
 
Join Date: Jan 2006
Location: MA
Posts: 1,063
Default

Cool! Thanks for posting the script. Have you tried integrating the results with HSTouch?
Reply With Quote
  #8  
Old February 8th, 2011, 11:13 AM
BootsC5 BootsC5 is offline
Seer Deluxe
 
Join Date: Jan 2008
Location: SoFla
Posts: 325
Default

No. I found it easier/better to use the squeezebox web interface to control all household players vs the using the HST interface of the SB plug-on.

I'm using a modified (I have to modify everything...) version of the Tablet skin for my touch screens. On my phone I use iPeng.
Reply With Quote
  #9  
Old December 18th, 2011, 01:29 PM
stinggray stinggray is offline
Seer
 
Join Date: Sep 2006
Location: Jupiter, FL
Posts: 51
Default

How could this script be implemented on HSTouch music browser?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:30 AM.

Untitled Document
NEW!
New How-To's
New Products

HomeSeer Z-Troller"
MyHomeSeer-Connect Service

Copyright HomeSeer Technologies, LLC