From 7f923f8ce0f4d147c88081a2d253221b57aa7675 Mon Sep 17 00:00:00 2001 From: Cedric Girard Date: Sun, 26 Jan 2014 15:10:39 +0100 Subject: [PATCH] [cleanup] WS and namming consistency --- addon.xml | 4 ++-- resources/language/english/strings.xml | 10 ++++----- resources/lib/brlog.py | 12 +++++------ resources/lib/file.py | 4 ++-- resources/lib/makemkv.py | 28 +++++++++++++------------- resources/lib/mkvparser.py | 2 +- resources/lib/settings.py | 20 +++++++++--------- service.py | 8 ++++---- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/addon.xml b/addon.xml index 4559287..7709d9b 100644 --- a/addon.xml +++ b/addon.xml @@ -13,8 +13,8 @@ - Play BluRays from XBMC with MakeMKV - Uses MakeMKV streaming ability to play BlueRay Discs + Play Blu-Ray from XBMC with MakeMKV + Uses MakeMKV streaming ability to play Blu-Ray Discs all diff --git a/resources/language/english/strings.xml b/resources/language/english/strings.xml index e81a8e7..25b70e9 100644 --- a/resources/language/english/strings.xml +++ b/resources/language/english/strings.xml @@ -15,24 +15,24 @@ duration chapters - Starting BluRay script + Starting Blu-Ray script Initializing - Waiting for BluRay to be prepared + Waiting for Blu-Ray to be prepared Starting Disc Starting Image Starting Directory Waiting for stream - + Settings - + Play Disc %s: %s Browse Disc %s: %s Play Filelocation Browse Filelocation Play Remote location Browse Remote location - + Running MakeMKV ended abnormally. Is it installed? unable to find autoplay stream diff --git a/resources/lib/brlog.py b/resources/lib/brlog.py index 7a13df2..0b289a2 100644 --- a/resources/lib/brlog.py +++ b/resources/lib/brlog.py @@ -10,23 +10,23 @@ class BrLog: if prefix <> '': prefix = '-' + prefix self.prefix = prefix - + def setLevel(self, level): if level >= 0 and level <= 3: self.logLevel = level - + def info(self, message): self.log(message, self.__INFO) - + def debug(self, message): self.log(message, self.__DEBUG) - + def error(self, message): self.log(message, self.__ERROR) - + def warn(self, message): self.log(message, self.__WARN) - + def log(self, message, level): if self.logLevel <= level: print '[BR%s %d] %s' %(self.prefix, level, message) diff --git a/resources/lib/file.py b/resources/lib/file.py index ee90e8b..012fd8b 100644 --- a/resources/lib/file.py +++ b/resources/lib/file.py @@ -1,6 +1,6 @@ class FakeFile: def poll(self): return False - + def communicate(self): - return '', '' \ No newline at end of file + return '', '' diff --git a/resources/lib/makemkv.py b/resources/lib/makemkv.py index 5ae2853..3b989a3 100644 --- a/resources/lib/makemkv.py +++ b/resources/lib/makemkv.py @@ -9,13 +9,13 @@ class MakeMkvInteraction: def __init__(self): self.settings = settings.BluRaySettings() self.log = brlog.BrLog('makemkvinteraction') - + def discList(self): # First stop any old one self.killMkv() tmpf = tempfile.NamedTemporaryFile(delete=False) self.log.info('temporary file with disc info: %s' % tmpf.name) - sp = os.system(r'%s -r --cache=1 --messages=%s info disc:10' + sp = os.system(r'%s -r --cache=1 --messages=%s info disc:10' % (self.settings.mkvLocation, tmpf.name)) self.log.info('Return code for disc info generation: %s' % str(sp)) if not os.path.isfile(tmpf.name): @@ -50,15 +50,15 @@ class MakeMkvInteraction: else: # Treat as iso type = 'iso' - + # Check if the file is reachable through the filesystem, to prevent errors with smb:// shares etc. if not os.path.exists(choice) : dialog = xbmcgui.Dialog() dialog.ok("Info", _(50073)) return False - + return self.__runandregistershutdown('"%s" -r --cache=128 stream \'%s:%s\'' %(self.settings.mkvLocation, type, choice)) - + def __runandregistershutdown(self, mkvStart): result = self.__runmkvstream(mkvStart) @@ -66,7 +66,7 @@ class MakeMkvInteraction: return True else: return False - + def __runmkvstream(self, mkvStart): self.log.info('Starting %s' %(mkvStart)) @@ -75,7 +75,7 @@ class MakeMkvInteraction: timeSlept = 0 proc = subprocess.Popen(mkvStart, shell=True) # Then wait for the stream to come up - while True: + while True: try: urllib.urlretrieve(self.settings.rootURL) return proc.pid @@ -89,25 +89,25 @@ class MakeMkvInteraction: timeSlept = timeSlept + 1 if timeSlept > self.settings.waitTimeOut : return -1 - + def killMkv(self): # Linux try : - self.log.info('attempting linux kill of makemkvcon') + self.log.info('attempting linux kill of makemkvcon') subprocess.call('killall -9 makemkvcon', shell=True) - self.log.info('Linux call successful') + self.log.info('Linux call successful') except: pass #Windows. try : - self.log.info('attempting windows kill of makemkvcon') + self.log.info('attempting windows kill of makemkvcon') subprocess.call('taskkill /F /IM makemkvcon.exe', shell=True) - self.log.info('Windows call successful') + self.log.info('Windows call successful') except: pass - + def makeMkvExists(self): (fin, fout) = os.popen4('%s -r' %(self.settings.mkvLocation)) result = fout.read() @@ -116,7 +116,7 @@ class MakeMkvInteraction: self.log.info("MakeMkvCon found!") return True else: - self.log.info('MakeMkvcon seems not to be configured properly : %s' + self.log.info('MakeMkvcon seems not to be configured properly : %s' % (self.settings.mkvLocation)) return False diff --git a/resources/lib/mkvparser.py b/resources/lib/mkvparser.py index 45c91bf..2e62d8f 100644 --- a/resources/lib/mkvparser.py +++ b/resources/lib/mkvparser.py @@ -8,7 +8,7 @@ class BrowseHandler: self.lastKey = '' self.lastVal = '' self.titleMap = {} - + def start(self, url, title = 'none'): # Initialize all locals self.catchCharData = False diff --git a/resources/lib/settings.py b/resources/lib/settings.py index ae8d66a..53ddec8 100644 --- a/resources/lib/settings.py +++ b/resources/lib/settings.py @@ -10,7 +10,7 @@ class BluRaySettings: def __init__(self): addon = xbmcaddon.Addon(__scriptID__) self.log = brlog.BrLog('settings') - self.log.info('reading settings') + self.log.info('reading settings') params = self.getParams() if len(sys.argv) >= 2: @@ -21,16 +21,16 @@ class BluRaySettings: self.autoPlay = self.getBoolParam(params, "autoplay") self.disc = self.getParam(params, "disc") self.local = True - self.portNumber = addon.getSetting('port_number') + self.portNumber = addon.getSetting('port_number') self.ipAddress = '127.0.0.1' - self.mkvLocation = addon.getSetting('mkvlocation') + self.mkvLocation = addon.getSetting('mkvlocation') self.rootURL = 'http://%s:%s/' % (self.ipAddress, self.portNumber) - self.waitTimeOut = int(addon.getSetting('wait_timeout')) - + self.waitTimeOut = int(addon.getSetting('wait_timeout')) + # Sections: - self.enableDisc = addon.getSetting('support_disc') == "true" - self.enableFile = addon.getSetting('support_fileselect') == "true" + self.enableDisc = addon.getSetting('support_disc') == "true" + self.enableFile = addon.getSetting('support_fileselect') == "true" def getParam(self, params, name): try: @@ -47,7 +47,7 @@ class BluRaySettings: return int(param) except: return None - + def getBoolParam (self, params, name): try: param = self.getParam(params,name) @@ -55,7 +55,7 @@ class BluRaySettings: return 'True' == param except: return None - + def getParams(self): try: param=[] @@ -78,4 +78,4 @@ class BluRaySettings: return [] def showSettings(self): - xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ]) + xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ]) diff --git a/service.py b/service.py index 13e5dac..8ace4a7 100644 --- a/service.py +++ b/service.py @@ -18,28 +18,28 @@ import settings, file, mkvparser, brlog, makemkv _log = brlog.BrLog('tracker service') -_log.info('Starting the BluRay tracker service') +_log.info('Starting the Blu-Ray tracker service') class MyPlayer(xbmc.Player): def __init__(self): xbmc.Player.__init__(self) self.makemkv = makemkv.MakeMkvInteraction() - + def onPlayBackStopped(self): _log.info('Playback stopped, trying to kill makemkv') self.makemkv.killMkv() def onPlayBackStarted(self): _log.info('Playback started') - + myPlayer = MyPlayer() xbmc.sleep(4) if not makemkv.MakeMkvInteraction().makeMkvExists(): imagePath = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'images', 'alerticon.png') - xbmc.executebuiltin('Notification("MakeMkv", "The MakeMKV bluray plugin cannot find MakeMkv. Please configure the plugin to point to it", "15000", "%s")' % (imagePath)) + xbmc.executebuiltin('Notification("MakeMkv", "The MakeMKV Blu-Ray plugin cannot find MakeMkv. Please configure the plugin to point to it", "15000", "%s")' % (imagePath)) while (not xbmc.abortRequested): xbmc.sleep(4)