3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.0.9 |
Version 0.0.17 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
|
import cgi as urlparse |
|
10 |
import os |
import os |
11 |
|
|
12 |
|
|
17 |
import urllib |
import urllib |
18 |
import urllib2 |
import urllib2 |
19 |
|
|
20 |
|
# import pprint |
21 |
|
|
22 |
from xml.dom.minidom import parseString |
from xml.dom.minidom import parseString |
23 |
|
from time import time |
24 |
|
|
25 |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
26 |
__key__ = __addon__.getSetting('xbmckey').lower() |
__key__ = __addon__.getSetting('xbmckey').lower() |
27 |
__backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__ |
__backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ |
28 |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'fanart.jpg') |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
29 |
datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/') |
datapath = xbmc.translatePath( |
30 |
|
'special://profile/addon_data/plugin.video.todic/') |
31 |
|
|
32 |
class TodicPlayer(xbmc.Player): |
ADDON_PATH = __addon__.getAddonInfo('path') |
33 |
def __init__(self, *args, **kwargs): |
SkinMasterPath = os.path.join(ADDON_PATH, 'skins') + '/' |
34 |
#xbmc.Player.__init__(selv,*args,**kwargs) |
MySkinPath = (os.path.join(SkinMasterPath, '720p')) + '/' |
35 |
xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER ) |
MySkin = 'main.xml' |
|
self.stopped = False |
|
|
self.started = False |
|
|
print "[TodicPlayer] init" |
|
|
|
|
|
# @catchall |
|
|
def onPlayBackStarted(self): |
|
|
self.started = True |
|
|
print "[TodicPlayer] : started" |
|
|
# super.onPlayBackStarted() |
|
|
|
|
|
def onPlayBackStopped(self): |
|
|
self.stopped = True |
|
|
print "[TodicPlayer] : stopped" |
|
|
|
|
|
def onPlayBackEnded(self): |
|
|
self.stopped = True |
|
|
print "[TodicPlayer] : ended" |
|
|
|
|
|
def callbackLoop(self): |
|
|
print "[Todic] startLoop" |
|
|
while (self.stopped == False): |
|
|
if (self.started == True ): |
|
|
print "[todic] " + str(self.getTime()) |
|
|
xbmc.sleep(5000) |
|
|
|
|
|
|
|
|
def getText2(nodelist): |
|
|
rc = [] |
|
|
for node in nodelist: |
|
|
if node.nodeType == node.TEXT_NODE: |
|
|
rc.append(node.data) |
|
|
else: |
|
|
rc.append( getText(node.childNodes) ) |
|
|
return ''.join(rc) |
|
36 |
|
|
|
def getText(nodelist): |
|
|
if nodelist.length == 0: |
|
|
return '' |
|
|
else: |
|
|
if nodelist[0].childNodes.length == 0: |
|
|
return '' |
|
|
else: |
|
|
return nodelist[0].childNodes[0].nodeValue |
|
37 |
|
|
38 |
def SaveFile(path, data): |
class TodicMovieDialog(xbmcgui.WindowXMLDialog): |
|
file = open(path,'w') |
|
|
file.write(data) |
|
|
file.close() |
|
39 |
|
|
40 |
|
def __new__(cls): |
41 |
|
return super(TodicMovieDialog, cls).__new__(cls, "main.xml", ADDON_PATH) |
42 |
|
|
43 |
def open_url(url): |
def __init__(self): |
44 |
req = urllib2.Request(url) |
super(TodicMovieDialog, self).__init__() |
|
content = urllib2.urlopen(req) |
|
|
data = content.read() |
|
|
content.close() |
|
|
return data |
|
45 |
|
|
46 |
def rootMenu(): |
def onClick(self, controlId): |
47 |
|
print "OnClick: " + str(controlId) |
48 |
|
|
49 |
msg = open_url(__backend__ + "&action=messages") |
if (controlId == 50): |
50 |
msg = msg.strip() |
self.close() |
51 |
|
play_real_video(self.url, self.name) |
52 |
|
|
53 |
if msg != "": |
if (controlId == 98): |
54 |
dialog = xbmcgui.Dialog() |
self.close() |
|
dialog.ok('XBMC Todic', msg) |
|
55 |
|
|
56 |
buildList(__backend__, "", False) # call default list |
def onInit(self): |
57 |
|
|
58 |
# Adde xtra items to root menu |
print "ONINIT" |
59 |
listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') |
self.getControl(1).setLabel(self.name) |
60 |
listitem.setProperty('Fanart_Image', fanartImage) |
self.getControl(2).setLabel(self.moviegroups) |
61 |
|
self.getControl(3).setLabel(self.description) |
62 |
|
self.getControl(10).setLabel(self.playlength) |
63 |
|
self.getControl(11).setLabel(self.codecdetails) |
64 |
|
|
65 |
u = sys.argv[0] + "?mode=10&name=" |
orig_img_width = self.getControl(40).getWidth() |
66 |
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
67 |
|
self.getControl(40).setWidth(int(self.starwidth)) |
68 |
|
|
69 |
#add search series |
def setUrl(self, url): |
70 |
listitem = xbmcgui.ListItem(label = "Søg Serier ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') |
print "SETURL:" + url |
71 |
listitem.setProperty('Fanart_Image', fanartImage) |
self.url = url |
72 |
|
self.fetchClipDetails() |
73 |
|
|
74 |
u = sys.argv[0] + "?mode=11&name=" |
def fetchClipDetails(self): |
75 |
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
param1 = parse_parameter_string(self.url) |
76 |
|
|
77 |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
self.clipkey = param1["clipkey"] |
78 |
|
print "CLIPKEY:" + self.clipkey |
79 |
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + self.clipkey |
80 |
|
|
81 |
|
xml = open_url(detailurl) |
82 |
|
|
83 |
def buildList(url,title, endlist=True): |
doc = parseString(xml) |
84 |
print '[TODIC]:'+str(url) |
self.imdbrating = getText(doc.getElementsByTagName("imdbrating")) |
85 |
|
self.moviegroups = getText(doc.getElementsByTagName("moviegroups")) |
86 |
|
self.playlength = getText(doc.getElementsByTagName("playlength")) |
87 |
|
self.codecdetails = getText(doc.getElementsByTagName("codecdetails")) |
88 |
|
|
89 |
link = open_url(url) |
def setName(self, name): |
90 |
doc = parseString(link) |
self.name = name |
|
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
|
|
print '[TODIC]'+str(ty) |
|
91 |
|
|
92 |
if ty == 'clipList': |
def setDescription(self, description): |
93 |
mode = '50' |
self.description = description |
|
folder = False |
|
|
else: |
|
|
mode = '1' |
|
|
folder = True |
|
94 |
|
|
95 |
|
|
96 |
entries = doc.getElementsByTagName("entry") |
class TodicPlayer(xbmc.Player): |
|
l=len(entries) |
|
|
description = '' |
|
|
for entry in entries: |
|
|
name = getText( entry.getElementsByTagName("title") ) |
|
|
url = getText( entry.getElementsByTagName("url") ) |
|
|
thumb = getText( entry.getElementsByTagName("cover") ) |
|
|
description = getText( entry.getElementsByTagName("description") ) |
|
|
playcount = getText( entry.getElementsByTagName("playcount") ) |
|
|
|
|
|
if playcount == '': |
|
|
playcount = '0' |
|
|
playcount = int(playcount) |
|
97 |
|
|
98 |
|
def __init__(self, *args, **kwargs): |
99 |
|
# xbmc.Player.__init__(selv,*args,**kwargs) |
100 |
|
xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER) |
101 |
|
self.stopped = False |
102 |
|
self.started = False |
103 |
|
self.playingPosition = 0.0 |
104 |
|
self.lastReport = 0 |
105 |
|
print "[TodicPlayer] init" |
106 |
|
|
107 |
|
# @catchall |
108 |
|
def onPlayBackStarted(self): |
109 |
|
self.started = True |
110 |
|
print "[TodicPlayer] : started" |
111 |
|
# super.onPlayBackStarted() |
112 |
|
|
113 |
## print "name:" + name |
#When user presses stop, we report back the the position registered in the last call to self.tick() |
114 |
# print "url:" + url |
def onPlayBackStopped(self): |
115 |
# print "thumb:" + thumb |
self.stopped = True |
116 |
# print "description:" + description |
print "[TodicPlayer] : stopped" |
117 |
|
url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) |
118 |
|
open_url_safe(url) |
119 |
|
|
120 |
|
|
121 |
|
def onPlayBackEnded(self): |
122 |
|
self.stopped = True |
123 |
|
print "[TodicPlayer] : ended" |
124 |
|
url = __backend__ + "&action=playbacktime&subaction=ended&time=" |
125 |
|
open_url_safe(url) |
126 |
|
|
127 |
|
def tick(self): |
128 |
|
if ( self.isPlaying() ): |
129 |
|
self.playingPosition = self.getTime() |
130 |
|
now = time() |
131 |
|
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
132 |
|
if ( (now - self.lastReport) > 60.0): |
133 |
|
self.reportPlaytime() |
134 |
|
self.lastReport = now |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
def reportPlaytime(self): |
139 |
|
url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) |
140 |
|
open_url_safe(url) |
141 |
|
print "[Todic] reportPlaytime:" + url |
142 |
|
|
143 |
|
|
144 |
|
|
145 |
listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb) |
def getText2(nodelist): |
146 |
listitem.setProperty('Fanart_Image', fanartImage) |
rc = [] |
147 |
if mode == '50': |
for node in nodelist: |
148 |
infoLabels = {} |
if node.nodeType == node.TEXT_NODE: |
149 |
infoLabels['title'] = name |
rc.append(node.data) |
150 |
infoLabels['plot'] = description |
else: |
151 |
infoLabels['playcount'] = playcount |
rc.append(getText(node.childNodes)) |
152 |
listitem.setInfo('video', infoLabels) |
return ''.join(rc) |
153 |
|
|
|
name = name.encode('UTF-8') |
|
|
description = description.encode('UTF-8') |
|
154 |
|
|
155 |
|
def getText(nodelist): |
156 |
|
if nodelist.length == 0: |
157 |
|
return '' |
158 |
|
else: |
159 |
|
if nodelist[0].childNodes.length == 0: |
160 |
|
return '' |
161 |
|
else: |
162 |
|
return nodelist[0].childNodes[0].nodeValue |
163 |
|
|
|
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url) |
|
|
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) |
|
164 |
|
|
|
if (endlist == True): |
|
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
|
165 |
|
|
166 |
|
def SaveFile(path, data): |
167 |
|
file = open(path, 'w') |
168 |
|
file.write(data) |
169 |
|
file.close() |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
def play_video(url, name): |
def open_url(url): |
174 |
xml = open_url(url) |
req = urllib2.Request(url) |
175 |
print 'TODIC url: ' + str(url) |
content = urllib2.urlopen(req) |
176 |
print 'TODIC xml: '+ xml |
data = content.read() |
177 |
|
content.close() |
178 |
|
return data |
179 |
|
|
|
doc = parseString(xml) |
|
|
url = getText( doc.getElementsByTagName("url") ) |
|
180 |
|
|
181 |
subtitleurl = getText( doc.getElementsByTagName("subtitles") ) |
# wraps open url in a catch-all exception handler |
182 |
subtitlesfile = os.path.join(datapath,'temp.srt') |
# usefull for periodic back-reporting that should not interrupt the program flow |
183 |
|
def open_url_safe(url): |
184 |
|
try: |
185 |
|
return open_url(url) |
186 |
|
except: |
187 |
|
print "Some error during open_url call to ", url |
188 |
|
|
|
#if old srt file exists delete it first |
|
|
if os.path.isfile(subtitlesfile): |
|
|
os.unlink(subtitlesfile) |
|
189 |
|
|
|
print '[TODIC] subs: '+str(subtitleurl) |
|
|
if len(subtitleurl) > 0: |
|
|
subtitles = open_url(subtitleurl) |
|
|
SaveFile(subtitlesfile, subtitles) |
|
|
print 'TODIC downloaded subtitles' |
|
190 |
|
|
191 |
|
def rootMenu(): |
192 |
|
|
193 |
|
msg = open_url(__backend__ + "&action=messages") |
194 |
|
msg = msg.strip() |
195 |
|
|
196 |
image = xbmc.getInfoImage( 'ListItem.Thumb' ) |
if msg != "": |
197 |
listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image) |
dialog = xbmcgui.Dialog() |
198 |
listitem.setInfo( type = "Video", infoLabels={ "Title": name } ) |
dialog.ok('XBMC Todic', msg) |
199 |
|
|
200 |
|
buildList(__backend__, "", False) # call default list |
201 |
|
|
202 |
|
# Adde xtra items to root menu |
203 |
|
listitem = xbmcgui.ListItem( |
204 |
|
label="Søg film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
205 |
|
listitem.setProperty('Fanart_Image', fanartImage) |
206 |
|
|
207 |
|
u = sys.argv[0] + "?mode=10&name=" |
208 |
|
xbmcplugin.addDirectoryItem( |
209 |
|
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
210 |
|
|
211 |
|
# add search series |
212 |
|
listitem = xbmcgui.ListItem( |
213 |
|
label="Søg Serier ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
214 |
|
listitem.setProperty('Fanart_Image', fanartImage) |
215 |
|
|
216 |
|
u = sys.argv[0] + "?mode=11&name=" |
217 |
|
xbmcplugin.addDirectoryItem( |
218 |
|
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
219 |
|
|
220 |
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
221 |
|
|
222 |
|
|
223 |
|
def buildList(url, title, endlist=True): |
224 |
|
print '[TODIC]:' + str(url) |
225 |
|
|
226 |
|
link = open_url(url) |
227 |
|
doc = parseString(link) |
228 |
|
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
229 |
|
print '[TODIC]' + str(ty) |
230 |
|
|
231 |
|
if ty == 'clipList': |
232 |
|
mode = '50' |
233 |
|
folder = False |
234 |
|
else: |
235 |
|
mode = '1' |
236 |
|
folder = True |
237 |
|
|
238 |
|
entries = doc.getElementsByTagName("entry") |
239 |
|
l = len(entries) |
240 |
|
description = '' |
241 |
|
for entry in entries: |
242 |
|
name = getText(entry.getElementsByTagName("title")) |
243 |
|
url = getText(entry.getElementsByTagName("url")) |
244 |
|
thumb = getText(entry.getElementsByTagName("cover")) |
245 |
|
description = getText(entry.getElementsByTagName("description")) |
246 |
|
playcount = getText(entry.getElementsByTagName("playcount")) |
247 |
|
|
248 |
|
if playcount == '': |
249 |
|
playcount = '0' |
250 |
|
playcount = int(playcount) |
251 |
|
|
252 |
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
# print "name:" + name |
253 |
player.play(str(url), listitem) |
# print "url:" + url |
254 |
|
# print "thumb:" + thumb |
255 |
|
# print "description:" + description |
256 |
|
listitem = xbmcgui.ListItem( |
257 |
|
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
258 |
|
listitem.setProperty('Fanart_Image', fanartImage) |
259 |
|
if mode == '50': |
260 |
|
infoLabels = {} |
261 |
|
infoLabels['title'] = name |
262 |
|
infoLabels['plot'] = description |
263 |
|
infoLabels['playcount'] = playcount |
264 |
|
listitem.setInfo('video', infoLabels) |
265 |
|
|
266 |
|
name = name.encode('UTF-8') |
267 |
|
description = description.encode('UTF-8') |
268 |
|
|
269 |
|
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
270 |
|
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
271 |
|
xbmcplugin.addDirectoryItem( |
272 |
|
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) |
273 |
|
|
274 |
|
if (endlist == True): |
275 |
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
276 |
|
|
277 |
|
|
278 |
|
def play_video(url, name, description): |
279 |
|
if (description == None or description == ""): |
280 |
|
play_real_video(url, name) |
281 |
|
else: |
282 |
|
d = TodicMovieDialog() |
283 |
|
d.setUrl(url) |
284 |
|
d.setName(name) |
285 |
|
d.setDescription(description) |
286 |
|
|
287 |
|
d.doModal() |
288 |
|
|
289 |
|
|
290 |
|
def play_real_video(url, name): |
291 |
|
xml = open_url(url) |
292 |
|
print 'TODIC url: ' + str(url) |
293 |
|
print 'TODIC xml: ' + xml |
294 |
|
|
295 |
|
doc = parseString(xml) |
296 |
|
url = getText(doc.getElementsByTagName("url")) |
297 |
|
|
298 |
|
subtitleurl = getText(doc.getElementsByTagName("subtitles")) |
299 |
|
subtitlesfile = os.path.join(datapath, 'temp.srt') |
300 |
|
|
301 |
|
# if old srt file exists delete it first |
302 |
|
if os.path.isfile(subtitlesfile): |
303 |
|
os.unlink(subtitlesfile) |
304 |
|
|
305 |
|
print '[TODIC] subs: ' + str(subtitleurl) |
306 |
|
if len(subtitleurl) > 0: |
307 |
|
subtitles = open_url(subtitleurl) |
308 |
|
SaveFile(subtitlesfile, subtitles) |
309 |
|
print 'TODIC downloaded subtitles' |
310 |
|
|
311 |
|
image = xbmc.getInfoImage('ListItem.Thumb') |
312 |
|
listitem = xbmcgui.ListItem( |
313 |
|
label=name, iconImage='DefaultVideo.png', thumbnailImage=image) |
314 |
|
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
315 |
|
|
316 |
|
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
317 |
|
player.play(str(url), listitem) |
318 |
|
|
319 |
|
# kan ikke loade subtitles hvis foerend playeren koerer |
320 |
|
count = 0 |
321 |
|
while not xbmc.Player().isPlaying(): |
322 |
|
xbmc.sleep(500) |
323 |
|
count += 1 |
324 |
|
if count > 10: |
325 |
|
break |
326 |
|
|
327 |
|
if xbmc.Player().isPlaying(): |
328 |
|
if os.path.isfile(subtitlesfile): |
329 |
|
player.setSubtitles(subtitlesfile) |
330 |
|
print 'TODIC started subtitles' |
331 |
|
else: |
332 |
|
player.disableSubtitles() |
333 |
|
|
334 |
#kan ikke loade subtitles hvis foerend playeren koerer |
#Holder python kørernde indtil at det bliver bedt om at stoppe |
335 |
count = 0 |
while (not xbmc.abortRequested): |
336 |
while not xbmc.Player().isPlaying(): |
player.tick() |
337 |
xbmc.sleep(500) |
xbmc.sleep(100) |
|
count += 1 |
|
|
if count > 10: |
|
|
break |
|
338 |
|
|
339 |
|
|
|
if xbmc.Player().isPlaying(): |
|
|
if os.path.isfile(subtitlesfile): |
|
|
player.setSubtitles(subtitlesfile) |
|
|
print 'TODIC started subtitles' |
|
|
else: |
|
|
player.disableSubtitles() |
|
340 |
|
|
341 |
# player.callbackLoop() |
# player.callbackLoop() |
342 |
|
|
343 |
|
|
|
|
|
344 |
def search(): |
def search(): |
345 |
search = getUserInput("Todic Søgning") |
search = getUserInput("Todic Søgning") |
346 |
|
|
347 |
if (search != None and search != ""): |
if (search != None and search != ""): |
348 |
url = __backend__ + "&action=search&search=" + urllib.quote_plus(search) |
url = __backend__ + "&action=search&search=" + \ |
349 |
|
urllib.quote_plus(search) |
350 |
|
|
351 |
#print "[TODIC] Search start: " + search |
# print "[TODIC] Search start: " + search |
352 |
#print "[TODIC] Search url: " + url |
# print "[TODIC] Search url: " + url |
353 |
|
|
354 |
buildList(url, "søgning") |
buildList(url, "søgning") |
355 |
|
|
|
def searchSeries(): |
|
|
search = getUserInput("Todic Serie Søgning") |
|
356 |
|
|
357 |
if (search != None and search != ""): |
def searchSeries(): |
358 |
url = __backend__ + "&action=searchseries&search=" + urllib.quote_plus(search) |
search = getUserInput("Todic Serie Søgning") |
359 |
|
|
360 |
#print "[TODIC] Search start: " + search |
if (search != None and search != ""): |
361 |
#print "[TODIC] Search url: " + url |
url = __backend__ + "&action=searchseries&search=" + \ |
362 |
|
urllib.quote_plus(search) |
363 |
|
|
364 |
buildList(url, "serie søgning") |
# print "[TODIC] Search start: " + search |
365 |
|
# print "[TODIC] Search url: " + url |
366 |
|
|
367 |
|
buildList(url, "serie søgning") |
368 |
|
|
369 |
|
|
370 |
|
#=================================== Tool Box ======================================= |
|
#=================================== Tool Box ======================================= |
|
371 |
# shows a more userfriendly notification |
# shows a more userfriendly notification |
372 |
def showMessage(heading, message): |
def showMessage(heading, message): |
373 |
duration = 15*1000 |
duration = 15 * 1000 |
374 |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % ( heading, message, duration) ) |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % |
375 |
|
(heading, message, duration)) |
376 |
|
|
377 |
|
|
378 |
# raise a keyboard for user input |
# raise a keyboard for user input |
379 |
def getUserInput(title = "Input", default="", hidden=False): |
def getUserInput(title="Input", default="", hidden=False): |
380 |
result = None |
result = None |
381 |
|
|
382 |
# Fix for when this functions is called with default=None |
# Fix for when this functions is called with default=None |
383 |
if not default: |
if not default: |
384 |
default = "" |
default = "" |
385 |
|
|
386 |
keyboard = xbmc.Keyboard(default, title) |
keyboard = xbmc.Keyboard(default, title) |
387 |
keyboard.setHiddenInput(hidden) |
keyboard.setHiddenInput(hidden) |
388 |
keyboard.doModal() |
keyboard.doModal() |
389 |
|
|
390 |
if keyboard.isConfirmed(): |
if keyboard.isConfirmed(): |
391 |
result = keyboard.getText() |
result = keyboard.getText() |
392 |
|
|
393 |
return result |
return result |
394 |
|
|
395 |
|
|
396 |
def get_params(): |
def get_params(): |
397 |
param=[] |
return parse_parameter_string(sys.argv[2]) |
398 |
paramstring=sys.argv[2] |
|
399 |
if len(paramstring)>=2: |
|
400 |
params=sys.argv[2] |
def parse_parameter_string(paramstring): |
401 |
cleanedparams=params.replace('?','') |
param = [] |
402 |
if (params[len(params)-1]=='/'): |
if len(paramstring) >= 2: |
403 |
params=params[0:len(params)-2] |
params = paramstring |
404 |
pairsofparams=cleanedparams.split('&') |
cleanedparams = params.replace('?', '') |
405 |
param={} |
if (params[len(params) - 1] == '/'): |
406 |
for i in range(len(pairsofparams)): |
params = params[0:len(params) - 2] |
407 |
splitparams={} |
pairsofparams = cleanedparams.split('&') |
408 |
splitparams=pairsofparams[i].split('=') |
param = {} |
409 |
if (len(splitparams))==2: |
for i in range(len(pairsofparams)): |
410 |
param[splitparams[0]]=splitparams[1] |
splitparams = {} |
411 |
return param |
splitparams = pairsofparams[i].split('=') |
412 |
|
if (len(splitparams)) == 2: |
413 |
|
param[splitparams[0]] = splitparams[1] |
414 |
|
return param |
415 |
|
|
416 |
|
|
417 |
params = get_params() |
params = get_params() |
418 |
url = None |
url = None |
419 |
name = None |
name = None |
420 |
mode = None |
mode = None |
421 |
|
description = None |
422 |
|
|
423 |
try: |
try: |
424 |
url = urllib.unquote_plus(params["url"]) |
url = urllib.unquote_plus(params["url"]) |
425 |
except: |
except: |
426 |
pass |
pass |
427 |
try: |
try: |
428 |
name = urllib.unquote_plus(params["name"]) |
name = urllib.unquote_plus(params["name"]) |
429 |
except: |
except: |
430 |
pass |
pass |
431 |
try: |
try: |
432 |
mode = int(params["mode"]) |
mode = int(params["mode"]) |
433 |
except: |
except: |
434 |
pass |
pass |
435 |
|
try: |
436 |
|
description = urllib.unquote_plus(params["description"]) |
437 |
|
except: |
438 |
|
pass |
439 |
|
|
440 |
|
try: |
441 |
|
open_url("http://todic.dk") |
442 |
|
except: |
443 |
|
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
444 |
|
exit() |
445 |
|
|
446 |
|
|
447 |
if url == 'refresh': |
if url == 'refresh': |
448 |
#xbmc.output("[tvserver] Container.Refresh") #20130418 xbmc.output virker ikke med XBMC12 |
# xbmc.output("[tvserver] Container.Refresh") #20130418 xbmc.output virker |
449 |
xbmc.executebuiltin("Container.Refresh") |
# ikke med XBMC12 |
450 |
|
xbmc.executebuiltin("Container.Refresh") |
451 |
|
|
452 |
|
|
453 |
elif mode == None: |
elif mode == None: |
454 |
#build main menu |
# build main menu |
455 |
rootMenu() |
rootMenu() |
456 |
|
|
457 |
elif mode == 1: |
elif mode == 1: |
458 |
#build list of movie starting letters |
# build list of movie starting letters |
459 |
buildList(url, name) |
buildList(url, name) |
460 |
|
|
461 |
elif mode == 10: |
elif mode == 10: |
462 |
search() |
search() |
463 |
|
|
464 |
elif mode == 11: |
elif mode == 11: |
465 |
searchSeries() |
searchSeries() |
|
|
|
|
|
|
|
elif mode == 50: |
|
|
play_video(url, name) |
|
|
|
|
|
|
|
466 |
|
|
467 |
|
|
468 |
|
elif mode == 50: |
469 |
|
play_video(url, name, description) |