3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.0.20 |
Version 0.1.0 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
60 |
|
|
61 |
def onInit(self): |
def onInit(self): |
62 |
|
|
63 |
print "[Todic] MovieDialog 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) |
80 |
#self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
#self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
81 |
#self.getControl(40).setWidth(int(self.starwidth)) |
#self.getControl(40).setWidth(int(self.starwidth)) |
82 |
|
|
83 |
def setUrl(self, url): |
def setDetailsDoc(self, detailsDoc): |
84 |
print "[Todic] MovieDialog SETURL:" + url |
print "[Todic] MovieDialog setDetailsDoc:" |
85 |
self.url = url |
self.imdbrating = getText(detailsDoc.getElementsByTagName("imdbrating")) |
86 |
self.fetchClipDetails() |
self.moviegroups = getText(detailsDoc.getElementsByTagName("moviegroups")) |
87 |
|
self.playlength = getText(detailsDoc.getElementsByTagName("playlength")) |
88 |
|
self.codecdetails = getText(detailsDoc.getElementsByTagName("codecdetails")) |
89 |
|
self.position = int( getText(detailsDoc.getElementsByTagName("position")) ) |
90 |
|
|
|
def setPosition(self, pos): |
|
|
print "[Todic] MovieDialog setPosition:" + str(pos) |
|
|
self.position = pos |
|
|
|
|
|
|
|
|
|
|
|
def fetchClipDetails(self): |
|
|
param1 = parse_parameter_string(self.url) |
|
|
|
|
|
self.clipkey = param1["clipkey"] |
|
|
print "CLIPKEY:" + self.clipkey |
|
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + self.clipkey |
|
|
|
|
|
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")) |
|
91 |
|
|
92 |
def setName(self, name): |
def setName(self, name): |
93 |
self.name = name |
self.name = name |
107 |
self.lastReport = 0 |
self.lastReport = 0 |
108 |
print "[TodicPlayer] init" |
print "[TodicPlayer] init" |
109 |
|
|
|
# @catchall |
|
110 |
def onPlayBackStarted(self): |
def onPlayBackStarted(self): |
111 |
self.started = True |
self.started = True |
112 |
print "[TodicPlayer] : started" |
print "[TodicPlayer] : started" |
|
# super.onPlayBackStarted() |
|
113 |
|
|
114 |
#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() |
115 |
def onPlayBackStopped(self): |
def onPlayBackStopped(self): |
116 |
self.stopped = True |
self.stopped = True |
117 |
print "[TodicPlayer] : stopped" |
print "[TodicPlayer] : stopped" |
118 |
url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) |
self.reportPlaytime("stopped") |
119 |
open_url_safe(url) |
|
120 |
|
|
121 |
|
|
122 |
def onPlayBackEnded(self): |
def onPlayBackEnded(self): |
123 |
self.stopped = True |
self.stopped = True |
124 |
print "[TodicPlayer] : ended" |
print "[TodicPlayer] : ended" |
125 |
url = __backend__ + "&action=playbacktime&subaction=ended&time=" |
self.reportPlaytime("ended") |
|
open_url_safe(url) |
|
126 |
|
|
127 |
def tick(self): |
def tick(self): |
128 |
if ( self.isPlaying() ): |
if ( self.isPlaying() ): |
131 |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
132 |
if ( (now - self.lastReport) > 60.0): |
if ( (now - self.lastReport) > 60.0): |
133 |
self.lastReport = now |
self.lastReport = now |
134 |
self.reportPlaytime() |
self.reportPlaytime("playing") |
|
|
|
|
|
|
135 |
|
|
136 |
|
def reportPlaytime(self, subaction): |
137 |
|
if (self.playingPosition > 60): |
138 |
|
url = __backend__ + "&action=playbacktime&subaction=" + subaction + "&time=" + str( self.playingPosition ) |
139 |
|
print "[Todic] reportPlaytime:" + url |
140 |
|
open_url_safe(url) |
141 |
|
|
|
def reportPlaytime(self): |
|
|
url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) |
|
|
open_url_safe(url) |
|
|
print "[Todic] reportPlaytime:" + url |
|
142 |
|
|
143 |
|
|
144 |
|
|
244 |
thumb = getText(entry.getElementsByTagName("cover")) |
thumb = getText(entry.getElementsByTagName("cover")) |
245 |
description = getText(entry.getElementsByTagName("description")) |
description = getText(entry.getElementsByTagName("description")) |
246 |
playcount = getText(entry.getElementsByTagName("playcount")) |
playcount = getText(entry.getElementsByTagName("playcount")) |
|
pos = getText(entry.getElementsByTagName("pos")) |
|
247 |
|
|
248 |
|
|
249 |
if playcount == '': |
if playcount == '': |
268 |
description = description.encode('UTF-8') |
description = description.encode('UTF-8') |
269 |
|
|
270 |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
271 |
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) + "&pos=" + pos |
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
272 |
xbmcplugin.addDirectoryItem( |
xbmcplugin.addDirectoryItem( |
273 |
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) |
274 |
|
|
277 |
|
|
278 |
|
|
279 |
def play_video(url, name, description): |
def play_video(url, name, description): |
280 |
|
param1 = parse_parameter_string(url) |
281 |
|
clipkey = param1["clipkey"] |
282 |
|
|
283 |
|
print "[Todic] ClipKey:" + clipkey |
284 |
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + clipkey |
285 |
|
print "[Todic] detailURL = " + detailurl |
286 |
|
|
287 |
|
xml = open_url(detailurl) |
288 |
|
|
289 |
|
clipDetailsDoc = parseString(xml) |
290 |
|
savedPosition = int( getText(clipDetailsDoc.getElementsByTagName("position")) ) |
291 |
|
playPosition = 0 |
292 |
|
|
293 |
if (description == None or description == ""): |
if (description == None or description == ""): |
294 |
play_real_video(url, name, 0) |
if (savedPosition > 0): |
295 |
|
dialog = xbmcgui.Dialog() |
296 |
|
#yes / true -afspil fra position |
297 |
|
answer = dialog.yesno(heading='Todic', line1='Afspil fra gemt', nolabel='Fra start', yeslabel='Fortsæt') |
298 |
|
if (answer == True): |
299 |
|
playPosition = savedPosition |
300 |
|
|
301 |
|
play_real_video(url, name, playPosition) |
302 |
|
|
303 |
else: |
else: |
304 |
d = TodicMovieDialog() |
d = TodicMovieDialog() |
305 |
d.setUrl(url) |
d.setDetailsDoc(clipDetailsDoc) |
306 |
d.setName(name) |
d.setName(name) |
307 |
d.setDescription(description) |
d.setDescription(description) |
|
d.setPosition(pos) #tager pos fra global scope |
|
308 |
|
|
309 |
d.doModal() |
d.doModal() |
310 |
|
|
452 |
name = None |
name = None |
453 |
mode = None |
mode = None |
454 |
description = None |
description = None |
455 |
pos = 0 |
|
456 |
|
|
457 |
#print params |
#print params |
458 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
|
try: |
|
|
pos = int(params["pos"]) |
|
|
except: |
|
|
pass |
|
|
|
|
478 |
|
|
479 |
try: |
try: |
480 |
open_url("http://todic.dk") |
open_url("http://todic.dk") |