/[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 1830 by torben, Sun Aug 19 20:41:20 2012 UTC revision 1921 by torben, Wed Jan 30 07:26:42 2013 UTC
# Line 3  Line 3 
3    
4  '''  '''
5      Todic plugin for XBMC      Todic plugin for XBMC
6      Version 0.0.2      Version 0.0.7
7  '''  '''
8    
9  import sys  import sys
# Line 24  __addon__ = xbmcaddon.Addon(id='plugin.v Line 24  __addon__ = xbmcaddon.Addon(id='plugin.v
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'), 'fanart.jpg')
27    datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/')
28    
29    
30  class TodicPlayer(xbmc.Player):  class TodicPlayer(xbmc.Player):
# Line 74  def getText(nodelist): Line 75  def getText(nodelist):
75                  else:                  else:
76                          return nodelist[0].childNodes[0].nodeValue                          return nodelist[0].childNodes[0].nodeValue
77    
78    def SaveFile(path, data):
79            file = open(path,'w')
80            file.write(data)
81            file.close()
82    
83    
84  def open_url(url):  def open_url(url):
85          req = urllib2.Request(url)          req = urllib2.Request(url)
# Line 104  def rootMenu(): Line 110  def rootMenu():
110    
111    
112  def buildList(url,title, endlist=True):  def buildList(url,title, endlist=True):
113          print '[TODIC]:'+str(url)                  print '[TODIC]:'+str(url)
114    
115          link = open_url(url)          link = open_url(url)
116          doc = parseString(link)          doc = parseString(link)
# Line 162  def buildList(url,title, endlist=True): Line 168  def buildList(url,title, endlist=True):
168    
169  def play_video(url, name):  def play_video(url, name):
170          xml = open_url(url)          xml = open_url(url)
171            print 'TODIC url: ' + str(url)
172            print 'TODIC xml: '+ xml
173    
174          doc = parseString(xml)          doc = parseString(xml)
175          url = getText( doc.getElementsByTagName("url") )          url = getText( doc.getElementsByTagName("url") )
176    
177          print '[TODIC]:'+str(url)          subtitleurl = getText( doc.getElementsByTagName("subtitles") )
178            subtitlesfile = os.path.join(datapath,'temp.srt')
179    
180            #if old srt file exists delete it first
181            if os.path.isfile(subtitlesfile):
182                    os.unlink(subtitlesfile)
183    
184            print '[TODIC] subs: '+str(subtitleurl)
185            if len(subtitleurl) > 0:
186                    subtitles = open_url(subtitleurl)
187                    SaveFile(subtitlesfile, subtitles)
188                    print 'TODIC downloaded subtitles'
189    
190    
191    
192          image = xbmc.getInfoImage( 'ListItem.Thumb' )          image = xbmc.getInfoImage( 'ListItem.Thumb' )
193          listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image)          listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image)
194          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )          listitem.setInfo( type = "Video", infoLabels={ "Title": name } )
195    
196          player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)          player = TodicPlayer(xbmc.PLAYER_CORE_AUTO)
197          player.play(str(url), listitem)          player.play(str(url), listitem)
198    
199            #kan ikke loade subtitles hvis foerend playeren koerer
200            count = 0
201            while not xbmc.Player().isPlaying():
202                    xbmc.sleep(500)
203                    count += 1
204                    if count > 10:
205                            break
206    
207    
208            if xbmc.Player().isPlaying():
209                    if os.path.isfile(subtitlesfile):
210                            player.setSubtitles(subtitlesfile)
211                            print 'TODIC started subtitles'
212                    else:
213                            player.disableSubtitles()
214    
215  #       player.callbackLoop()  #       player.callbackLoop()
216    
217    

Legend:
Removed from v.1830  
changed lines
  Added in v.1921

  ViewVC Help
Powered by ViewVC 1.1.20