3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.1.3 |
Version 1.7.1 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
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 |
|
__entrypoint__ = __addon__.getSetting('entrypoint').lower() |
28 |
__backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ |
__backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ |
29 |
|
|
30 |
|
if __entrypoint__ == "alternative": |
31 |
|
__backend__ = "https://alt.todic.dk/xbmc.php?xbmckey=" + __key__ |
32 |
|
|
33 |
|
if __entrypoint__ == "testing": |
34 |
|
__backend__ = "https://todic.dk/xbmc-beta.php?xbmckey=" + __key__ |
35 |
|
|
36 |
|
print "[Todic] entrypoint: " + __entrypoint__ |
37 |
|
print "[Todic] backend: " + __backend__ |
38 |
|
|
39 |
|
|
40 |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
41 |
datapath = xbmc.translatePath( |
datapath = xbmc.translatePath( |
42 |
'special://profile/addon_data/plugin.video.todic/') |
'special://profile/addon_data/plugin.video.todic/') |
114 |
|
|
115 |
def __init__(self, *args, **kwargs): |
def __init__(self, *args, **kwargs): |
116 |
# xbmc.Player.__init__(selv,*args,**kwargs) |
# xbmc.Player.__init__(selv,*args,**kwargs) |
117 |
xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER) |
xbmc.Player.__init__(self) |
118 |
self.stopped = False |
self.stopped = False |
119 |
self.started = False |
self.started = False |
120 |
self.playingPosition = 0.0 |
self.playingPosition = 0.0 |
148 |
def tick(self): |
def tick(self): |
149 |
#print "[Todic] Tick: " + str( self.isPlaying() ) |
#print "[Todic] Tick: " + str( self.isPlaying() ) |
150 |
if ( self.isPlaying() ): |
if ( self.isPlaying() ): |
151 |
self.playingPosition = self.getTime() |
tmpTime = self.getTime(): |
152 |
now = time() |
|
153 |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
#only report time if it has changed in the mean time |
154 |
if ( (now - self.lastReport) > 60.0): |
if tmpTime != self.playingPosition: |
155 |
self.lastReport = now |
self.playingPosition = tmpTime |
156 |
self.reportPlaytime("playing") |
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 |
def reportPlaytime(self, subaction): |
def reportPlaytime(self, subaction): |
163 |
if (self.playingPosition > 60): |
if (self.playingPosition > 60): |
262 |
|
|
263 |
entries = doc.getElementsByTagName("entry") |
entries = doc.getElementsByTagName("entry") |
264 |
l = len(entries) |
l = len(entries) |
265 |
description = '' |
|
266 |
for entry in entries: |
for entry in entries: |
267 |
name = getText(entry.getElementsByTagName("title")) |
name = getText(entry.getElementsByTagName("title")) |
268 |
url = getText(entry.getElementsByTagName("url")) |
url = getText(entry.getElementsByTagName("url")) |
269 |
thumb = getText(entry.getElementsByTagName("cover")) |
thumb = getText(entry.getElementsByTagName("cover")) |
|
description = getText(entry.getElementsByTagName("description")) |
|
270 |
playcount = getText(entry.getElementsByTagName("playcount")) |
playcount = getText(entry.getElementsByTagName("playcount")) |
271 |
|
|
272 |
|
|
277 |
# print "name:" + name |
# print "name:" + name |
278 |
# print "url:" + url |
# print "url:" + url |
279 |
# print "thumb:" + thumb |
# print "thumb:" + thumb |
|
# print "description:" + description |
|
280 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem( |
281 |
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
282 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
283 |
if mode == '50': |
if mode == '50': |
284 |
infoLabels = {} |
infoLabels = {} |
285 |
infoLabels['title'] = name |
infoLabels['title'] = name |
|
infoLabels['plot'] = description |
|
286 |
infoLabels['playcount'] = playcount |
infoLabels['playcount'] = playcount |
287 |
listitem.setInfo('video', infoLabels) |
listitem.setInfo('video', infoLabels) |
288 |
|
|
289 |
name = name.encode('UTF-8') |
name = name.encode('UTF-8') |
|
description = description.encode('UTF-8') |
|
290 |
|
|
291 |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
292 |
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
name) + "&url=" + urllib.quote(url) |
293 |
xbmcplugin.addDirectoryItem( |
xbmcplugin.addDirectoryItem( |
294 |
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) |
295 |
|
|
297 |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
298 |
|
|
299 |
|
|
300 |
def play_video(url, name, description): |
def play_video(url, name): |
301 |
|
description = "" |
302 |
playPosition = 0 |
playPosition = 0 |
303 |
savedPosition = 0 |
savedPosition = 0 |
304 |
try: |
try: |
313 |
|
|
314 |
clipDetailsDoc = parseString(xml) |
clipDetailsDoc = parseString(xml) |
315 |
savedPosition = int( getText(clipDetailsDoc.getElementsByTagName("position")) ) |
savedPosition = int( getText(clipDetailsDoc.getElementsByTagName("position")) ) |
316 |
|
description = getText(clipDetailsDoc.getElementsByTagName("description")) |
317 |
except: |
except: |
318 |
print "[Todic] Unexpected error:", sys.exc_info()[0] |
print "[Todic] Unexpected error:", sys.exc_info()[0] |
319 |
|
|
366 |
listitem.setProperty('ResumeTime', '300') |
listitem.setProperty('ResumeTime', '300') |
367 |
listitem.setProperty('TotalTime', '3000') |
listitem.setProperty('TotalTime', '3000') |
368 |
|
|
369 |
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
player = TodicPlayer() |
370 |
player.play(str(url), listitem) |
player.play(str(url), listitem) |
371 |
|
|
372 |
# kan ikke loade subtitles hvis foerend playeren koerer |
# kan ikke loade subtitles hvis foerend playeren koerer |
384 |
player.setSubtitles(subtitlesfile) |
player.setSubtitles(subtitlesfile) |
385 |
print '[Todic] started subtitles' |
print '[Todic] started subtitles' |
386 |
else: |
else: |
387 |
player.disableSubtitles() |
player.showSubtitles(False) |
388 |
|
|
389 |
|
|
390 |
if (position > 0): |
if (position > 0): |
479 |
url = None |
url = None |
480 |
name = None |
name = None |
481 |
mode = None |
mode = None |
|
description = None |
|
482 |
|
|
483 |
|
|
484 |
#print params |
#print params |
495 |
mode = int(params["mode"]) |
mode = int(params["mode"]) |
496 |
except: |
except: |
497 |
pass |
pass |
|
try: |
|
|
description = urllib.unquote_plus(params["description"]) |
|
|
except: |
|
|
pass |
|
498 |
|
|
499 |
|
|
500 |
|
|
528 |
|
|
529 |
|
|
530 |
elif mode == 50: |
elif mode == 50: |
531 |
play_video(url, name, description) |
play_video(url, name) |