3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.0.21 |
Version 1.9.0 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
13 |
import xbmc |
import xbmc |
14 |
import xbmcaddon |
import xbmcaddon |
15 |
import xbmcgui |
import xbmcgui |
16 |
|
import xbmcvfs |
17 |
import xbmcplugin |
import xbmcplugin |
18 |
import urllib |
import urllib |
19 |
import urllib2 |
import urllib.request |
20 |
|
|
21 |
# import pprint |
# import pprint |
22 |
|
|
25 |
|
|
26 |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
27 |
__key__ = __addon__.getSetting('xbmckey').lower() |
__key__ = __addon__.getSetting('xbmckey').lower() |
28 |
|
__entrypoint__ = __addon__.getSetting('entrypoint').lower() |
29 |
__backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ |
__backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ |
30 |
|
|
31 |
|
|
32 |
|
if __entrypoint__ == "alternative": |
33 |
|
__backend__ = "https://alt.todic.dk/xbmc.php?xbmckey=" + __key__ |
34 |
|
|
35 |
|
if __entrypoint__ == "testing": |
36 |
|
__backend__ = "https://todic.dk/xbmc-beta.php?xbmckey=" + __key__ |
37 |
|
|
38 |
|
print( "[Todic] entrypoint: " + __entrypoint__ ) |
39 |
|
print( "[Todic] backend: " + __backend__ ) |
40 |
|
print( "[Todic] version: " + __addon__.getAddonInfo('version') ) |
41 |
|
|
42 |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
43 |
datapath = xbmc.translatePath( |
datapath = xbmcvfs.translatePath( |
44 |
'special://profile/addon_data/plugin.video.todic/') |
'special://profile/addon_data/plugin.video.todic/') |
45 |
|
|
46 |
ADDON_PATH = __addon__.getAddonInfo('path') |
ADDON_PATH = __addon__.getAddonInfo('path') |
59 |
self.position = 0 |
self.position = 0 |
60 |
|
|
61 |
def onClick(self, controlId): |
def onClick(self, controlId): |
62 |
print "[Todic] MovieDialog OnClick: " + str(controlId) |
print( "[Todic] MovieDialog OnClick: " + str(controlId) ) |
63 |
|
|
64 |
if (controlId == 50): |
if (controlId == 50): |
65 |
self.close() |
self.close() |
74 |
|
|
75 |
def onInit(self): |
def onInit(self): |
76 |
|
|
77 |
print "[Todic] MovieDialog ONINIT" |
print( "[Todic] MovieDialog onInit" ) |
78 |
self.getControl(1).setLabel(self.name) |
self.getControl(1).setLabel(self.name) |
79 |
self.getControl(2).setLabel(self.moviegroups) |
self.getControl(2).setLabel(self.moviegroups) |
80 |
self.getControl(3).setLabel(self.description) |
self.getControl(3).setLabel(self.description) |
94 |
#self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
#self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
95 |
#self.getControl(40).setWidth(int(self.starwidth)) |
#self.getControl(40).setWidth(int(self.starwidth)) |
96 |
|
|
97 |
|
def setDetailsDoc(self, detailsDoc): |
98 |
|
print( "[Todic] MovieDialog setDetailsDoc:") |
99 |
|
self.imdbrating = getText(detailsDoc.getElementsByTagName("imdbrating")) |
100 |
|
self.moviegroups = getText(detailsDoc.getElementsByTagName("moviegroups")) |
101 |
|
self.playlength = getText(detailsDoc.getElementsByTagName("playlength")) |
102 |
|
self.codecdetails = getText(detailsDoc.getElementsByTagName("codecdetails")) |
103 |
|
self.position = int( getText(detailsDoc.getElementsByTagName("position")) ) |
104 |
|
|
105 |
def setUrl(self, url): |
def setUrl(self, url): |
|
print "[Todic] MovieDialog SETURL:" + url |
|
106 |
self.url = url |
self.url = url |
|
self.fetchClipDetails() |
|
|
|
|
|
|
|
|
|
|
|
def fetchClipDetails(self): |
|
|
param1 = parse_parameter_string(self.url) |
|
|
|
|
|
self.clipkey = param1["clipkey"] |
|
|
print "CLIPKEY:" + self.clipkey |
|
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + self.clipkey |
|
|
print "[Todic] detailURL = " + detailurl |
|
|
|
|
|
xml = open_url(detailurl) |
|
|
|
|
|
doc = parseString(xml) |
|
|
self.imdbrating = getText(doc.getElementsByTagName("imdbrating")) |
|
|
self.moviegroups = getText(doc.getElementsByTagName("moviegroups")) |
|
|
self.playlength = getText(doc.getElementsByTagName("playlength")) |
|
|
self.codecdetails = getText(doc.getElementsByTagName("codecdetails")) |
|
|
self.position = int( getText(doc.getElementsByTagName("position")) ) |
|
107 |
|
|
108 |
def setName(self, name): |
def setName(self, name): |
109 |
self.name = name |
self.name = name |
116 |
|
|
117 |
def __init__(self, *args, **kwargs): |
def __init__(self, *args, **kwargs): |
118 |
# xbmc.Player.__init__(selv,*args,**kwargs) |
# xbmc.Player.__init__(selv,*args,**kwargs) |
119 |
xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER) |
xbmc.Player.__init__(self) |
120 |
self.stopped = False |
self.stopped = False |
121 |
self.started = False |
self.started = False |
122 |
self.playingPosition = 0.0 |
self.playingPosition = 0.0 |
123 |
self.lastReport = 0 |
self.lastReport = 0 |
124 |
print "[TodicPlayer] init" |
print( "[TodicPlayer] init") |
125 |
|
|
|
# @catchall |
|
126 |
def onPlayBackStarted(self): |
def onPlayBackStarted(self): |
127 |
self.started = True |
self.started = True |
128 |
print "[TodicPlayer] : started" |
print( "[TodicPlayer] : started") |
|
# super.onPlayBackStarted() |
|
129 |
|
|
130 |
#When user presses stop, we report back the the position registered in the last call to self.tick() |
#When user presses stop, we report back the the position registered in the last call to self.tick() |
131 |
def onPlayBackStopped(self): |
def onPlayBackStopped(self): |
132 |
self.stopped = True |
self.stopped = True |
133 |
print "[TodicPlayer] : stopped" |
print( "[TodicPlayer] : stopped") |
134 |
self.reportPlaytime("stopped") |
self.reportPlaytime("stopped") |
135 |
# url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) |
|
136 |
# open_url_safe(url) |
def onPlayBackPaused(self): |
137 |
|
print( "[TodicPlayer] : paused") |
138 |
|
self.reportPlaytime("paused") |
139 |
|
|
140 |
|
def onPlayBackResumed(self): |
141 |
|
print( "[TodicPlayer] : resumed") |
142 |
|
self.reportPlaytime("resumed") |
143 |
|
|
144 |
|
|
145 |
def onPlayBackEnded(self): |
def onPlayBackEnded(self): |
146 |
self.stopped = True |
self.stopped = True |
147 |
print "[TodicPlayer] : ended" |
print( "[TodicPlayer] : ended") |
148 |
self.reportPlaytime("ended") |
self.reportPlaytime("ended") |
|
# url = __backend__ + "&action=playbacktime&subaction=ended&time=" |
|
|
# open_url_safe(url) |
|
149 |
|
|
150 |
def tick(self): |
def tick(self): |
151 |
|
#print( "[Todic] Tick: " + str( self.isPlaying() ) ) |
152 |
if ( self.isPlaying() ): |
if ( self.isPlaying() ): |
153 |
self.playingPosition = self.getTime() |
tmpTime = self.getTime() |
|
now = time() |
|
|
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
|
|
if ( (now - self.lastReport) > 60.0): |
|
|
self.lastReport = now |
|
|
self.reportPlaytime("playing") |
|
|
|
|
|
|
|
154 |
|
|
155 |
|
#only report time if it has changed in the mean time |
156 |
|
if tmpTime != self.playingPosition: |
157 |
|
self.playingPosition = tmpTime |
158 |
|
now = time() |
159 |
|
#print( "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) ) |
160 |
|
if ( (now - self.lastReport) > 60.0): |
161 |
|
self.lastReport = now |
162 |
|
self.reportPlaytime("playing") |
163 |
|
|
164 |
def reportPlaytime(self, subaction): |
def reportPlaytime(self, subaction): |
165 |
url = __backend__ + "&action=playbacktime&subaction=" + subaction + "&time=" + str( self.playingPosition ) |
if (self.playingPosition > 60): |
166 |
open_url_safe(url) |
url = __backend__ + "&action=playbacktime&subaction=" + subaction + "&time=" + str( self.playingPosition ) |
167 |
print "[Todic] reportPlaytime:" + url |
print( "[Todic] reportPlaytime:" + url) |
168 |
|
open_url_safe(url) |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
def getText2(nodelist): |
def getText2(nodelist): |
198 |
|
|
199 |
|
|
200 |
def open_url(url): |
def open_url(url): |
201 |
req = urllib2.Request(url) |
with urllib.request.urlopen(url) as response: |
202 |
content = urllib2.urlopen(req) |
data = response.read() |
203 |
data = content.read() |
return data |
|
content.close() |
|
|
return data |
|
204 |
|
|
205 |
|
|
206 |
# wraps open url in a catch-all exception handler |
# wraps open url in a catch-all exception handler |
209 |
try: |
try: |
210 |
return open_url(url) |
return open_url(url) |
211 |
except: |
except: |
212 |
print "[Todic ]Some error during open_url call to ", url |
print( "[Todic] Some error during open_url call to ", url) |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
def rootMenu(): |
def rootMenu(): |
217 |
|
kodi_ver = xbmc.getInfoLabel('System.BuildVersion') |
218 |
|
plugin_ver = __addon__.getAddonInfo('version') |
219 |
|
msgurl = __backend__ + "&action=messages&kodi=" + urllib.parse.quote(kodi_ver) + "&todicplugin=" + urllib.parse.quote(plugin_ver) |
220 |
|
|
221 |
msg = open_url(__backend__ + "&action=messages") |
msg = open_url(msgurl) |
222 |
msg = msg.strip() |
msg = msg.strip() |
223 |
|
|
224 |
if msg != "": |
if msg != "": |
228 |
buildList(__backend__, "", False) # call default list |
buildList(__backend__, "", False) # call default list |
229 |
|
|
230 |
# Adde xtra items to root menu |
# Adde xtra items to root menu |
231 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label="Søg Film ...") |
232 |
label="Søg film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
listitem.setArt( { 'icon':'DefaultFolder.png', 'thumb':'DefaultFolder.png'} ) |
233 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
234 |
|
|
235 |
u = sys.argv[0] + "?mode=10&name=" |
u = sys.argv[0] + "?mode=10&name=" |
237 |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
238 |
|
|
239 |
# add search series |
# add search series |
240 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label="Søg Serier ...") |
241 |
label="Søg Serier ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
listitem.setArt( { 'icon':'DefaultFolder.png', 'thumb':'DefaultFolder.png'} ) |
242 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
243 |
|
|
244 |
u = sys.argv[0] + "?mode=11&name=" |
u = sys.argv[0] + "?mode=11&name=" |
249 |
|
|
250 |
|
|
251 |
def buildList(url, title, endlist=True): |
def buildList(url, title, endlist=True): |
252 |
print '[TODIC]:' + str(url) |
print( '[Todic::buildList]:' + str(url) ) |
253 |
|
|
254 |
link = open_url(url) |
link = open_url(url) |
255 |
doc = parseString(link) |
doc = parseString(link) |
256 |
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
257 |
print '[TODIC]' + str(ty) |
print( '[Todic]' + str(ty)) |
258 |
|
|
259 |
if ty == 'clipList': |
if ty == 'clipList': |
260 |
mode = '50' |
mode = '50' |
265 |
|
|
266 |
entries = doc.getElementsByTagName("entry") |
entries = doc.getElementsByTagName("entry") |
267 |
l = len(entries) |
l = len(entries) |
268 |
description = '' |
|
269 |
for entry in entries: |
for entry in entries: |
270 |
name = getText(entry.getElementsByTagName("title")) |
name = getText(entry.getElementsByTagName("title")) |
271 |
url = getText(entry.getElementsByTagName("url")) |
url = getText(entry.getElementsByTagName("url")) |
272 |
thumb = getText(entry.getElementsByTagName("cover")) |
thumb = getText(entry.getElementsByTagName("cover")) |
|
description = getText(entry.getElementsByTagName("description")) |
|
273 |
playcount = getText(entry.getElementsByTagName("playcount")) |
playcount = getText(entry.getElementsByTagName("playcount")) |
274 |
|
|
275 |
|
|
279 |
|
|
280 |
# print "name:" + name |
# print "name:" + name |
281 |
# print "url:" + url |
# print "url:" + url |
282 |
# print "thumb:" + thumb |
# print "thumb:" + thumbi |
283 |
# print "description:" + description |
listitem = xbmcgui.ListItem(label=name, label2='test') |
284 |
listitem = xbmcgui.ListItem( |
listitem.setArt( {'icon': 'DefaultFolder.png'} ) |
|
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
|
285 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
286 |
|
listitem.addContextMenuItems([('Refresh', 'Container.Refresh')]) |
287 |
|
listitem.setArt( {'thumb': thumb} ) |
288 |
|
|
289 |
if mode == '50': |
if mode == '50': |
290 |
infoLabels = {} |
infoLabels = {} |
291 |
infoLabels['title'] = name |
infoLabels['title'] = name |
|
infoLabels['plot'] = description |
|
292 |
infoLabels['playcount'] = playcount |
infoLabels['playcount'] = playcount |
293 |
|
# if playcount > 0: |
294 |
|
# listitem.setArt( {'thumb': thumb} ) #not pretty - but at least we can show a different icon for unwatched/watched in kodi18 |
295 |
listitem.setInfo('video', infoLabels) |
listitem.setInfo('video', infoLabels) |
296 |
|
|
297 |
name = name.encode('UTF-8') |
name = name.encode('UTF-8') |
|
description = description.encode('UTF-8') |
|
298 |
|
|
299 |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
u = sys.argv[0] + "?mode=" + urllib.parse.quote(mode) + "&name=" + urllib.parse.quote(name) + "&url=" + urllib.parse.quote(url) |
|
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
|
300 |
xbmcplugin.addDirectoryItem( |
xbmcplugin.addDirectoryItem( |
301 |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) |
302 |
|
|
304 |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
305 |
|
|
306 |
|
|
307 |
def play_video(url, name, description): |
def play_video(url, name): |
308 |
|
description = "" |
309 |
|
playPosition = 0 |
310 |
|
savedPosition = 0 |
311 |
|
try: |
312 |
|
param1 = parse_parameter_string(url) |
313 |
|
clipkey = param1["clipkey"] |
314 |
|
|
315 |
|
print( "[Todic] ClipKey:" + clipkey) |
316 |
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + clipkey |
317 |
|
print( "[Todic] detailURL = " + detailurl) |
318 |
|
|
319 |
|
xml = open_url(detailurl) |
320 |
|
|
321 |
|
clipDetailsDoc = parseString(xml) |
322 |
|
savedPosition = int( getText(clipDetailsDoc.getElementsByTagName("position")) ) |
323 |
|
description = getText(clipDetailsDoc.getElementsByTagName("description")) |
324 |
|
except: |
325 |
|
print( "[Todic] Unexpected error:", sys.exc_info()[0] ) |
326 |
|
|
327 |
if (description == None or description == ""): |
if (description == None or description == ""): |
328 |
play_real_video(url, name, 0) |
if (savedPosition > 0): |
329 |
|
dialog = xbmcgui.Dialog() |
330 |
|
#yes / true -afspil fra position |
331 |
|
answer = dialog.yesno(heading='Todic', line1='Afspil fra sidste position', nolabel='Fra start', yeslabel='Fortsæt') |
332 |
|
if (answer == True): |
333 |
|
playPosition = savedPosition |
334 |
|
|
335 |
|
play_real_video(url, name, playPosition) |
336 |
|
|
337 |
else: |
else: |
338 |
d = TodicMovieDialog() |
d = TodicMovieDialog() |
339 |
d.setUrl(url) |
d.setDetailsDoc(clipDetailsDoc) |
340 |
d.setName(name) |
d.setName(name) |
341 |
|
d.setUrl(url) |
342 |
d.setDescription(description) |
d.setDescription(description) |
343 |
|
|
344 |
d.doModal() |
d.doModal() |
346 |
|
|
347 |
def play_real_video(url, name, position): |
def play_real_video(url, name, position): |
348 |
xml = open_url(url) |
xml = open_url(url) |
349 |
print '[Todic] url: ' + str(url) |
print( '[Todic] url: ' + str(url) ) |
350 |
print '[Todic] xml: ' + xml |
print( '[Todic] xml: ' + str(xml) ) |
351 |
print '[Todic] pos: ' + str(position) |
print( '[Todic] pos: ' + str(position) ) |
352 |
|
|
353 |
doc = parseString(xml) |
doc = parseString(xml) |
354 |
url = getText(doc.getElementsByTagName("url")) |
url = getText(doc.getElementsByTagName("url")) |
355 |
|
|
356 |
subtitleurl = getText(doc.getElementsByTagName("subtitles")) |
subtitleurl = getText(doc.getElementsByTagName("subtitles")) |
|
subtitlesfile = os.path.join(datapath, 'temp.srt') |
|
357 |
|
|
|
# if old srt file exists delete it first |
|
|
if os.path.isfile(subtitlesfile): |
|
|
os.unlink(subtitlesfile) |
|
358 |
|
|
359 |
print '[TODIC] subs: ' + str(subtitleurl) |
print( '[Todic] subs: ' + str(subtitleurl) ) |
|
if len(subtitleurl) > 0: |
|
|
subtitles = open_url(subtitleurl) |
|
|
SaveFile(subtitlesfile, subtitles) |
|
|
print 'TODIC downloaded subtitles' |
|
360 |
|
|
361 |
image = xbmc.getInfoImage('ListItem.Thumb') |
image = xbmc.getInfoImage('ListItem.Thumb') |
362 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label=name) |
363 |
label=name, iconImage='DefaultVideo.png', thumbnailImage=image) |
listitem.setArt( {'icon': 'DefaultVideo.png', 'thumb':image} ) |
364 |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
|
listitem.setProperty('ResumeTime', '300') |
|
|
listitem.setProperty('TotalTime', '3000') |
|
|
|
|
|
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
|
|
player.play(str(url), listitem) |
|
|
|
|
|
# kan ikke loade subtitles hvis foerend playeren koerer |
|
|
count = 0 |
|
|
while not xbmc.Player().isPlaying(): |
|
|
xbmc.sleep(250) |
|
|
count += 1 |
|
|
if count > 10: |
|
|
break |
|
365 |
|
|
366 |
|
listitem.setProperty('StartOffset', str(position) ) |
367 |
|
|
368 |
|
if len(subtitleurl) > 0: |
369 |
|
listitem.setSubtitles([subtitleurl]) |
370 |
|
|
371 |
if xbmc.Player().isPlaying(): |
player = TodicPlayer() |
372 |
if os.path.isfile(subtitlesfile): |
player.play(str(url), listitem) |
|
player.setSubtitles(subtitlesfile) |
|
|
print 'TODIC started subtitles' |
|
|
else: |
|
|
player.disableSubtitles() |
|
|
|
|
|
|
|
|
if (position > 0): |
|
|
while (player.getTotalTime() == 0.0): #Vent indtil vi har beregnet hvor langt klippet er |
|
|
xbmc.sleep(250) |
|
|
|
|
|
print "[Todic] totalTime " + str( player.getTotalTime() ) |
|
|
player.seekTime(position) |
|
373 |
|
|
374 |
|
|
375 |
#Holder python kørernde indtil at det bliver bedt om at stoppe |
#Holder python kørernde indtil at det bliver bedt om at stoppe |
376 |
while (not xbmc.abortRequested): |
kodiMonitor = xbmc.Monitor() |
377 |
|
|
378 |
|
|
379 |
|
while (not kodiMonitor.abortRequested()): |
380 |
player.tick() |
player.tick() |
381 |
xbmc.sleep(500) |
kodiMonitor.waitForAbort( 1 ) |
382 |
|
|
383 |
|
|
384 |
|
|
387 |
|
|
388 |
if (search != None and search != ""): |
if (search != None and search != ""): |
389 |
url = __backend__ + "&action=search&search=" + \ |
url = __backend__ + "&action=search&search=" + \ |
390 |
urllib.quote_plus(search) |
urllib.parse.quote(search) |
391 |
|
|
392 |
# print "[TODIC] Search start: " + search |
# print "[Todic] Search start: " + search |
393 |
# print "[TODIC] Search url: " + url |
# print "[Todic] Search url: " + url |
394 |
|
|
395 |
buildList(url, "søgning") |
buildList(url, "søgning") |
396 |
|
|
400 |
|
|
401 |
if (search != None and search != ""): |
if (search != None and search != ""): |
402 |
url = __backend__ + "&action=searchseries&search=" + \ |
url = __backend__ + "&action=searchseries&search=" + \ |
403 |
urllib.quote_plus(search) |
urllib.parse.quote(search) |
404 |
|
|
405 |
# print "[TODIC] Search start: " + search |
# print "[Todic] Search start: " + search |
406 |
# print "[TODIC] Search url: " + url |
# print "[Todic] Search url: " + url |
407 |
|
|
408 |
buildList(url, "serie søgning") |
buildList(url, "serie søgning") |
409 |
|
|
411 |
#=================================== Tool Box ======================================= |
#=================================== Tool Box ======================================= |
412 |
# shows a more userfriendly notification |
# shows a more userfriendly notification |
413 |
def showMessage(heading, message): |
def showMessage(heading, message): |
414 |
|
print( "[Todic::showMessage] " + message) |
415 |
|
print( message ) |
416 |
duration = 15 * 1000 |
duration = 15 * 1000 |
417 |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % |
418 |
(heading, message, duration)) |
(heading, message, duration)) |
461 |
url = None |
url = None |
462 |
name = None |
name = None |
463 |
mode = None |
mode = None |
|
description = None |
|
464 |
|
|
465 |
|
|
466 |
#print params |
#print params |
467 |
|
|
468 |
try: |
try: |
469 |
url = urllib.unquote_plus(params["url"]) |
url = urllib.parse.unquote(params["url"]) |
470 |
except: |
except: |
471 |
pass |
pass |
472 |
try: |
try: |
473 |
name = urllib.unquote_plus(params["name"]) |
name = urllib.parse.unquote(params["name"]) |
474 |
except: |
except: |
475 |
pass |
pass |
476 |
try: |
try: |
477 |
mode = int(params["mode"]) |
mode = int(params["mode"]) |
478 |
except: |
except: |
479 |
pass |
pass |
|
try: |
|
|
description = urllib.unquote_plus(params["description"]) |
|
|
except: |
|
|
pass |
|
|
|
|
480 |
|
|
481 |
|
|
482 |
|
|
483 |
try: |
try: |
484 |
open_url("http://todic.dk") |
open_url("https://todic.dk") |
485 |
except: |
except: |
486 |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
487 |
exit() |
exit() |
509 |
|
|
510 |
|
|
511 |
elif mode == 50: |
elif mode == 50: |
512 |
play_video(url, name, description) |
play_video(url, name) |