/[projects]/misc/xbmc/plugin.video.todic/default.py
ViewVC logotype

Diff of /misc/xbmc/plugin.video.todic/default.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1676 by torben, Mon Jan 2 20:51:02 2012 UTC revision 1799 by torben, Sun May 6 16:21:11 2012 UTC
# Line 1  Line 1 
1    
2    # This Python file uses the following encoding: utf-8
3    
4  '''  '''
5      Todic plugin for XBMC      Todic plugin for XBMC
6      Version 0.0.2      Version 0.0.2
# Line 13  import xbmcaddon Line 16  import xbmcaddon
16  import xbmcgui  import xbmcgui
17  import xbmcplugin  import xbmcplugin
18  import urllib  import urllib
19  import urllib2, re  import urllib2
20    
21    from xml.dom.minidom import parseString
22    
23  __addon__ = xbmcaddon.Addon(id='plugin.video.todic')  __addon__ = xbmcaddon.Addon(id='plugin.video.todic')
24  __key__ = __addon__.getSetting('xbmckey').lower()  __key__ = __addon__.getSetting('xbmckey').lower()
# Line 51  class TodicPlayer(xbmc.Player): Line 56  class TodicPlayer(xbmc.Player):
56                          xbmc.sleep(5000)                          xbmc.sleep(5000)
57                                                    
58    
59    def getText2(nodelist):
60            rc = []
61            for node in nodelist:
62                    if node.nodeType == node.TEXT_NODE:
63                            rc.append(node.data)
64                    else:
65                            rc.append( getText(node.childNodes) )
66            return ''.join(rc)
67    
68    def getText(nodelist):
69            if nodelist.length == 0:
70                    return ''
71            else:
72                    if nodelist[0].childNodes.length == 0:
73                            return ''
74                    else:
75                            return nodelist[0].childNodes[0].nodeValue
76    
77    
78  def open_url(url):  def open_url(url):
# Line 62  def open_url(url): Line 84  def open_url(url):
84    
85  def rootMenu():  def rootMenu():
86    
87            msg = open_url(__backend__ + "&action=messages")
88            msg = msg.strip()
89    
90            if msg != "":
91                    dialog = xbmcgui.Dialog()              
92                    dialog.ok('XBMC Todic', msg)
93    
94          buildList(__backend__, "", False) # call default list          buildList(__backend__, "", False) # call default list
95    
96          # Adde xtra items to root menu          # Adde xtra items to root menu
# Line 76  def rootMenu(): Line 105  def rootMenu():
105    
106  def buildList(url,title, endlist=True):  def buildList(url,title, endlist=True):
107          print '[TODIC]:'+str(url)                  print '[TODIC]:'+str(url)        
108    
109          link = open_url(url)          link = open_url(url)
110          ty=re.compile('<meta type=\'(.+?)\'').findall(link)          doc = parseString(link)
111          print '[TODIC]'+str(ty[0])          ty = doc.getElementsByTagName("meta")[0].getAttribute("type")
112            print '[TODIC]'+str(ty)
113    
114          if ty[0] == 'clipList':          if ty == 'clipList':
115                  mode = '50'                  mode = '50'
116                  folder = False                  folder = False
117          else:          else:
118                  mode = '1'                  mode = '1'
119                  folder = True                  folder = True
120    
121          m=re.compile('<title>(.+?)</title><url>(.+?)</url><cover>(.+?)</cover><description>(.*)</description>').findall(link)          entries = doc.getElementsByTagName("entry")
122          l=len(m)          l=len(entries)
123          for name,url,thumb,description in m:                                  description = ''
124            for entry in entries:
125                    name =  getText( entry.getElementsByTagName("title") )
126                    url =  getText( entry.getElementsByTagName("url") )
127                    thumb = getText( entry.getElementsByTagName("cover") )
128                    description = getText( entry.getElementsByTagName("description") )
129    
130                    name = name.encode('latin-1')
131                    description = description.encode('latin-1')
132    
133    ##              print "name:" + name
134    #               print "url:" + url
135    #               print "thumb:" + thumb
136    #               print "description:" + description
137    
138    
139                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)
140                  listitem.setProperty('Fanart_Image', fanartImage)                  listitem.setProperty('Fanart_Image', fanartImage)
# Line 99  def buildList(url,title, endlist=True): Line 144  def buildList(url,title, endlist=True):
144                          infoLabels['plot'] = description                                  infoLabels['plot'] = description        
145                          listitem.setInfo('video', infoLabels)                          listitem.setInfo('video', infoLabels)
146    
147                  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)
148                  ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l)                  ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l)
149    
150          if (endlist == True):            if (endlist == True):  
# Line 109  def buildList(url,title, endlist=True): Line 154  def buildList(url,title, endlist=True):
154    
155    
156  def play_video(url, name):  def play_video(url, name):
157          link = open_url(url)          xml = open_url(url)
158          match=re.compile('<url>(.+?)</url>').findall(link)  
159          url = match[0]          doc = parseString(xml)
160            url = getText( doc.getElementsByTagName("url") )
161    
162          print '[TODIC]:'+str(url)          print '[TODIC]:'+str(url)
163          image = xbmc.getInfoImage( 'ListItem.Thumb' )          image = xbmc.getInfoImage( 'ListItem.Thumb' )
164          listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image)          listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image)
 #       listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = 'DefaultVideo.png')  
165          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )
 #       xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem)  
166    
167          player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)          player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)
168          player.play(str(url), listitem)          player.play(str(url), listitem)
169          player.callbackLoop()  #       player.callbackLoop()
170    
171    
172    
# Line 182  def get_params(): Line 227  def get_params():
227                                  param[splitparams[0]]=splitparams[1]                                                                      param[splitparams[0]]=splitparams[1]                                    
228          return param          return param
229    
 params = get_params()  
 url = None  
 name = None  
 mode = None  
230    
231  params = get_params()  params = get_params()
232  url = None  url = None
# Line 223  elif mode == 50: Line 264  elif mode == 50:
264    
265    
266    
 # xbmcplugin.endOfDirectory(int(sys.argv[1]))  
267    

Legend:
Removed from v.1676  
changed lines
  Added in v.1799

  ViewVC Help
Powered by ViewVC 1.1.20