--- misc/xbmc/plugin.video.todic/default.py 2013/01/13 15:39:59 1913 +++ misc/xbmc/plugin.video.todic/default.py 2013/01/17 18:44:47 1914 @@ -24,6 +24,7 @@ __key__ = __addon__.getSetting('xbmckey').lower() __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__ fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'fanart.jpg') +datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/') class TodicPlayer(xbmc.Player): @@ -74,6 +75,11 @@ else: return nodelist[0].childNodes[0].nodeValue +def SaveFile(path, data): + file = open(path,'w') + file.write(data) + file.close() + def open_url(url): req = urllib2.Request(url) @@ -104,7 +110,7 @@ def buildList(url,title, endlist=True): - print '[TODIC]:'+str(url) + print '[TODIC]:'+str(url) link = open_url(url) doc = parseString(link) @@ -162,17 +168,44 @@ def play_video(url, name): xml = open_url(url) + print 'TODIC url: ' + str(url) + print 'TODIC xml: '+ xml doc = parseString(xml) url = getText( doc.getElementsByTagName("url") ) - print '[TODIC]:'+str(url) + subtitleurl = getText( doc.getElementsByTagName("subtitles") ) + subtitlesfile = os.path.join(datapath,'temp.srt') + + print '[TODIC] subs: '+str(subtitleurl) + if len(subtitleurl) > 0: + subtitles = open_url(subtitleurl) + SaveFile(subtitlesfile, subtitles) + print 'TODIC downloaded subtitles' + + + image = xbmc.getInfoImage( 'ListItem.Thumb' ) listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image) listitem.setInfo( type = "Video", infoLabels={ "Title": name } ) player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) player.play(str(url), listitem) + + #kan ikke loade subtitles hvis foerend playeren koerer + count = 0 + while not xbmc.Player().isPlaying(): + xbmc.sleep(500) + count += 1 + if count > 10: + break + + + if xbmc.Player().isPlaying(): + if os.path.isfile(subtitlesfile): + player.setSubtitles(subtitlesfile) + print 'TODIC started subtitles' + # player.callbackLoop()