/[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 2602 by torben, Mon Jul 13 14:51:49 2015 UTC revision 3145 by torben, Wed Nov 23 09:36:57 2016 UTC
# Line 3  Line 3 
3    
4  '''  '''
5      Todic plugin for XBMC      Todic plugin for XBMC
6      Version 0.0.15      Version 0.0.18
7  '''  '''
8    
9  import sys  import sys
# Line 20  import urllib2 Line 20  import urllib2
20  # import pprint  # import pprint
21    
22  from xml.dom.minidom import parseString  from xml.dom.minidom import parseString
23    from time import time
24    
25  __addon__ = xbmcaddon.Addon(id='plugin.video.todic')  __addon__ = xbmcaddon.Addon(id='plugin.video.todic')
26  __key__ = __addon__.getSetting('xbmckey').lower()  __key__ = __addon__.getSetting('xbmckey').lower()
27  __backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__  __backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__
28  fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg')  fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg')
29  datapath = xbmc.translatePath(  datapath = xbmc.translatePath(
30      'special://profile/addon_data/plugin.video.todic/')      'special://profile/addon_data/plugin.video.todic/')
# Line 99  class TodicPlayer(xbmc.Player): Line 100  class TodicPlayer(xbmc.Player):
100          xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER)          xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER)
101          self.stopped = False          self.stopped = False
102          self.started = False          self.started = False
103            self.playingPosition = 0.0
104            self.lastReport = 0
105          print "[TodicPlayer] init"          print "[TodicPlayer] init"
106    
107  #       @catchall  #       @catchall
# Line 107  class TodicPlayer(xbmc.Player): Line 110  class TodicPlayer(xbmc.Player):
110          print "[TodicPlayer] : started"          print "[TodicPlayer] : started"
111  #               super.onPlayBackStarted()  #               super.onPlayBackStarted()
112    
113        #When user presses stop, we report back the the position registered in the last call to self.tick()
114      def onPlayBackStopped(self):      def onPlayBackStopped(self):
115          self.stopped = True          self.stopped = True
116          print "[TodicPlayer] : stopped"          print "[TodicPlayer] : stopped"
117            url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition )
118            open_url_safe(url)
119    
120    
121      def onPlayBackEnded(self):      def onPlayBackEnded(self):
122          self.stopped = True          self.stopped = True
123          print "[TodicPlayer] : ended"          print "[TodicPlayer] : ended"
124            url = __backend__ + "&action=playbacktime&subaction=ended&time="
125            open_url_safe(url)
126    
127      def callbackLoop(self):      def tick(self):
128          print "[Todic] startLoop"          if ( self.isPlaying() ):
129          while (self.stopped == False):              self.playingPosition = self.getTime()
130              if (self.started == True):              now = time()
131                  print "[todic] " + str(self.getTime())              #print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport)
132              xbmc.sleep(5000)              if ( (now - self.lastReport) > 60.0):
133                    self.reportPlaytime()
134                    self.lastReport = now
135                
136    
137    
138        def reportPlaytime(self):
139            url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition )
140            open_url_safe(url)
141            print "[Todic] reportPlaytime:" + url
142                    
143    
144    
145  def getText2(nodelist):  def getText2(nodelist):
# Line 143  def getText(nodelist): Line 162  def getText(nodelist):
162              return nodelist[0].childNodes[0].nodeValue              return nodelist[0].childNodes[0].nodeValue
163    
164    
165    
166  def SaveFile(path, data):  def SaveFile(path, data):
167      file = open(path, 'w')      file = open(path, 'w')
168      file.write(data)      file.write(data)
169      file.close()      file.close()
170    
171    
172    
173  def open_url(url):  def open_url(url):
174      req = urllib2.Request(url)      req = urllib2.Request(url)
175      content = urllib2.urlopen(req)      content = urllib2.urlopen(req)
# Line 157  def open_url(url): Line 178  def open_url(url):
178      return data      return data
179    
180    
181    # wraps open url in a catch-all exception handler
182    # usefull for periodic back-reporting that should not interrupt the program flow
183    def open_url_safe(url):
184        try:
185            return open_url(url)
186        except:
187            print "Some error during open_url call to ", url
188    
189    
190    
191  def rootMenu():  def rootMenu():
192    
193      msg = open_url(__backend__ + "&action=messages")      msg = open_url(__backend__ + "&action=messages")
# Line 300  def play_real_video(url, name): Line 331  def play_real_video(url, name):
331          else:          else:
332              player.disableSubtitles()              player.disableSubtitles()
333    
334            #Holder python kørernde indtil at det bliver bedt om at stoppe
335            while (not xbmc.abortRequested):
336                    player.tick()
337                    xbmc.sleep(100)
338    
339    
340    
341  #       player.callbackLoop()  #       player.callbackLoop()
342    
343    

Legend:
Removed from v.2602  
changed lines
  Added in v.3145

  ViewVC Help
Powered by ViewVC 1.1.20