Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [178bf1] Maximize Restore History

[plugin.video.irishtv] updated to version 2.0.14

sphere sphere 2014-03-24

changed plugin.video.irishtv/resources/language/English/strings.po
changed plugin.video.irishtv/resources/language/English/strings.xml
changed plugin.video.irishtv/resources/settings.xml
changed plugin.video.irishtv/addon.xml
changed plugin.video.irishtv/aertv.py
changed plugin.video.irishtv/brightcove.py
changed plugin.video.irishtv/changelog.txt
changed plugin.video.irishtv/default.py
changed plugin.video.irishtv/httpmanager.py
changed plugin.video.irishtv/provider.py
changed plugin.video.irishtv/rte.py
changed plugin.video.irishtv/tg4.py
changed plugin.video.irishtv/tv3.py
changed plugin.video.irishtv/utils.py
copied plugin.video.irishtv/player.py -> plugin.video.irishtv/irishtvplayer.py
plugin.video.irishtv/resources/language/English/strings.po Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/resources/language/English/strings.xml Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/resources/settings.xml Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/addon.xml Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/aertv.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/brightcove.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/changelog.txt Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/default.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/httpmanager.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/provider.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/rte.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/tg4.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/tv3.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/utils.py Diff Switch to side-by-side view
Loading...
plugin.video.irishtv/player.py to plugin.video.irishtv/irishtvplayer.py
--- a/plugin.video.irishtv/player.py
+++ b/plugin.video.irishtv/irishtvplayer.py
@@ -1,33 +1,55 @@
 import os
 import sys
 import re
+import time
+
+if os.environ.get( "OS" ) != "xbox":
+    import threading
+
+import xbmc
+import xbmcgui
+import xbmcplugin
 
 from loggingexception import LoggingException
 
-if hasattr(sys.modules["__main__"], "xbmc"):
-    xbmc = sys.modules["__main__"].xbmc
-else:
-    import xbmc
-
-if hasattr(sys.modules["__main__"], "xbmcgui"):
-    xbmcgui = sys.modules["__main__"].xbmcgui
-else:
-    import xbmcgui
-
-if hasattr(sys.modules["__main__"], "xbmcplugin"):
-    xbmcplugin = sys.modules["__main__"].xbmcplugin
-else:
-    import xbmcplugin
-
 import utils
 
 class PlayerLockException(LoggingException):
     """
-    Exception raised when IPlayer fails to obtain a resume lock
+    Exception raised when IrishTVPlayer fails to obtain a resume lock
     """
     pass
 
-class IrishTVPlayer(xbmc.Player):
+class BasePlayer(xbmc.Player):
+    #def __init__( self ):
+    #    pass
+    
+    def load_resume_file():
+        pass
+
+    @staticmethod
+    def delete_resume_point(pid_to_delete):
+        pass
+
+    def resume_and_play( self, url, listitem, is_tv, playresume=False ):
+        self.playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
+        self.playlist.clear()
+        self.playlist.add(url, listitem)
+        self.play(self.playlist)
+
+    def get_playlist(self):
+        return self.playlist
+    
+    def set_cancelled( self ):
+        pass 
+    
+
+"""
+class IrishTVPlayer(BasePlayer):
+    def __init__( self, pid, live ):
+        a = 0
+"""
+class IrishTVPlayer(BasePlayer):
     """
     An XBMC player object, for supporting Irish TV plugin features during playback
     """
@@ -39,47 +61,43 @@
     resume = None
     dates_added = None
 
-    def __init__( self, pid, live ):
-        if hasattr(sys.modules["__main__"], "log"):
-            self.log = sys.modules["__main__"].log
-        else:
-            from utils import log
-            self.log = log
-
-            self.log("")
-
-        self.log("%s: IrishTVPlayer initialised (core_player: %d, pid: %s, live: %s)" % (self, pid, live), xbmc.LOGINFO)
+    #def __init__( self, pid, live ):
+    def init( self, pid, live ):
+        xbmc.log(u"%s: IrishTVPlayer initialised (pid: %s, live: %s)" % (self, pid, live), xbmc.LOGINFO)
         self.paused = False
         self.live = live
         self.pid = pid
-        if os.environ.get( "OS" ) != "xbox":
+        if os.environ.get( u"OS" ) != u"xbox":
             self.cancelled = threading.Event()
         if live:
             # Live feed - no resume
             # Setup scheduling?
             pass
         else:
-            if os.environ.get( "OS" ) != "xbox":
+            if os.environ.get( u"OS" ) != u"xbox":
                 # Acquire the resume lock, store the pid and load the resume file
                 self._acquire_lock()
 
+    def set_cancelled( self ):
+        self.cancelled.set()
+
     def __del__( self ):
-        self.log("%s: De-initialising..." % self, xbmc.LOGINFO)
+        xbmc.log(u"%s: De-initialising..." % self, xbmc.LOGINFO)
         # If resume is enabled, try to release the resume lock
-        if os.environ.get( "OS" ) != "xbox":
+        if os.environ.get( u"OS" ) != u"xbox":
             if not self.live:
                 try: self.heartbeat.cancel()
-                except: self.log('%s: No heartbeat on destruction' % self, xbmc.LOGWARNING)
+                except: xbmc.log(u'%s: No heartbeat on destruction' % self, xbmc.LOGWARNING)
                 self._release_lock()
             # Refresh container to ensure '(resumeable)' is added if necessary
-            xbmc.executebuiltin('Container.Refresh')
+            xbmc.executebuiltin(u'Container.Refresh')
 
 
     def _acquire_lock( self ):
         if os.path.isfile(IrishTVPlayer.RESUME_LOCK_FILE):
-            raise PlayerLockException("Only one instance of IrishTVPlayer can be run at a time. Please stop any other streams you may be watching before opening a new stream")
+            raise PlayerLockException(u"Only one instance of Irish TV Player can be run at a time. Please stop any other streams you may be watching before opening a new stream")
         else:
-            lock_fh = open(IrishTVPlayer.RESUME_LOCK_FILE, 'w')
+            lock_fh = open(IrishTVPlayer.RESUME_LOCK_FILE, u'w')
             try:
                 lock_fh.write("%s" % self)
             finally:
@@ -89,18 +107,21 @@
         self_has_lock = False
         lock_fh = open(IrishTVPlayer.RESUME_LOCK_FILE)
         try:
-            self_has_lock = (lock_fh.read() == "%s" % self)
+            self_has_lock = (lock_fh.read() == u"%s" % self)
         finally:
             lock_fh.close()
 
-        xbmc.log("Lock owner test: %s" % self_has_lock, level=xbmc.LOGDEBUG)
+        xbmc.log(u"Lock owner test: %s" % self_has_lock, level=xbmc.LOGDEBUG)
         if self_has_lock:
-            self.log("%s: Removing lock file." % self, xbmc.LOGINFO)
+            xbmc.log(u"%s: Removing lock file." % self, xbmc.LOGINFO)
             try:
                 os.remove(IrishTVPlayer.RESUME_LOCK_FILE)
             except Exception, e:
