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