--- misc/xbmc/plugin.video.todic/default.py 2016/11/23 09:44:02 3146 +++ misc/xbmc/plugin.video.todic/default.py 2016/11/25 19:38:05 3153 @@ -3,7 +3,7 @@ ''' Todic plugin for XBMC - Version 0.0.18 + Version 0.1.1 ''' import sys @@ -42,49 +42,54 @@ def __init__(self): super(TodicMovieDialog, self).__init__() + self.position = 0 def onClick(self, controlId): - print "OnClick: " + str(controlId) + print "[Todic] MovieDialog OnClick: " + str(controlId) if (controlId == 50): self.close() - play_real_video(self.url, self.name) + play_real_video(self.url, self.name, 0) + + if (controlId == 51): + self.close() + play_real_video(self.url, self.name, self.position) if (controlId == 98): self.close() def onInit(self): - print "ONINIT" + print "[Todic] MovieDialog onInit" self.getControl(1).setLabel(self.name) self.getControl(2).setLabel(self.moviegroups) self.getControl(3).setLabel(self.description) self.getControl(10).setLabel(self.playlength) self.getControl(11).setLabel(self.codecdetails) - orig_img_width = self.getControl(40).getWidth() - self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width - self.getControl(40).setWidth(int(self.starwidth)) + if (self.position > 0): + self.getControl(51).setVisible(True) + self.getControl(50).setPosition(100, 570) + self.getControl(51).setPosition(450, 570) + self.getControl(50).controlLeft( self.getControl(51) ) + self.getControl(50).controlRight( self.getControl(51) ) + else: + self.getControl(51).setVisible(False) + + #orig_img_width = self.getControl(40).getWidth() + #self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width + #self.getControl(40).setWidth(int(self.starwidth)) + + 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 setUrl(self, url): - print "SETURL:" + url self.url = url - self.fetchClipDetails() - - 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")) def setName(self, name): self.name = name @@ -104,25 +109,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" - url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) - open_url_safe(url) + self.reportPlaytime("stopped") + def onPlayBackEnded(self): self.stopped = True print "[TodicPlayer] : ended" - url = __backend__ + "&action=playbacktime&subaction=ended&time=" - open_url_safe(url) + self.reportPlaytime("ended") def tick(self): if ( self.isPlaying() ): @@ -130,15 +132,15 @@ now = time() #print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) if ( (now - self.lastReport) > 60.0): - self.reportPlaytime() self.lastReport = now - + self.reportPlaytime("playing") + def reportPlaytime(self, subaction): + if (self.playingPosition > 60): + url = __backend__ + "&action=playbacktime&subaction=" + subaction + "&time=" + str( self.playingPosition ) + print "[Todic] reportPlaytime:" + url + open_url_safe(url) - def reportPlaytime(self): - url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) - open_url_safe(url) - print "[Todic] reportPlaytime:" + url @@ -184,7 +186,7 @@ try: return open_url(url) except: - print "Some error during open_url call to ", url + print "[Todic ]Some error during open_url call to ", url @@ -245,6 +247,7 @@ description = getText(entry.getElementsByTagName("description")) playcount = getText(entry.getElementsByTagName("playcount")) + if playcount == '': playcount = '0' playcount = int(playcount) @@ -276,21 +279,44 @@ 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) + 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.setUrl(url) d.setDescription(description) d.doModal() -def play_real_video(url, name): +def play_real_video(url, name, position): xml = open_url(url) - print 'TODIC url: ' + str(url) - print 'TODIC xml: ' + xml + print '[Todic] url: ' + str(url) + print '[Todic] xml: ' + xml + print '[Todic] pos: ' + str(position) doc = parseString(xml) url = getText(doc.getElementsByTagName("url")) @@ -312,6 +338,8 @@ listitem = xbmcgui.ListItem( label=name, iconImage='DefaultVideo.png', thumbnailImage=image) listitem.setInfo(type="Video", infoLabels={"Title": name}) + listitem.setProperty('ResumeTime', '300') + listitem.setProperty('TotalTime', '3000') player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) player.play(str(url), listitem) @@ -324,6 +352,8 @@ if count > 10: break + + if xbmc.Player().isPlaying(): if os.path.isfile(subtitlesfile): player.setSubtitles(subtitlesfile) @@ -331,14 +361,20 @@ else: player.disableSubtitles() - #Holder python kørernde indtil at det bliver bedt om at stoppe - while (not xbmc.abortRequested): - player.tick() - xbmc.sleep(250) + + if (position > 0): + while (player.getTotalTime() == 0.0): #Vent indtil vi har beregnet hvor langt klippet er + xbmc.sleep(250) + + print "[Todic] totalTime " + str( player.getTotalTime() ) + player.seekTime(position) + #Holder python kørernde indtil at det bliver bedt om at stoppe + while (not xbmc.abortRequested): + player.tick() + xbmc.sleep(500) -# player.callbackLoop() def search(): @@ -420,6 +456,9 @@ mode = None description = None + +#print params + try: url = urllib.unquote_plus(params["url"]) except: @@ -437,6 +476,9 @@ except: pass + + + try: open_url("http://todic.dk") except: