/[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 1630 by torben, Sun Nov 27 11:05:43 2011 UTC revision 1648 by torben, Sun Dec 4 14:40:44 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 30  def rootMenu(): Line 33  def rootMenu():
33          l = len(m)          l = len(m)
34          for name,url in m:          for name,url in m:
35                  listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')                  listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')
36                    listitem.setProperty('Fanart_Image', fanartImage)
37    
38                  u = sys.argv[0] + "?mode=1&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url)                  u = sys.argv[0] + "?mode=1&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url)
39                  ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l)                  ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l)
40    
41            listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')
42            listitem.setProperty('Fanart_Image', fanartImage)
43    
44            u = sys.argv[0] + "?mode=10&name=" + urllib.quote_plus(name)
45            ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l)
46    
47          xbmcplugin.endOfDirectory(int(sys.argv[1]))          xbmcplugin.endOfDirectory(int(sys.argv[1]))
48    
49    
# Line 39  def buildList(url,title): Line 51  def buildList(url,title):
51          print '[TODIC]:'+str(url)                  print '[TODIC]:'+str(url)        
52          link = open_url(url)          link = open_url(url)
53          ty=re.compile('<meta type=\'(.+?)\'').findall(link)          ty=re.compile('<meta type=\'(.+?)\'').findall(link)
54          print '[TOD]'+str(ty[0])          print '[TODIC]'+str(ty[0])
55          m=re.compile('<title>(.+?)</title><url>(.+?)</url><cover>(.+?)</cover>').findall(link)  
56            if ty[0] == 'clipList':
57                    mode = '50'
58                    folder = False
59            else:
60                    mode = '1'
61                    folder = True
62    
63            m=re.compile('<title>(.+?)</title><url>(.+?)</url><cover>(.+?)</cover><description>(.*)</description>').findall(link)
64          l=len(m)          l=len(m)
65          for name,url,thumb in m:          for name,url,thumb,description in m:                        
66                  if ty[0] == 'clipList':                  infoLabels = {}
67                          mode = '50'                  infoLabels['title'] = name
68                          folder = False                  infoLabels['plot'] = description        
69                  else:  
70                          mode = '2'                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)
71                          folder = True                  listitem.setInfo('video', infoLabels)
72                                            listitem.setProperty('Fanart_Image', fanartImage)
73                  listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = thumb)  
74                  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)
75                  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)
76          xbmcplugin.endOfDirectory(int(sys.argv[1]))          xbmcplugin.endOfDirectory(int(sys.argv[1]))
77    
 def buildSubList(url,title):  
         print '[TODIC]:'+str(url)  
         link = open_url(url)  
         m=re.compile('<title>(.+?)</title><url>(.+?)</url><cover>(.+?)</cover>').findall(link)  
         l = len(m)  
         for name,url,thumb in m:  
                 listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = thumb)  
                 u = sys.argv[0] + "?mode=50&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url)  
                 ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = False, totalItems = l)  
         xbmcplugin.endOfDirectory(int(sys.argv[1]))  
78    
79    
80    
# Line 80  def play_video(url, name): Line 90  def play_video(url, name):
90          xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem)          xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem)
91          xbmc.sleep(200)          xbmc.sleep(200)
92    
93    def search():
94            search = getUserInput("Todic Søgning")
95    
96            if (search != None and search != ""):
97                    url = __backend__ + "&action=search&search=" + urllib.quote_plus(search)
98    
99                    #print "[TODIC] Search start: " + search
100                    #print "[TODIC] Search url: " + url
101    
102                    buildList(url, "søgning")
103    
104            
105    
106    
107                    
108    #=================================== Tool Box =======================================
109    # shows a more userfriendly notification
110    def showMessage(heading, message):
111            duration = 15*1000
112            xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % ( heading, message, duration) )
113    
114    
115    # raise a keyboard for user input
116    def getUserInput(title = "Input", default="", hidden=False):
117            result = None
118    
119            # Fix for when this functions is called with default=None
120            if not default:
121                    default = ""
122                            
123            keyboard = xbmc.Keyboard(default, title)
124            keyboard.setHiddenInput(hidden)
125            keyboard.doModal()
126                    
127            if keyboard.isConfirmed():
128                    result = keyboard.getText()
129                    
130            return result
131    
132    
133  def get_params():  def get_params():
134          param=[]          param=[]
# Line 130  elif mode == 1: Line 179  elif mode == 1:
179          #build list of movie starting letters          #build list of movie starting letters
180          buildList(url, name)          buildList(url, name)
181    
182  elif mode == 2:  elif mode == 10:
183          #build list of series                  search()
184          buildSubList(url, name)          
185    
186  elif mode == 50:  elif mode == 50:
187          play_video(url, name)          play_video(url, name)
188    
189    
190    
191  xbmcplugin.endOfDirectory(int(sys.argv[1]))  # xbmcplugin.endOfDirectory(int(sys.argv[1]))
192    

Legend:
Removed from v.1630  
changed lines
  Added in v.1648

  ViewVC Help
Powered by ViewVC 1.1.20