Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
UPDATE: refactor repo into more official XBMC-Addon form
Browse files Browse the repository at this point in the history
* Added GPL-3.0 license references & text (mirrors pithos libary license)
* Moved python library modules to resources/lib
* Updated __[VARS]__ in default.py
  • Loading branch information
rivy committed Jan 13, 2014
1 parent d646cb8 commit a5feea9
Show file tree
Hide file tree
Showing 13 changed files with 726 additions and 34 deletions.
22 changes: 15 additions & 7 deletions COPYING.txt
@@ -1,11 +1,19 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, re/sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so.
### BEGIN LICENSE
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation (<http://fsf.org>).

HE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranties of
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program (in the file LICENSE.txt). If not, see
<http://www.gnu.org/licenses/>.
### END LICENSE

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Expand Down
674 changes: 674 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.txt
Expand Up @@ -2,8 +2,8 @@ Pandora Radio for XBMC

* uses the Pandora JSON API from the Pithos Project

This script is released freely without restrictions, but also without
warrenty, as described in the file "COPYING.txt"
This script is released under the GPL-3.0 license, without
warranty, as further described in the file "COPYING.txt"

Usage:

Expand Down
12 changes: 8 additions & 4 deletions addon.xml
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.pandora"
<addon id="plugin.audio.pandora"
name="Pandora"
version="2.2.0"
version="2.3.0"
provider-name="spbogie, vtwoods, rivy">
<requires>
<!-- Eden: xbmc.python 1.0; Frodo: xbmc.python 2.1.0; Gotham: ? -->
<import addon="xbmc.python" version="1.0"/>
</requires>
<extension point="xbmc.python.script"
library="default.py">
<extension point="xbmc.python.script" library="default.py">
<provides>audio</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Pandora Radio</summary>
<description lang="en">Pandora Internet Radio for XBMC</description>
<license>GPL-3.0</license>
<!-- see LICENSE.txt or <http://opensource.org/licenses/GPL-3.0> -->
<platform>all</platform>
<website></website>
<email></email>
<forum>http://forum.xbmc.org/showthread.php?tid=70471</forum>
<source>https://github.com/rivy/xbmc-pandora</source>
</extension>
Expand Down
48 changes: 27 additions & 21 deletions default.py
Expand Up @@ -3,18 +3,24 @@
import xbmcaddon
import os, sys

__settings__ = xbmcaddon.Addon()
__script_id__ = __settings__.getAddonInfo('id')
__title__ = __settings__.getAddonInfo('name')
__version__ = __settings__.getAddonInfo('version')
__settings__ = xbmcaddon.Addon()
__script_id__ = __settings__.getAddonInfo('id')
__name__ = __settings__.getAddonInfo('name')
__version__ = __settings__.getAddonInfo('version')
__language__ = __settings__.getLocalizedString
__cwd__ = __settings__.getAddonInfo('path')
__profile__ = xbmc.translatePath( __settings__.getAddonInfo('profile') )
__lib__ = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib' ) )

TITLE = __title__.upper()
sys.path.append (__lib__)

print TITLE+": Initializing v%s" % __version__
print TITLE+": sys.platform = %s" % sys.platform
__NAME__ = __name__.upper()

print __NAME__+": Initializing v%s" % __version__
print __NAME__+": sys.platform = %s" % sys.platform

dlg = xbmcgui.DialogProgress()
dlg.create( TITLE, "Loading Script..." )
dlg.create( __NAME__, "Loading Script..." )
dlg.update( 0 )

from pithos.pandora.pandora import Pandora, PandoraError
Expand All @@ -31,7 +37,7 @@
dataDir = xbmc.translatePath( dataDir )

if __settings__.getSetting( "firstrun" ) == "true":
print TITLE+": First run, showing settings dialog"
print __NAME__+": First run, showing settings dialog"
__settings__.openSettings()
__settings__.setSetting( "firstrun", "false" )

Expand Down Expand Up @@ -85,13 +91,13 @@ def __init__( self ):
self.pandora = My_Pandora()
self.pandora.set_audio_quality(fmt)
except PandoraError, e:
xbmcgui.Dialog().ok( __title__, "Error: %s" %e )
xbmcgui.Dialog().ok( __name__, "Error: %s" %e )
self.die = True
return

#Proxy settings
if self.settings.getSetting( "proxy_enable" ) == "true":
print TITLE+": Proxy Enabled"
print __NAME__+": Proxy Enabled"
proxy_info = {
"host" : self.settings.getSetting( "proxy_server" ),
"port" : self.settings.getSetting( "proxy_port" ),
Expand All @@ -101,7 +107,7 @@ def __init__( self ):
self.pandora.set_proxy( "http://%(user)s:%(pass)s@%(host)s:%(port)s" % proxy_info )

while not self.auth():
resp = xbmcgui.Dialog().yesno( __title__, \
resp = xbmcgui.Dialog().yesno( __name__, \
"Failed to authenticate listener.", \
"Check username/password and try again.", \
"Show Settings?" )
Expand Down Expand Up @@ -132,7 +138,7 @@ def auth( self ):
if pandoraone == "true":
client_id = pithos.pandora.data.default_one_client_id
dlg = xbmcgui.DialogProgress()
dlg.create( TITLE, "Logging In..." )
dlg.create( __NAME__, "Logging In..." )
dlg.update( 0 )
try:
self.pandora.connect(pithos.pandora.data.client_keys[client_id], user, pwd)
Expand All @@ -145,7 +151,7 @@ def playStation( self, stationId ):
self.curStation = stationId
station = self.pandora.get_station_by_id(self.curStation);
dlg = xbmcgui.DialogProgress()
dlg.create( TITLE, "Opening Pandora station: " + station.name )
dlg.create( __NAME__, "Opening Pandora station: " + station.name )
dlg.update( 0 )
self.settings.setSetting( 'last_station_id', stationId )
self.curSong = None
Expand All @@ -160,34 +166,34 @@ def getStations( self ):
return self.pandora.stations

def getMoreSongs( self ):
print TITLE+": getting more songs"
print __NAME__+": getting more songs"
if self.curStation == "":
raise PandaException()
items = []
station = self.pandora.get_station_by_id(self.curStation);
songs = station.get_playlist()
for song in songs:
print TITLE+": Adding song %s" % song.title
print __NAME__+": Adding song %s" % song.__NAME__
thumbnailArtwork = self.settings.getSetting( "thumbnailArtwork" )
thumbnail = song.artRadio

item = xbmcgui.ListItem( song.title )
item = xbmcgui.ListItem( song.__NAME__ )
item.setIconImage( thumbnail )
item.setThumbnailImage( thumbnail )
item.setProperty( "Cover", thumbnail )
if song.rating_str != None:
item.setProperty( "Rating", song.rating_str )
else:
item.setProperty( "Rating", "" )
info = { "title" : song.title, \
info = { "__NAME__" : song.__NAME__, \
"artist" : song.artist, \
"album" : song.album, \
}
## HACK: set fictional duration to enable scrobbling
if self.settings.getSetting( "scrobble_hack" ) == "true":
duration = 60 * ( int(self.settings.getSetting( "scrobble_hack_time" )) + 1 )
info["duration"] = duration
print TITLE+": item info = %s" % info
print __NAME__+": item info = %s" % info
item.setInfo( "music", info )
items.append( ( song.audioUrl, item, song ) )

Expand Down Expand Up @@ -220,7 +226,7 @@ def playNextSong( self ):
self.gui.getControl(BTN_THUMB_UP).setVisible(False)
self.gui.getControl(BTN_THUMBED_UP).setVisible(True)
else:
print TITLE+": !!!! Unrecognised rating"
print __NAME__+": !!!! Unrecognised rating"
except IndexError:
self.curSong = None
self.getMoreSongs()
Expand Down Expand Up @@ -275,7 +281,7 @@ def quit( self ):
if __name__ == '__main__':
if __settings__.getSetting( "username" ) == "" or \
__settings__.getSetting( "password" ) == "":
xbmcgui.Dialog().ok( __title__, \
xbmcgui.Dialog().ok( __name__, \
"Username and/or password not specified" )
__settings__.setSetting( "firstrun", "true" )
else:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a5feea9

Please sign in to comment.