--- misc/xbmc/plugin.video.todic/default.py 2016/11/25 16:17:45 3152 +++ misc/xbmc/plugin.video.todic/default.py 2019/02/18 18:09:47 3245 @@ -3,7 +3,7 @@ ''' Todic plugin for XBMC - Version 0.1.0 + Version 1.7.2 ''' import sys @@ -24,7 +24,19 @@ __addon__ = xbmcaddon.Addon(id='plugin.video.todic') __key__ = __addon__.getSetting('xbmckey').lower() +__entrypoint__ = __addon__.getSetting('entrypoint').lower() __backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ + +if __entrypoint__ == "alternative": + __backend__ = "https://alt.todic.dk/xbmc.php?xbmckey=" + __key__ + +if __entrypoint__ == "testing": + __backend__ = "https://todic.dk/xbmc-beta.php?xbmckey=" + __key__ + +print "[Todic] entrypoint: " + __entrypoint__ +print "[Todic] backend: " + __backend__ + + fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') datapath = xbmc.translatePath( 'special://profile/addon_data/plugin.video.todic/') @@ -88,6 +100,8 @@ self.codecdetails = getText(detailsDoc.getElementsByTagName("codecdetails")) self.position = int( getText(detailsDoc.getElementsByTagName("position")) ) + def setUrl(self, url): + self.url = url def setName(self, name): self.name = name @@ -100,7 +114,7 @@ def __init__(self, *args, **kwargs): # xbmc.Player.__init__(selv,*args,**kwargs) - xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER) + xbmc.Player.__init__(self) self.stopped = False self.started = False self.playingPosition = 0.0 @@ -117,6 +131,13 @@ print "[TodicPlayer] : stopped" self.reportPlaytime("stopped") + def onPlayBackPaused(self): + print "[TodicPlayer] : paused" + self.reportPlaytime("paused") + + def onPlayBackResumed(self): + print "[TodicPlayer] : resumed" + self.reportPlaytime("resumed") def onPlayBackEnded(self): @@ -125,13 +146,18 @@ self.reportPlaytime("ended") def tick(self): + #print "[Todic] Tick: " + str( self.isPlaying() ) if ( self.isPlaying() ): - self.playingPosition = self.getTime() - now = time() - #print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) - if ( (now - self.lastReport) > 60.0): - self.lastReport = now - self.reportPlaytime("playing") + tmpTime = self.getTime() + + #only report time if it has changed in the mean time + if tmpTime != self.playingPosition: + self.playingPosition = tmpTime + now = time() + #print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) + if ( (now - self.lastReport) > 60.0): + self.lastReport = now + self.reportPlaytime("playing") def reportPlaytime(self, subaction): if (self.playingPosition > 60): @@ -139,7 +165,6 @@ print "[Todic] reportPlaytime:" + url open_url_safe(url) - def getText2(nodelist): @@ -184,7 +209,7 @@ try: return open_url(url) except: - print "[Todic ]Some error during open_url call to ", url + print "[Todic] Some error during open_url call to ", url @@ -201,7 +226,7 @@ # Adde xtra items to root menu listitem = xbmcgui.ListItem( - label="Søg film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') + label="Søg Film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') listitem.setProperty('Fanart_Image', fanartImage) u = sys.argv[0] + "?mode=10&name=" @@ -221,12 +246,12 @@ def buildList(url, title, endlist=True): - print '[TODIC]:' + str(url) + print '[Todic]:' + str(url) link = open_url(url) doc = parseString(link) ty = doc.getElementsByTagName("meta")[0].getAttribute("type") - print '[TODIC]' + str(ty) + print '[Todic]' + str(ty) if ty == 'clipList': mode = '50' @@ -237,12 +262,11 @@ entries = doc.getElementsByTagName("entry") l = len(entries) - description = '' + for entry in entries: name = getText(entry.getElementsByTagName("title")) url = getText(entry.getElementsByTagName("url")) thumb = getText(entry.getElementsByTagName("cover")) - description = getText(entry.getElementsByTagName("description")) playcount = getText(entry.getElementsByTagName("playcount")) @@ -253,22 +277,19 @@ # print "name:" + name # print "url:" + url # print "thumb:" + thumb -# print "description:" + description listitem = xbmcgui.ListItem( label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) listitem.setProperty('Fanart_Image', fanartImage) if mode == '50': infoLabels = {} infoLabels['title'] = name - infoLabels['plot'] = description infoLabels['playcount'] = playcount listitem.setInfo('video', infoLabels) name = name.encode('UTF-8') - description = description.encode('UTF-8') u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( - name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) + name) + "&url=" + urllib.quote(url) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) @@ -276,25 +297,31 @@ xbmcplugin.endOfDirectory(int(sys.argv[1])) -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")) ) +def play_video(url, name): + description = "" playPosition = 0 + savedPosition = 0 + try: + 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")) ) + description = getText(clipDetailsDoc.getElementsByTagName("description")) + except: + print "[Todic] Unexpected error:", sys.exc_info()[0] if (description == None or description == ""): 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') + answer = dialog.yesno(heading='Todic', line1='Afspil fra sidste position', nolabel='Fra start', yeslabel='Fortsæt') if (answer == True): playPosition = savedPosition @@ -304,6 +331,7 @@ d = TodicMovieDialog() d.setDetailsDoc(clipDetailsDoc) d.setName(name) + d.setUrl(url) d.setDescription(description) d.doModal() @@ -325,11 +353,11 @@ if os.path.isfile(subtitlesfile): os.unlink(subtitlesfile) - print '[TODIC] subs: ' + str(subtitleurl) + print '[Todic] subs: ' + str(subtitleurl) if len(subtitleurl) > 0: subtitles = open_url(subtitleurl) SaveFile(subtitlesfile, subtitles) - print 'TODIC downloaded subtitles' + print '[Todic] downloaded subtitles' image = xbmc.getInfoImage('ListItem.Thumb') listitem = xbmcgui.ListItem( @@ -338,7 +366,7 @@ listitem.setProperty('ResumeTime', '300') listitem.setProperty('TotalTime', '3000') - player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) + player = TodicPlayer() player.play(str(url), listitem) # kan ikke loade subtitles hvis foerend playeren koerer @@ -354,9 +382,9 @@ if xbmc.Player().isPlaying(): if os.path.isfile(subtitlesfile): player.setSubtitles(subtitlesfile) - print 'TODIC started subtitles' + print '[Todic] started subtitles' else: - player.disableSubtitles() + player.showSubtitles(False) if (position > 0): @@ -381,8 +409,8 @@ url = __backend__ + "&action=search&search=" + \ urllib.quote_plus(search) - # print "[TODIC] Search start: " + search - # print "[TODIC] Search url: " + url + # print "[Todic] Search start: " + search + # print "[Todic] Search url: " + url buildList(url, "søgning") @@ -394,8 +422,8 @@ url = __backend__ + "&action=searchseries&search=" + \ urllib.quote_plus(search) - # print "[TODIC] Search start: " + search - # print "[TODIC] Search url: " + url + # print "[Todic] Search start: " + search + # print "[Todic] Search url: " + url buildList(url, "serie søgning") @@ -451,7 +479,6 @@ url = None name = None mode = None -description = None #print params @@ -468,10 +495,6 @@ mode = int(params["mode"]) except: pass -try: - description = urllib.unquote_plus(params["description"]) -except: - pass @@ -505,4 +528,4 @@ elif mode == 50: - play_video(url, name, description) + play_video(url, name)