/[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 1917 by torben, Fri Jan 18 11:36:20 2013 UTC revision 2594 by torben, Mon Jun 29 20:07:17 2015 UTC
# Line 3  Line 3 
3    
4  '''  '''
5      Todic plugin for XBMC      Todic plugin for XBMC
6      Version 0.0.2      Version 0.0.14
7  '''  '''
8    
9  import sys  import sys
# Line 23  from xml.dom.minidom import parseString Line 23  from xml.dom.minidom import parseString
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()
25  __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__  __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__
26  fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'fanart.jpg')  fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg')
27  datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/')  datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/')
28    
29    ADDON_PATH = __addon__.getAddonInfo('path')
30    SkinMasterPath = os.path.join(ADDON_PATH, 'skins' ) + '/'
31    MySkinPath = (os.path.join(SkinMasterPath, '720p')) + '/'
32    MySkin = 'main.xml'
33    
34    
35    class TodicMovieDialog(xbmcgui.WindowXMLDialog):
36            def __new__(cls):
37                    return super(TodicMovieDialog, cls).__new__(cls, "main.xml", ADDON_PATH)
38    
39            def __init__(self):
40                    super(TodicMovieDialog, self).__init__()
41    
42            def onClick( self, controlId ):
43                    print "OnClick: " + str(controlId)
44            
45                    if (controlId == 50):
46                            self.close()
47                            play_real_video(self.url, self.name)
48    
49                    if ( controlId == 98 ):
50                            self.close()
51    
52    
53            def onInit(self):
54    
55                    print "ONINIT"
56                    self.getControl( 1 ).setLabel( self.name);
57                    self.getControl( 2 ).setLabel( self.description );
58    
59            def setUrl( self, url):
60                    self.url = url
61    
62            def setName( self, name ):
63                    self.name = name
64    
65            def setDescription( self, description ):
66                    self.description = description
67    
68    
69  class TodicPlayer(xbmc.Player):  class TodicPlayer(xbmc.Player):
70          def __init__(self, *args, **kwargs):          def __init__(self, *args, **kwargs):
# Line 106  def rootMenu(): Line 145  def rootMenu():
145          u = sys.argv[0] + "?mode=10&name="          u = sys.argv[0] + "?mode=10&name="
146          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)
147    
148            #add search series
149            listitem = xbmcgui.ListItem(label = "Søg Serier ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png')
150            listitem.setProperty('Fanart_Image', fanartImage)
151    
152            u = sys.argv[0] + "?mode=11&name="
153            ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True)
154    
155          xbmcplugin.endOfDirectory(int(sys.argv[1]))          xbmcplugin.endOfDirectory(int(sys.argv[1]))
156    
157    
# Line 139  def buildList(url,title, endlist=True): Line 185  def buildList(url,title, endlist=True):
185                          playcount = '0'                          playcount = '0'
186                  playcount = int(playcount)                  playcount = int(playcount)
187    
                 name = name.encode('latin-1')  
                 description = description.encode('latin-1')  
188    
189  ##              print "name:" + name  ##              print "name:" + name
190  #               print "url:" + url  #               print "url:" + url
# Line 157  def buildList(url,title, endlist=True): Line 201  def buildList(url,title, endlist=True):
201                          infoLabels['playcount'] = playcount                          infoLabels['playcount'] = playcount
202                          listitem.setInfo('video', infoLabels)                          listitem.setInfo('video', infoLabels)
203    
204                  u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url)                  name = name.encode('UTF-8')
205                    description = description.encode('UTF-8')
206    
207    
208                    u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description)
209                  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)
210    
211          if (endlist == True):            if (endlist == True):  
# Line 166  def buildList(url,title, endlist=True): Line 214  def buildList(url,title, endlist=True):
214    
215    
216    
217  def play_video(url, name):  def play_video(url, name,description):
218          xml = open_url(url)          if (description == None or description == ""):
219                    play_real_video(url,name)
220            else:
221                    d = TodicMovieDialog()
222                    d.setUrl( url)
223                    d.setName( name )
224                    d.setDescription( description )
225    
226                    d.doModal()
227    
228    
229    def play_real_video(url, name):
230            xml = open_url(url)
231          print 'TODIC url: ' + str(url)          print 'TODIC url: ' + str(url)
232          print 'TODIC xml: '+ xml          print 'TODIC xml: '+ xml
233    
# Line 227  def search(): Line 287  def search():
287    
288                  buildList(url, "søgning")                  buildList(url, "søgning")
289    
290    def searchSeries():
291            search = getUserInput("Todic Serie Søgning")
292    
293            if (search != None and search != ""):
294                    url = __backend__ + "&action=searchseries&search=" + urllib.quote_plus(search)
295    
296                    #print "[TODIC] Search start: " + search
297                    #print "[TODIC] Search url: " + url
298    
299                    buildList(url, "serie søgning")
300    
301                    
302    
303    
# Line 278  params = get_params() Line 349  params = get_params()
349  url = None  url = None
350  name = None  name = None
351  mode = None  mode = None
352    description = None
353    
354  try:  try:
355          url = urllib.unquote_plus(params["url"])          url = urllib.unquote_plus(params["url"])
# Line 291  try: Line 363  try:
363          mode = int(params["mode"])          mode = int(params["mode"])
364  except:  except:
365          pass          pass
366    try:
367            description = urllib.unquote_plus(params["description"])
368    except:
369            pass
370    
371    try:
372            open_url("http://todic.dk")
373    except:
374            showMessage("Fejl", "Kunne ikke forbinde til todic.dk")
375            exit()
376                            
377    
378  if url == 'refresh':  if url == 'refresh':
379          xbmc.output("[tvserver] Container.Refresh")          #xbmc.output("[tvserver] Container.Refresh") #20130418 xbmc.output virker ikke med XBMC12
380          xbmc.executebuiltin("Container.Refresh")          xbmc.executebuiltin("Container.Refresh")
381                    
382    
# Line 307  elif mode == 1: Line 390  elif mode == 1:
390    
391  elif mode == 10:  elif mode == 10:
392          search()          search()
393    
394    elif mode == 11:
395            searchSeries()
396                    
397    
398  elif mode == 50:  elif mode == 50:
399          play_video(url, name)          play_video(url, name, description)
400    
401    
402    

Legend:
Removed from v.1917  
changed lines
  Added in v.2594

  ViewVC Help
Powered by ViewVC 1.1.20