--- misc/xbmc/plugin.video.todic/default.py 2012/01/23 15:50:40 1677 +++ misc/xbmc/plugin.video.todic/default.py 2012/01/23 17:31:45 1678 @@ -1,5 +1,5 @@ -# This Python file uses the following encoding: utf-8 +# This Python file uses the following encoding: utf-8 ''' Todic plugin for XBMC @@ -16,7 +16,9 @@ import xbmcgui import xbmcplugin import urllib -import urllib2, re +import urllib2 + +from xml.dom.minidom import parseString __addon__ = xbmcaddon.Addon(id='plugin.video.todic') __key__ = __addon__.getSetting('xbmckey').lower() @@ -54,6 +56,23 @@ xbmc.sleep(5000) +def getText2(nodelist): + rc = [] + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + rc.append(node.data) + else: + rc.append( getText(node.childNodes) ) + return ''.join(rc) + +def getText(nodelist): + if nodelist.length == 0: + return '' + else: + if nodelist[0].childNodes.length == 0: + return '' + else: + return nodelist[0].childNodes[0].nodeValue def open_url(url): @@ -79,20 +98,36 @@ 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: + 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") ) + + name = name.encode('latin-1') + description = description.encode('latin-1') + +## 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) @@ -102,7 +137,7 @@ 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) + u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url) ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) if (endlist == True): @@ -112,19 +147,19 @@ def play_video(url, name): - link = open_url(url) - match=re.compile('(.+?)').findall(link) - url = match[0] + xml = open_url(url) + + doc = parseString(xml) + url = getText( doc.getElementsByTagName("url") ) + print '[TODIC]:'+str(url) image = xbmc.getInfoImage( 'ListItem.Thumb' ) 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) player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) player.play(str(url), listitem) - player.callbackLoop() +# player.callbackLoop() @@ -226,5 +261,4 @@ -# xbmcplugin.endOfDirectory(int(sys.argv[1]))