-                l("Error removing IrishTVPlayer resume lock file! (%s)" % e, xbmc.LOGWARNING)
-
+                xbmc.log(u"Error removing IrishTVPlayer resume lock file! (%s)" % e, xbmc.LOGWARNING)
+
+    def set_cancelled( self ):
+        self.cancelled.set() 
+    
     @staticmethod
     def force_release_lock():
         """
@@ -110,60 +131,62 @@
         try:
             os.remove(IrishTVPlayer.RESUME_LOCK_FILE)
             dialog = xbmcgui.Dialog()
-            dialog.ok('Lock released', 'Successfully released lock')
+            dialog.ok(u'Lock released', u'Successfully released lock')
         except:
             dialog = xbmcgui.Dialog()
-            dialog.ok('Failed to force release lock', 'Failed to release lock')
+            dialog.ok(u'Failed to force release lock', u'Failed to release lock')
 
     def run_heartbeat( self ):
         """
         Method is run every second to perform housekeeping tasks, e.g. updating the current seek time of the player.
         Heartbeat will continue until player stops playing.
         """
-        xbmc.log("%s: Heartbeat %d" % (self, time.time()), level=xbmc.LOGDEBUG)
+        xbmc.log(u"%s: Heartbeat %d" % (self, time.time()), level=xbmc.LOGDEBUG)
         self.heartbeat = threading.Timer(1.0, self.run_heartbeat)
         self.heartbeat.setDaemon(True)
         self.heartbeat.start()
         if not self.live and not self.cancelled.is_set():
             self.current_seek_time = self.getTime()
-            xbmc.log("%s IrishTVPlayer: current_seek_time %s" % (self, self.current_seek_time), level=xbmc.LOGDEBUG)
+            xbmc.log(u"%s IrishTVPlayer: current_seek_time %s" % (self, self.current_seek_time), level=xbmc.LOGDEBUG)
         elif self.cancelled.is_set():
             self.onPlayBackEnded()
 
     def onPlayBackStarted( self ):
         # Will be called when xbmc starts playing the stream
-        self.log( "%s: Begin playback of pid %s" % (self, self.pid), xbmc.LOGINFO )
+        xbmc.log( u"%s: Begin playback of pid %s" % (self, self.pid), xbmc.LOGINFO )
         self.paused = False
-        if os.environ.get( "OS" ) != "xbox":
+        if os.environ.get( u"OS" ) != u"xbox":
             self.run_heartbeat()
 
     def onPlayBackEnded( self ):
         # Will be called when xbmc stops playing the stream
         if self.heartbeat: self.heartbeat.cancel()
-        self.log( "%s: Playback ended." % self, xbmc.LOGINFO)
-        if os.environ.get( "OS" ) != "xbox":
-            if not self.live:
-                self.log( "%s: Saving resume point for pid %s at %fs." % (self, self.pid, self.current_seek_time), xbmc.LOGINFO )
-                self.save_resume_point( self.current_seek_time )
+        xbmc.log( u"%s: Playback ended." % self, xbmc.LOGINFO)
+        if os.environ.get( u"OS" ) != u"xbox":
+            if not self.live:
+                ##xbmc.log( u"%s: Saving resume point for pid %s at %fs." % (self, self.pid, self.current_seek_time), xbmc.LOGINFO )
+                x = self
+                y = x.current_seek_time
+                x.save_resume_point( y )
         self.__del__()
 
     def onPlayBackStopped( self ):
         if self.heartbeat: self.heartbeat.cancel()
         # Will be called when user stops xbmc playing the stream
         # The player needs to be unloaded to release the resume lock
-        self.log( "%s: Playback stopped." % self, xbmc.LOGINFO)
-        if os.environ.get( "OS" ) != "xbox":
-            if not self.live:
-                self.log("%s: Saving resume point for pid %s at %fs." % (self, self.pid, self.current_seek_time), xbmc.LOGINFO )
+        xbmc.log( u"%s: Playback stopped." % self, xbmc.LOGINFO)
+        if os.environ.get( u"OS" ) != u"xbox":
+            if not self.live:
+                xbmc.log(u"%s: Saving resume point for pid %s at %fs." % (self, self.pid, self.current_seek_time), xbmc.LOGINFO )
                 self.save_resume_point( self.current_seek_time )
         self.__del__()
 
     def onPlayBackPaused( self ):
         # Will be called when user pauses playback on a stream
-        self.log( "%s: Playback paused." % self, xbmc.LOGINFO)
-        if os.environ.get( "OS" ) != "xbox":
-            if not self.live:
-                self.log("%s: Saving resume point for pid %s at %fs." % (self, self.pid, self.getTime()), xbmc.LOGINFO )
+        xbmc.log( u"%s: Playback paused." % self, xbmc.LOGINFO)
+        if os.environ.get( u"OS" ) != u"xbox":
+            if not self.live:
+                xbmc.log(u"%s: Saving resume point for pid %s at %fs." % (self, self.pid, self.getTime()), xbmc.LOGINFO )
                 self.save_resume_point( self.current_seek_time )
         self.paused = True
 
@@ -174,7 +197,7 @@
         resume, dates_added = IrishTVPlayer.load_resume_file()
         resume[self.pid] = resume_point
         dates_added[self.pid] = time.time()
-        self.log("%s: Saving resume point (pid %s, seekTime %fs, dateAdded %d) to resume file" % (self, self.pid, resume[self.pid], dates_added[self.pid]), xbmc.LOGINFO)
+        xbmc.log(u"%s: Saving resume point (pid %s, seekTime %fs, dateAdded %d) to resume file" % (self, self.pid, resume[self.pid], dates_added[self.pid]), xbmc.LOGINFO)
         IrishTVPlayer.save_resume_file(resume, dates_added)
 
     @staticmethod
@@ -192,7 +215,7 @@
             IrishTVPlayer.resume = {}
             IrishTVPlayer.dates_added = {}
             if os.path.isfile(IrishTVPlayer.RESUME_FILE):
-                self.log("IrishTVPlayer: Loading resume file: %s" % (IrishTVPlayer.RESUME_FILE), xbmc.LOGINFO)
+                xbmc.log(u"IrishTVPlayer: Loading resume file: %s" % (IrishTVPlayer.RESUME_FILE), xbmc.LOGINFO)
                 with open(IrishTVPlayer.RESUME_FILE, 'rU') as resume_fh:
                     resume_str = resume_fh.read()
                 tokens = resume_str.split()
@@ -203,7 +226,7 @@
                 pid_to_resume_point_map = []
                 pid_to_date_added_map = []
                 # if row was added less than days_to_keep days ago, add it to valid_mappings
-                try: days_to_keep = int(__addon__.getSetting('resume_days_to_keep'))
+                try: days_to_keep = int(__addon__.getSetting(u'resume_days_to_keep'))
                 except: days_to_keep = 40
                 limit_time = time.time() - 60*60*24*days_to_keep
                 for i in range(len(pids)):
@@ -212,13 +235,13 @@
                         pid_to_date_added_map.append( (pids[i], datesAdded[i]) )
                 IrishTVPlayer.resume = dict(pid_to_resume_point_map)
                 IrishTVPlayer.dates_added = dict(pid_to_date_added_map)
-                self.log("IrishTVPlayer: Found %d resume entries" % (len(IrishTVPlayer.resume.keys())), xbmc.LOGINFO)
+                xbmc.log(u"IrishTVPlayer: Found %d resume entries" % (len(IrishTVPlayer.resume.keys())), xbmc.LOGINFO)
                 
         return IrishTVPlayer.resume, IrishTVPlayer.dates_added
 
     @staticmethod
     def delete_resume_point(pid_to_delete):
-        self.log("IrishTVPlayer: Deleting resume point for pid %s" % pid_to_delete, xbmc.LOGINFO)
+        xbmc.log(u"IrishTVPlayer: Deleting resume point for pid %s" % pid_to_delete, xbmc.LOGINFO)
         resume, dates_added = IrishTVPlayer.load_resume_file()
         del resume[pid_to_delete]
         del dates_added[pid_to_delete]
@@ -233,12 +256,12 @@
         IrishTVPlayer.resume = resume
         IrishTVPlayer.dates_added = dates_added
         
-        str = ""
-        self.log("IrishTVPlayer: Saving %d entries to %s" % (len(resume.keys()), IrishTVPlayer.RESUME_FILE), xbmc.LOGINFO)
-        resume_fh = open(IrishTVPlayer.RESUME_FILE, 'w')
+        str = u""
+        xbmc.log(u"IrishTVPlayer: Saving %d entries to %s" % (len(resume.keys()), IrishTVPlayer.RESUME_FILE), xbmc.LOGINFO)
+        resume_fh = open(IrishTVPlayer.RESUME_FILE, u'w')
         try:
             for pid, seekTime in resume.items():
-                str += "%s %f %d%s" % (pid, seekTime, dates_added[pid], os.linesep)
+                str += u"%s %f %d%s" % (pid, seekTime, dates_added[pid], os.linesep)
             resume_fh.write(str)
         finally:
              resume_fh.close()
@@ -249,18 +272,19 @@
         XBMC is muted during seeking, as there is often a pause before seeking begins.
         """
 
-        if os.environ.get( "OS" ) != "xbox" and not self.live and playresume:
+        if os.environ.get( u"OS" ) != u"xbox" and not self.live and playresume:
             resume, dates_added = IrishTVPlayer.load_resume_file()
             if self.pid in resume.keys():
-                self.log("%s: Resume point found for pid %s at %f, seeking..." % (self, self.pid, resume[self.pid]), xbmc.LOGINFO)
-                listitem.setProperty('StartOffset', '%d' % resume[self.pid])
+                xbmc.log(u"%s: Resume point found for pid %s at %f, seeking..." % (self, self.pid, resume[self.pid]), xbmc.LOGINFO)
+                listitem.setProperty(u'StartOffset', u'%d' % resume[self.pid])
 
         if is_tv:
-            play = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
+            self.playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         else:
-            play = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
-        play.clear()
-        play.add(url, listitem)
-
-        self.play(play)
-
+            self.playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
+        self.playlist.clear()
+        self.playlist.add(url, listitem)
+
+        self.play(self.playlist)
+
+