--- misc/xbmc/plugin.video.todic/default.py 2011/12/03 13:53:47 1647 +++ misc/xbmc/plugin.video.todic/default.py 2012/01/02 20:51:02 1676 @@ -5,6 +5,8 @@ import sys import cgi as urlparse +import os + import xbmc import xbmcaddon @@ -16,6 +18,40 @@ __addon__ = xbmcaddon.Addon(id='plugin.video.todic') __key__ = __addon__.getSetting('xbmckey').lower() __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__ +fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'fanart.jpg') + + +class TodicPlayer(xbmc.Player): + def __init__(self, *args, **kwargs): + #xbmc.Player.__init__(selv,*args,**kwargs) + xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER ) + self.stopped = False + self.started = False + print "[TodicPlayer] init" + +# @catchall + def onPlayBackStarted(self): + self.started = True + print "[TodicPlayer] : started" +# super.onPlayBackStarted() + + def onPlayBackStopped(self): + self.stopped = True + print "[TodicPlayer] : stopped" + + def onPlayBackEnded(self): + self.stopped = True + print "[TodicPlayer] : ended" + + def callbackLoop(self): + print "[Todic] startLoop" + while (self.stopped == False): + if (self.started == True ): + print "[todic] " + str(self.getTime()) + xbmc.sleep(5000) + + + def open_url(url): req = urllib2.Request(url) @@ -25,22 +61,20 @@ return data def rootMenu(): - link = open_url(__backend__) - m=re.compile('(.+?)(.+?)').findall(link) - l = len(m) - for name,url in m: - listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') - u = sys.argv[0] + "?mode=1&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url) - ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l) + buildList(__backend__, "", False) # call default list + + # Adde xtra items to root menu listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') - u = sys.argv[0] + "?mode=10&name=" + urllib.quote_plus(name) - ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l) + listitem.setProperty('Fanart_Image', fanartImage) + + u = sys.argv[0] + "?mode=10&name=" + ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) xbmcplugin.endOfDirectory(int(sys.argv[1])) -def buildList(url,title): +def buildList(url,title, endlist=True): print '[TODIC]:'+str(url) link = open_url(url) ty=re.compile('(.+?)(.+?)(.+?)(.*)').findall(link) l=len(m) for name,url,thumb,description in m: - infoLabels = {} - infoLabels['title'] = name - infoLabels['plot'] = description listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb) - listitem.setInfo('video', infoLabels) + listitem.setProperty('Fanart_Image', fanartImage) + if mode == '50': + infoLabels = {} + infoLabels['title'] = name + infoLabels['plot'] = description + listitem.setInfo('video', infoLabels) + u = sys.argv[0] + "?mode=" + urllib.quote_plus(mode) + "&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url) ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) - xbmcplugin.endOfDirectory(int(sys.argv[1])) + + if (endlist == True): + xbmcplugin.endOfDirectory(int(sys.argv[1])) @@ -78,8 +117,13 @@ listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image) # listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = 'DefaultVideo.png') listitem.setInfo( type = "Video", infoLabels={ "Title": name } ) - xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem) - xbmc.sleep(200) +# xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem) + + player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) + player.play(str(url), listitem) + player.callbackLoop() + + def search(): search = getUserInput("Todic Søgning")