[855c28]: / plugin.audio.npr / default.py  Maximize  Restore  History

Download this file

92 lines (74 with data), 3.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#/*
# * Copyright (C) Fisslefink
# *
# *
# * This Program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2, or (at your option)
# * any later version.
# *
# * This Program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY 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; see the file COPYING. If not, write to
# * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# * http://www.gnu.org/copyleft/gpl.html
# *
# */
import string,xbmc,xbmcaddon,xbmcplugin,xbmcgui
__XBMC_Revision__ = xbmc.getInfoLabel('System.BuildVersion')
__settings__ = xbmcaddon.Addon(id='plugin.audio.npr')
__language__ = __settings__.getLocalizedString
__version__ = __settings__.getAddonInfo('version')
__cwd__ = __settings__.getAddonInfo('path')
__addonname__ = "NPR"
__addonid__ = "plugin.audio.npr"
__author__ = "Fisslefink"
def PLAY(url):
xbmc.Player().play(url)
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
params=get_params()
stream=None
try:
stream=int(params["stream"])
except:
pass
try:
firstrun=(int(sys.argv[1]) == 0)
except:
pass
print "Selected stream: "+str(stream)
if stream==None:
u=sys.argv[0]+"?stream=1"
liz=xbmcgui.ListItem(__language__(30090), iconImage="DefaultPlaylist.png", thumbnailImage="")
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
u=sys.argv[0]+"?stream=2"
liz=xbmcgui.ListItem(__language__(30091), iconImage="DefaultPlaylist.png", thumbnailImage="")
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
elif stream==1:
print "Playing stream 1"
url='http://npr.ic.llnwd.net/stream/npr_live24'
PLAY(url)
elif stream==2:
print "Playing stream 2"
url='http://sc9.sjc.llnw.net:80/stream/npr_music2'
PLAY(url)