/[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 1829 by torben, Sun Aug 19 17:22:41 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)  
122          l=len(m)          entries = doc.getElementsByTagName("entry")
123          for name,url,thumb,description in m:                                  l=len(entries)
124            description = ''
125            for entry in entries:
126                    name =  getText( entry.getElementsByTagName("title") )
127                    url =  getText( entry.getElementsByTagName("url") )
128                    thumb = getText( entry.getElementsByTagName("cover") )
129                    description = getText( entry.getElementsByTagName("description") )
130                    playcount = getText( entry.getElementsByTagName("playcount") )
131    
132                    name = name.encode('latin-1')
133                    description = description.encode('latin-1')
134    
135    ##              print "name:" + name
136    #               print "url:" + url
137    #               print "thumb:" + thumb
138    #               print "description:" + description
139    
140    
141                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)
142                  listitem.setProperty('Fanart_Image', fanartImage)                  listitem.setProperty('Fanart_Image', fanartImage)
143                  if mode == '50':                  if mode == '50':
144                          infoLabels = {}                          infoLabels = {}
145                          infoLabels['title'] = name                          infoLabels['title'] = name
146                          infoLabels['plot'] = description                                  infoLabels['plot'] = description
147                            infoLabels['playcount'] = playcount
148                          listitem.setInfo('video', infoLabels)                          listitem.setInfo('video', infoLabels)
149    
150                  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)
151                  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)
152    
153          if (endlist == True):            if (endlist == True):  
# Line 109  def buildList(url,title, endlist=True): Line 157  def buildList(url,title, endlist=True):
157    
158    
159  def play_video(url, name):  def play_video(url, name):
160          link = open_url(url)          xml = open_url(url)
161          match=re.compile('<url>(.+?)</url>').findall(link)  
162          url = match[0]          doc = parseString(xml)
163            url = getText( doc.getElementsByTagName("url") )
164    
165          print '[TODIC]:'+str(url)          print '[TODIC]:'+str(url)
166          image = xbmc.getInfoImage( 'ListItem.Thumb' )          image = xbmc.getInfoImage( 'ListItem.Thumb' )
167          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')  
168          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )
 #       xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem)  
169    
170          player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)          player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)
171          player.play(str(url), listitem)          player.play(str(url), listitem)
172          player.callbackLoop()  #       player.callbackLoop()
173    
174    
175    
# Line 182  def get_params(): Line 230  def get_params():
230                                  param[splitparams[0]]=splitparams[1]                                                                      param[splitparams[0]]=splitparams[1]                                    
231          return param          return param
232    
 params = get_params()  
 url = None  
 name = None  
 mode = None  
233    
234  params = get_params()  params = get_params()
235  url = None  url = None
# Line 205  try: Line 249  try:
249  except:  except:
250          pass          pass
251    
252    if url == 'refresh':
253            xbmc.output("[tvserver] Container.Refresh")
254            xbmc.executebuiltin("Container.Refresh")
255            
256    
257  if mode == None:  elif mode == None:
258          #build main menu          #build main menu
259          rootMenu()          rootMenu()
260                
# Line 223  elif mode == 50: Line 271  elif mode == 50:
271    
272    
273    
 # xbmcplugin.endOfDirectory(int(sys.argv[1]))  
274    

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

  ViewVC Help
Powered by ViewVC 1.1.20