3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.1.0 |
Version 1.7 |
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/') |
100 |
self.codecdetails = getText(detailsDoc.getElementsByTagName("codecdetails")) |
self.codecdetails = getText(detailsDoc.getElementsByTagName("codecdetails")) |
101 |
self.position = int( getText(detailsDoc.getElementsByTagName("position")) ) |
self.position = int( getText(detailsDoc.getElementsByTagName("position")) ) |
102 |
|
|
103 |
|
def setUrl(self, url): |
104 |
|
self.url = url |
105 |
|
|
106 |
def setName(self, name): |
def setName(self, name): |
107 |
self.name = name |
self.name = name |
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 |
131 |
print "[TodicPlayer] : stopped" |
print "[TodicPlayer] : stopped" |
132 |
self.reportPlaytime("stopped") |
self.reportPlaytime("stopped") |
133 |
|
|
134 |
|
def onPlayBackPaused(self): |
135 |
|
print "[TodicPlayer] : paused" |
136 |
|
self.reportPlaytime("paused") |
137 |
|
|
138 |
|
def onPlayBackResumed(self): |
139 |
|
print "[TodicPlayer] : resumed" |
140 |
|
self.reportPlaytime("resumed") |
141 |
|
|
142 |
|
|
143 |
def onPlayBackEnded(self): |
def onPlayBackEnded(self): |
146 |
self.reportPlaytime("ended") |
self.reportPlaytime("ended") |
147 |
|
|
148 |
def tick(self): |
def tick(self): |
149 |
|
#print "[Todic] Tick: " + str( self.isPlaying() ) |
150 |
if ( self.isPlaying() ): |
if ( self.isPlaying() ): |
151 |
self.playingPosition = self.getTime() |
self.playingPosition = self.getTime() |
152 |
now = time() |
now = time() |
161 |
print "[Todic] reportPlaytime:" + url |
print "[Todic] reportPlaytime:" + url |
162 |
open_url_safe(url) |
open_url_safe(url) |
163 |
|
|
|
|
|
164 |
|
|
165 |
|
|
166 |
def getText2(nodelist): |
def getText2(nodelist): |
205 |
try: |
try: |
206 |
return open_url(url) |
return open_url(url) |
207 |
except: |
except: |
208 |
print "[Todic ]Some error during open_url call to ", url |
print "[Todic] Some error during open_url call to ", url |
209 |
|
|
210 |
|
|
211 |
|
|
222 |
|
|
223 |
# Adde xtra items to root menu |
# Adde xtra items to root menu |
224 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem( |
225 |
label="Søg film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
label="Søg Film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
226 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
227 |
|
|
228 |
u = sys.argv[0] + "?mode=10&name=" |
u = sys.argv[0] + "?mode=10&name=" |
242 |
|
|
243 |
|
|
244 |
def buildList(url, title, endlist=True): |
def buildList(url, title, endlist=True): |
245 |
print '[TODIC]:' + str(url) |
print '[Todic]:' + str(url) |
246 |
|
|
247 |
link = open_url(url) |
link = open_url(url) |
248 |
doc = parseString(link) |
doc = parseString(link) |
249 |
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
250 |
print '[TODIC]' + str(ty) |
print '[Todic]' + str(ty) |
251 |
|
|
252 |
if ty == 'clipList': |
if ty == 'clipList': |
253 |
mode = '50' |
mode = '50' |
258 |
|
|
259 |
entries = doc.getElementsByTagName("entry") |
entries = doc.getElementsByTagName("entry") |
260 |
l = len(entries) |
l = len(entries) |
261 |
description = '' |
|
262 |
for entry in entries: |
for entry in entries: |
263 |
name = getText(entry.getElementsByTagName("title")) |
name = getText(entry.getElementsByTagName("title")) |
264 |
url = getText(entry.getElementsByTagName("url")) |
url = getText(entry.getElementsByTagName("url")) |
265 |
thumb = getText(entry.getElementsByTagName("cover")) |
thumb = getText(entry.getElementsByTagName("cover")) |
|
description = getText(entry.getElementsByTagName("description")) |
|
266 |
playcount = getText(entry.getElementsByTagName("playcount")) |
playcount = getText(entry.getElementsByTagName("playcount")) |
267 |
|
|
268 |
|
|
273 |
# print "name:" + name |
# print "name:" + name |
274 |
# print "url:" + url |
# print "url:" + url |
275 |
# print "thumb:" + thumb |
# print "thumb:" + thumb |
|
# print "description:" + description |
|
276 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem( |
277 |
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
278 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
279 |
if mode == '50': |
if mode == '50': |
280 |
infoLabels = {} |
infoLabels = {} |
281 |
infoLabels['title'] = name |
infoLabels['title'] = name |
|
infoLabels['plot'] = description |
|
282 |
infoLabels['playcount'] = playcount |
infoLabels['playcount'] = playcount |
283 |
listitem.setInfo('video', infoLabels) |
listitem.setInfo('video', infoLabels) |
284 |
|
|
285 |
name = name.encode('UTF-8') |
name = name.encode('UTF-8') |
|
description = description.encode('UTF-8') |
|
286 |
|
|
287 |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
288 |
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
name) + "&url=" + urllib.quote(url) |
289 |
xbmcplugin.addDirectoryItem( |
xbmcplugin.addDirectoryItem( |
290 |
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) |
291 |
|
|
293 |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
294 |
|
|
295 |
|
|
296 |
def play_video(url, name, description): |
def play_video(url, name): |
297 |
param1 = parse_parameter_string(url) |
description = "" |
|
clipkey = param1["clipkey"] |
|
|
|
|
|
print "[Todic] ClipKey:" + clipkey |
|
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + clipkey |
|
|
print "[Todic] detailURL = " + detailurl |
|
|
|
|
|
xml = open_url(detailurl) |
|
|
|
|
|
clipDetailsDoc = parseString(xml) |
|
|
savedPosition = int( getText(clipDetailsDoc.getElementsByTagName("position")) ) |
|
298 |
playPosition = 0 |
playPosition = 0 |
299 |
|
savedPosition = 0 |
300 |
|
try: |
301 |
|
param1 = parse_parameter_string(url) |
302 |
|
clipkey = param1["clipkey"] |
303 |
|
|
304 |
|
print "[Todic] ClipKey:" + clipkey |
305 |
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + clipkey |
306 |
|
print "[Todic] detailURL = " + detailurl |
307 |
|
|
308 |
|
xml = open_url(detailurl) |
309 |
|
|
310 |
|
clipDetailsDoc = parseString(xml) |
311 |
|
savedPosition = int( getText(clipDetailsDoc.getElementsByTagName("position")) ) |
312 |
|
description = getText(clipDetailsDoc.getElementsByTagName("description")) |
313 |
|
except: |
314 |
|
print "[Todic] Unexpected error:", sys.exc_info()[0] |
315 |
|
|
316 |
if (description == None or description == ""): |
if (description == None or description == ""): |
317 |
if (savedPosition > 0): |
if (savedPosition > 0): |
318 |
dialog = xbmcgui.Dialog() |
dialog = xbmcgui.Dialog() |
319 |
#yes / true -afspil fra position |
#yes / true -afspil fra position |
320 |
answer = dialog.yesno(heading='Todic', line1='Afspil fra gemt', nolabel='Fra start', yeslabel='Fortsæt') |
answer = dialog.yesno(heading='Todic', line1='Afspil fra sidste position', nolabel='Fra start', yeslabel='Fortsæt') |
321 |
if (answer == True): |
if (answer == True): |
322 |
playPosition = savedPosition |
playPosition = savedPosition |
323 |
|
|
327 |
d = TodicMovieDialog() |
d = TodicMovieDialog() |
328 |
d.setDetailsDoc(clipDetailsDoc) |
d.setDetailsDoc(clipDetailsDoc) |
329 |
d.setName(name) |
d.setName(name) |
330 |
|
d.setUrl(url) |
331 |
d.setDescription(description) |
d.setDescription(description) |
332 |
|
|
333 |
d.doModal() |
d.doModal() |
349 |
if os.path.isfile(subtitlesfile): |
if os.path.isfile(subtitlesfile): |
350 |
os.unlink(subtitlesfile) |
os.unlink(subtitlesfile) |
351 |
|
|
352 |
print '[TODIC] subs: ' + str(subtitleurl) |
print '[Todic] subs: ' + str(subtitleurl) |
353 |
if len(subtitleurl) > 0: |
if len(subtitleurl) > 0: |
354 |
subtitles = open_url(subtitleurl) |
subtitles = open_url(subtitleurl) |
355 |
SaveFile(subtitlesfile, subtitles) |
SaveFile(subtitlesfile, subtitles) |
356 |
print 'TODIC downloaded subtitles' |
print '[Todic] downloaded subtitles' |
357 |
|
|
358 |
image = xbmc.getInfoImage('ListItem.Thumb') |
image = xbmc.getInfoImage('ListItem.Thumb') |
359 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem( |
362 |
listitem.setProperty('ResumeTime', '300') |
listitem.setProperty('ResumeTime', '300') |
363 |
listitem.setProperty('TotalTime', '3000') |
listitem.setProperty('TotalTime', '3000') |
364 |
|
|
365 |
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
player = TodicPlayer() |
366 |
player.play(str(url), listitem) |
player.play(str(url), listitem) |
367 |
|
|
368 |
# kan ikke loade subtitles hvis foerend playeren koerer |
# kan ikke loade subtitles hvis foerend playeren koerer |
378 |
if xbmc.Player().isPlaying(): |
if xbmc.Player().isPlaying(): |
379 |
if os.path.isfile(subtitlesfile): |
if os.path.isfile(subtitlesfile): |
380 |
player.setSubtitles(subtitlesfile) |
player.setSubtitles(subtitlesfile) |
381 |
print 'TODIC started subtitles' |
print '[Todic] started subtitles' |
382 |
else: |
else: |
383 |
player.disableSubtitles() |
player.showSubtitles(False) |
384 |
|
|
385 |
|
|
386 |
if (position > 0): |
if (position > 0): |
405 |
url = __backend__ + "&action=search&search=" + \ |
url = __backend__ + "&action=search&search=" + \ |
406 |
urllib.quote_plus(search) |
urllib.quote_plus(search) |
407 |
|
|
408 |
# print "[TODIC] Search start: " + search |
# print "[Todic] Search start: " + search |
409 |
# print "[TODIC] Search url: " + url |
# print "[Todic] Search url: " + url |
410 |
|
|
411 |
buildList(url, "søgning") |
buildList(url, "søgning") |
412 |
|
|
418 |
url = __backend__ + "&action=searchseries&search=" + \ |
url = __backend__ + "&action=searchseries&search=" + \ |
419 |
urllib.quote_plus(search) |
urllib.quote_plus(search) |
420 |
|
|
421 |
# print "[TODIC] Search start: " + search |
# print "[Todic] Search start: " + search |
422 |
# print "[TODIC] Search url: " + url |
# print "[Todic] Search url: " + url |
423 |
|
|
424 |
buildList(url, "serie søgning") |
buildList(url, "serie søgning") |
425 |
|
|
475 |
url = None |
url = None |
476 |
name = None |
name = None |
477 |
mode = None |
mode = None |
|
description = None |
|
478 |
|
|
479 |
|
|
480 |
#print params |
#print params |
491 |
mode = int(params["mode"]) |
mode = int(params["mode"]) |
492 |
except: |
except: |
493 |
pass |
pass |
|
try: |
|
|
description = urllib.unquote_plus(params["description"]) |
|
|
except: |
|
|
pass |
|
494 |
|
|
495 |
|
|
496 |
|
|
524 |
|
|
525 |
|
|
526 |
elif mode == 50: |
elif mode == 50: |
527 |
play_video(url, name, description) |
play_video(url, name) |