/[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 1647 by torben, Sat Dec 3 13:53:47 2011 UTC revision 1659 by torben, Mon Dec 12 17:50:21 2011 UTC
# Line 5  Line 5 
5    
6  import sys  import sys
7  import cgi as urlparse  import cgi as urlparse
8    import os
9    
10    
11  import xbmc  import xbmc
12  import xbmcaddon  import xbmcaddon
# Line 16  import urllib2, re Line 18  import urllib2, re
18  __addon__ = xbmcaddon.Addon(id='plugin.video.todic')  __addon__ = xbmcaddon.Addon(id='plugin.video.todic')
19  __key__ = __addon__.getSetting('xbmckey').lower()  __key__ = __addon__.getSetting('xbmckey').lower()
20  __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__  __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__
21    fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'fanart.jpg')
22    
23  def open_url(url):  def open_url(url):
24          req = urllib2.Request(url)          req = urllib2.Request(url)
# Line 25  def open_url(url): Line 28  def open_url(url):
28          return data          return data
29    
30  def rootMenu():  def rootMenu():
         link = open_url(__backend__)  
         m=re.compile('<title>(.+?)</title><url>(.+?)</url>').findall(link)  
         l = len(m)  
         for name,url in m:  
                 listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')  
                 u = sys.argv[0] + "?mode=1&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url)  
                 ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l)  
31    
32            buildList(__backend__, "", False) # call default list
33    
34            # Adde xtra items to root menu
35          listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')          listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')
36          u = sys.argv[0] + "?mode=10&name=" + urllib.quote_plus(name)          listitem.setProperty('Fanart_Image', fanartImage)
37          ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l)  
38            u = sys.argv[0] + "?mode=10&name="
39            ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True)
40    
41          xbmcplugin.endOfDirectory(int(sys.argv[1]))          xbmcplugin.endOfDirectory(int(sys.argv[1]))
42    
43    
44  def buildList(url,title):  def buildList(url,title, endlist=True):
45          print '[TODIC]:'+str(url)                  print '[TODIC]:'+str(url)        
46          link = open_url(url)          link = open_url(url)
47          ty=re.compile('<meta type=\'(.+?)\'').findall(link)          ty=re.compile('<meta type=\'(.+?)\'').findall(link)
# Line 56  def buildList(url,title): Line 57  def buildList(url,title):
57          m=re.compile('<title>(.+?)</title><url>(.+?)</url><cover>(.+?)</cover><description>(.*)</description>').findall(link)          m=re.compile('<title>(.+?)</title><url>(.+?)</url><cover>(.+?)</cover><description>(.*)</description>').findall(link)
58          l=len(m)          l=len(m)
59          for name,url,thumb,description in m:                                  for name,url,thumb,description in m:                        
                 infoLabels = {}  
                 infoLabels['title'] = name  
                 infoLabels['plot'] = description          
60    
61                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)
62                  listitem.setInfo('video', infoLabels)                  listitem.setProperty('Fanart_Image', fanartImage)
63                    if mode == '50':
64                            infoLabels = {}
65                            infoLabels['title'] = name
66                            infoLabels['plot'] = description        
67                            listitem.setInfo('video', infoLabels)
68    
69                  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_plus(mode) + "&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url)
70                  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)
71          xbmcplugin.endOfDirectory(int(sys.argv[1]))  
72            if (endlist == True):  
73                    xbmcplugin.endOfDirectory(int(sys.argv[1]))
74    
75    
76    

Legend:
Removed from v.1647  
changed lines
  Added in v.1659

  ViewVC Help
Powered by ViewVC 1.1.20