/[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 1676 by torben, Mon Jan 2 20:51:02 2012 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    
24    class TodicPlayer(xbmc.Player):
25            def __init__(self, *args, **kwargs):
26                    #xbmc.Player.__init__(selv,*args,**kwargs)
27                    xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER )
28                    self.stopped = False
29                    self.started = False
30                    print "[TodicPlayer] init"
31    
32    #       @catchall      
33            def onPlayBackStarted(self):
34                    self.started = True
35                    print "[TodicPlayer] : started"
36    #               super.onPlayBackStarted()
37    
38            def onPlayBackStopped(self):
39                    self.stopped = True
40                    print "[TodicPlayer] : stopped"
41    
42            def onPlayBackEnded(self):
43                    self.stopped = True
44                    print "[TodicPlayer] : ended"
45    
46            def callbackLoop(self):
47                    print "[Todic] startLoop"
48                    while (self.stopped == False):
49                            if (self.started == True ):
50                                    print "[todic] " + str(self.getTime())
51                            xbmc.sleep(5000)
52                            
53    
54    
55    
56  def open_url(url):  def open_url(url):
57          req = urllib2.Request(url)          req = urllib2.Request(url)
# Line 25  def open_url(url): Line 61  def open_url(url):
61          return data          return data
62    
63  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)  
64    
65            buildList(__backend__, "", False) # call default list
66    
67            # Adde xtra items to root menu
68          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')
69          u = sys.argv[0] + "?mode=10&name=" + urllib.quote_plus(name)          listitem.setProperty('Fanart_Image', fanartImage)
70          ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l)  
71            u = sys.argv[0] + "?mode=10&name="
72            ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True)
73    
74          xbmcplugin.endOfDirectory(int(sys.argv[1]))          xbmcplugin.endOfDirectory(int(sys.argv[1]))
75    
76    
77  def buildList(url,title):  def buildList(url,title, endlist=True):
78          print '[TODIC]:'+str(url)                  print '[TODIC]:'+str(url)        
79          link = open_url(url)          link = open_url(url)
80          ty=re.compile('<meta type=\'(.+?)\'').findall(link)          ty=re.compile('<meta type=\'(.+?)\'').findall(link)
# Line 56  def buildList(url,title): Line 90  def buildList(url,title):
90          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)
91          l=len(m)          l=len(m)
92          for name,url,thumb,description in m:                                  for name,url,thumb,description in m:                        
                 infoLabels = {}  
                 infoLabels['title'] = name  
                 infoLabels['plot'] = description          
93    
94                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)                  listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb)
95                  listitem.setInfo('video', infoLabels)                  listitem.setProperty('Fanart_Image', fanartImage)
96                    if mode == '50':
97                            infoLabels = {}
98                            infoLabels['title'] = name
99                            infoLabels['plot'] = description        
100                            listitem.setInfo('video', infoLabels)
101    
102                  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)
103                  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)
104          xbmcplugin.endOfDirectory(int(sys.argv[1]))  
105            if (endlist == True):  
106                    xbmcplugin.endOfDirectory(int(sys.argv[1]))
107    
108    
109    
# Line 78  def play_video(url, name): Line 117  def play_video(url, name):
117          listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image)          listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image)
118  #       listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = 'DefaultVideo.png')  #       listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = 'DefaultVideo.png')
119          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )
120          xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem)  #       xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem)
121          xbmc.sleep(200)  
122            player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)
123            player.play(str(url), listitem)
124            player.callbackLoop()
125    
126    
127    
128  def search():  def search():
129          search = getUserInput("Todic Søgning")          search = getUserInput("Todic Søgning")

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

  ViewVC Help
Powered by ViewVC 1.1.20