--- misc/xbmc/plugin.video.todic/default.py 2012/01/02 20:51:02 1676
+++ misc/xbmc/plugin.video.todic/default.py 2012/08/19 17:22:41 1829
@@ -1,3 +1,6 @@
+
+# This Python file uses the following encoding: utf-8
+
'''
Todic plugin for XBMC
Version 0.0.2
@@ -13,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()
@@ -51,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):
@@ -62,6 +84,13 @@
def rootMenu():
+ msg = open_url(__backend__ + "&action=messages")
+ msg = msg.strip()
+
+ if msg != "":
+ dialog = xbmcgui.Dialog()
+ dialog.ok('XBMC Todic', msg)
+
buildList(__backend__, "", False) # call default list
# Adde xtra items to root menu
@@ -76,30 +105,49 @@
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") )
+ playcount = getText( entry.getElementsByTagName("playcount") )
+
+ 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)
if mode == '50':
infoLabels = {}
infoLabels['title'] = name
- infoLabels['plot'] = description
+ infoLabels['plot'] = description
+ infoLabels['playcount'] = playcount
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):
@@ -109,19 +157,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()
@@ -182,10 +230,6 @@
param[splitparams[0]]=splitparams[1]
return param
-params = get_params()
-url = None
-name = None
-mode = None
params = get_params()
url = None
@@ -205,8 +249,12 @@
except:
pass
+if url == 'refresh':
+ xbmc.output("[tvserver] Container.Refresh")
+ xbmc.executebuiltin("Container.Refresh")
+
-if mode == None:
+elif mode == None:
#build main menu
rootMenu()
@@ -223,5 +271,4 @@
-# xbmcplugin.endOfDirectory(int(sys.argv[1]))