3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.0.18 |
Version 0.0.19 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
42 |
|
|
43 |
def __init__(self): |
def __init__(self): |
44 |
super(TodicMovieDialog, self).__init__() |
super(TodicMovieDialog, self).__init__() |
45 |
|
self.position = 0 |
46 |
|
|
47 |
def onClick(self, controlId): |
def onClick(self, controlId): |
48 |
print "OnClick: " + str(controlId) |
print "[Todic] MovieDialog OnClick: " + str(controlId) |
49 |
|
|
50 |
if (controlId == 50): |
if (controlId == 50): |
51 |
self.close() |
self.close() |
52 |
play_real_video(self.url, self.name) |
play_real_video(self.url, self.name, 0) |
53 |
|
|
54 |
|
if (controlId == 51): |
55 |
|
self.close() |
56 |
|
play_real_video(self.url, self.name, self.position) |
57 |
|
|
58 |
if (controlId == 98): |
if (controlId == 98): |
59 |
self.close() |
self.close() |
60 |
|
|
61 |
def onInit(self): |
def onInit(self): |
62 |
|
|
63 |
print "ONINIT" |
print "[Todic] MovieDialog ONINIT" |
64 |
self.getControl(1).setLabel(self.name) |
self.getControl(1).setLabel(self.name) |
65 |
self.getControl(2).setLabel(self.moviegroups) |
self.getControl(2).setLabel(self.moviegroups) |
66 |
self.getControl(3).setLabel(self.description) |
self.getControl(3).setLabel(self.description) |
67 |
self.getControl(10).setLabel(self.playlength) |
self.getControl(10).setLabel(self.playlength) |
68 |
self.getControl(11).setLabel(self.codecdetails) |
self.getControl(11).setLabel(self.codecdetails) |
69 |
|
|
70 |
orig_img_width = self.getControl(40).getWidth() |
if (self.position > 0): |
71 |
self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
self.getControl(51).setVisible(True) |
72 |
self.getControl(40).setWidth(int(self.starwidth)) |
self.getControl(50).setPosition(100, 570) |
73 |
|
self.getControl(51).setPosition(450, 570) |
74 |
|
self.getControl(50).controlLeft( self.getControl(51) ) |
75 |
|
self.getControl(50).controlRight( self.getControl(51) ) |
76 |
|
else: |
77 |
|
self.getControl(51).setVisible(False) |
78 |
|
|
79 |
|
#orig_img_width = self.getControl(40).getWidth() |
80 |
|
#self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
81 |
|
#self.getControl(40).setWidth(int(self.starwidth)) |
82 |
|
|
83 |
def setUrl(self, url): |
def setUrl(self, url): |
84 |
print "SETURL:" + url |
print "[Todic] MovieDialog SETURL:" + url |
85 |
self.url = url |
self.url = url |
86 |
self.fetchClipDetails() |
self.fetchClipDetails() |
87 |
|
|
88 |
|
def setPosition(self, pos): |
89 |
|
print "[Todic] MovieDialog setPosition:" + str(pos) |
90 |
|
self.position = pos |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
def fetchClipDetails(self): |
def fetchClipDetails(self): |
95 |
param1 = parse_parameter_string(self.url) |
param1 = parse_parameter_string(self.url) |
96 |
|
|
150 |
now = time() |
now = time() |
151 |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
152 |
if ( (now - self.lastReport) > 60.0): |
if ( (now - self.lastReport) > 60.0): |
|
self.reportPlaytime() |
|
153 |
self.lastReport = now |
self.lastReport = now |
154 |
|
self.reportPlaytime() |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
205 |
try: |
try: |
206 |
return open_url(url) |
return open_url(url) |
207 |
except: |
except: |
208 |
print "Some error during open_url call to ", url |
print "[Todic ]Some error during open_url call to ", url |
209 |
|
|
210 |
|
|
211 |
|
|
298 |
|
|
299 |
def play_video(url, name, description): |
def play_video(url, name, description): |
300 |
if (description == None or description == ""): |
if (description == None or description == ""): |
301 |
play_real_video(url, name) |
play_real_video(url, name, 0) |
302 |
else: |
else: |
303 |
d = TodicMovieDialog() |
d = TodicMovieDialog() |
304 |
d.setUrl(url) |
d.setUrl(url) |
305 |
d.setName(name) |
d.setName(name) |
306 |
d.setDescription(description) |
d.setDescription(description) |
307 |
|
d.setPosition(pos) #tager pos fra global scope |
308 |
|
|
309 |
d.doModal() |
d.doModal() |
310 |
|
|
311 |
|
|
312 |
def play_real_video(url, name): |
def play_real_video(url, name, position): |
313 |
xml = open_url(url) |
xml = open_url(url) |
314 |
print 'TODIC url: ' + str(url) |
print '[Todic] url: ' + str(url) |
315 |
print 'TODIC xml: ' + xml |
print '[Todic] xml: ' + xml |
316 |
|
print '[Todic] pos: ' + str(position) |
317 |
|
|
318 |
doc = parseString(xml) |
doc = parseString(xml) |
319 |
url = getText(doc.getElementsByTagName("url")) |
url = getText(doc.getElementsByTagName("url")) |
335 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem( |
336 |
label=name, iconImage='DefaultVideo.png', thumbnailImage=image) |
label=name, iconImage='DefaultVideo.png', thumbnailImage=image) |
337 |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
338 |
|
listitem.setProperty('ResumeTime', '300') |
339 |
|
listitem.setProperty('TotalTime', '3000') |
340 |
|
|
341 |
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
342 |
player.play(str(url), listitem) |
player.play(str(url), listitem) |
344 |
# kan ikke loade subtitles hvis foerend playeren koerer |
# kan ikke loade subtitles hvis foerend playeren koerer |
345 |
count = 0 |
count = 0 |
346 |
while not xbmc.Player().isPlaying(): |
while not xbmc.Player().isPlaying(): |
347 |
xbmc.sleep(500) |
xbmc.sleep(250) |
348 |
count += 1 |
count += 1 |
349 |
if count > 10: |
if count > 10: |
350 |
break |
break |
351 |
|
|
352 |
|
|
353 |
|
|
354 |
if xbmc.Player().isPlaying(): |
if xbmc.Player().isPlaying(): |
355 |
if os.path.isfile(subtitlesfile): |
if os.path.isfile(subtitlesfile): |
356 |
player.setSubtitles(subtitlesfile) |
player.setSubtitles(subtitlesfile) |
358 |
else: |
else: |
359 |
player.disableSubtitles() |
player.disableSubtitles() |
360 |
|
|
|
#Holder python kørernde indtil at det bliver bedt om at stoppe |
|
|
while (not xbmc.abortRequested): |
|
|
player.tick() |
|
|
xbmc.sleep(100) |
|
361 |
|
|
362 |
|
if (position > 0): |
363 |
|
while (player.getTotalTime() == 0.0): #Vent indtil vi har beregnet hvor langt klippet er |
364 |
|
xbmc.sleep(250) |
365 |
|
|
366 |
|
print "[Todic] totalTime " + str( player.getTotalTime() ) |
367 |
|
player.seekTime(position) |
368 |
|
|
369 |
|
|
370 |
# player.callbackLoop() |
#Holder python kørernde indtil at det bliver bedt om at stoppe |
371 |
|
while (not xbmc.abortRequested): |
372 |
|
player.tick() |
373 |
|
xbmc.sleep(500) |
374 |
|
|
375 |
|
|
376 |
|
|
377 |
def search(): |
def search(): |
452 |
name = None |
name = None |
453 |
mode = None |
mode = None |
454 |
description = None |
description = None |
455 |
|
pos = 0 |
456 |
|
|
457 |
try: |
try: |
458 |
url = urllib.unquote_plus(params["url"]) |
url = urllib.unquote_plus(params["url"]) |
472 |
pass |
pass |
473 |
|
|
474 |
try: |
try: |
475 |
|
pos = int(params["pos"]) |
476 |
|
except: |
477 |
|
pass |
478 |
|
|
479 |
|
|
480 |
|
try: |
481 |
open_url("http://todic.dk") |
open_url("http://todic.dk") |
482 |
except: |
except: |
483 |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |