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

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

  ViewVC Help
Powered by ViewVC 1.1.20