--- misc/xbmc/plugin.video.todic/default.py 2016/11/24 19:55:00 3151 +++ misc/xbmc/plugin.video.todic/default.py 2016/11/25 16:17:45 3152 @@ -3,7 +3,7 @@ ''' Todic plugin for XBMC - Version 0.0.21b + Version 0.1.0 ''' import sys @@ -60,7 +60,7 @@ def onInit(self): - print "[Todic] MovieDialog ONINIT" + print "[Todic] MovieDialog onInit" self.getControl(1).setLabel(self.name) self.getControl(2).setLabel(self.moviegroups) self.getControl(3).setLabel(self.description) @@ -80,30 +80,15 @@ #self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width #self.getControl(40).setWidth(int(self.starwidth)) - def setUrl(self, url): - print "[Todic] MovieDialog SETURL:" + url - self.url = url - self.fetchClipDetails() + def setDetailsDoc(self, detailsDoc): + print "[Todic] MovieDialog setDetailsDoc:" + self.imdbrating = getText(detailsDoc.getElementsByTagName("imdbrating")) + self.moviegroups = getText(detailsDoc.getElementsByTagName("moviegroups")) + self.playlength = getText(detailsDoc.getElementsByTagName("playlength")) + self.codecdetails = getText(detailsDoc.getElementsByTagName("codecdetails")) + self.position = int( getText(detailsDoc.getElementsByTagName("position")) ) - - 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")) ) - def setName(self, name): self.name = name @@ -122,27 +107,22 @@ self.lastReport = 0 print "[TodicPlayer] init" -# @catchall def onPlayBackStarted(self): self.started = True print "[TodicPlayer] : started" -# super.onPlayBackStarted() #When user presses stop, we report back the the position registered in the last call to self.tick() def onPlayBackStopped(self): self.stopped = True print "[TodicPlayer] : stopped" self.reportPlaytime("stopped") -# url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) -# open_url_safe(url) + def onPlayBackEnded(self): self.stopped = True print "[TodicPlayer] : ended" self.reportPlaytime("ended") -# url = __backend__ + "&action=playbacktime&subaction=ended&time=" - # open_url_safe(url) def tick(self): if ( self.isPlaying() ): @@ -153,9 +133,6 @@ self.lastReport = now self.reportPlaytime("playing") - - - def reportPlaytime(self, subaction): if (self.playingPosition > 60): url = __backend__ + "&action=playbacktime&subaction=" + subaction + "&time=" + str( self.playingPosition ) @@ -300,11 +277,32 @@ def play_video(url, name, description): + param1 = parse_parameter_string(url) + 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")) ) + playPosition = 0 + if (description == None or description == ""): - play_real_video(url, name, 0) + if (savedPosition > 0): + dialog = xbmcgui.Dialog() + #yes / true -afspil fra position + answer = dialog.yesno(heading='Todic', line1='Afspil fra gemt', nolabel='Fra start', yeslabel='Fortsæt') + if (answer == True): + playPosition = savedPosition + + play_real_video(url, name, playPosition) + else: d = TodicMovieDialog() - d.setUrl(url) + d.setDetailsDoc(clipDetailsDoc) d.setName(name) d.setDescription(description)