[cleanup] WS and namming consistency

This commit is contained in:
Cedric Girard 2014-01-26 15:10:39 +01:00
parent 2ccbc80565
commit 7f923f8ce0
8 changed files with 44 additions and 44 deletions

View file

@ -13,8 +13,8 @@
<extension point="xbmc.service" library="service.py"> <extension point="xbmc.service" library="service.py">
</extension> </extension>
<extension point="xbmc.addon.metadata"> <extension point="xbmc.addon.metadata">
<summary>Play BluRays from XBMC with MakeMKV</summary> <summary>Play Blu-Ray from XBMC with MakeMKV</summary>
<description>Uses MakeMKV streaming ability to play BlueRay Discs</description> <description>Uses MakeMKV streaming ability to play Blu-Ray Discs</description>
<platform>all</platform> <platform>all</platform>
</extension> </extension>
</addon> </addon>

View file

@ -15,24 +15,24 @@
<string id="50005">duration</string> <string id="50005">duration</string>
<string id="50006">chapters</string> <string id="50006">chapters</string>
<!-- Progress Dialog --> <!-- Progress Dialog -->
<string id="50050">Starting BluRay script</string> <string id="50050">Starting Blu-Ray script</string>
<string id="50051">Initializing</string> <string id="50051">Initializing</string>
<string id="50052">Waiting for BluRay to be prepared</string> <string id="50052">Waiting for Blu-Ray to be prepared</string>
<string id="50053">Starting Disc</string> <string id="50053">Starting Disc</string>
<string id="50054">Starting Image</string> <string id="50054">Starting Image</string>
<string id="50055">Starting Directory</string> <string id="50055">Starting Directory</string>
<string id="50056">Waiting for stream</string> <string id="50056">Waiting for stream</string>
<!-- Plugin strings --> <!-- Plugin strings -->
<string id="50060">Settings</string> <string id="50060">Settings</string>
<string id="50061">Play Disc %s: %s</string> <string id="50061">Play Disc %s: %s</string>
<string id="50062">Browse Disc %s: %s</string> <string id="50062">Browse Disc %s: %s</string>
<string id="50063">Play Filelocation</string> <string id="50063">Play Filelocation</string>
<string id="50064">Browse Filelocation</string> <string id="50064">Browse Filelocation</string>
<string id="50065">Play Remote location</string> <string id="50065">Play Remote location</string>
<string id="50066">Browse Remote location</string> <string id="50066">Browse Remote location</string>
<!-- Error messages --> <!-- Error messages -->
<string id="50070">Running MakeMKV ended abnormally. Is it installed?</string> <string id="50070">Running MakeMKV ended abnormally. Is it installed?</string>
<string id="50071">unable to find autoplay stream</string> <string id="50071">unable to find autoplay stream</string>

View file

@ -10,23 +10,23 @@ class BrLog:
if prefix <> '': if prefix <> '':
prefix = '-' + prefix prefix = '-' + prefix
self.prefix = prefix self.prefix = prefix
def setLevel(self, level): def setLevel(self, level):
if level >= 0 and level <= 3: if level >= 0 and level <= 3:
self.logLevel = level self.logLevel = level
def info(self, message): def info(self, message):
self.log(message, self.__INFO) self.log(message, self.__INFO)
def debug(self, message): def debug(self, message):
self.log(message, self.__DEBUG) self.log(message, self.__DEBUG)
def error(self, message): def error(self, message):
self.log(message, self.__ERROR) self.log(message, self.__ERROR)
def warn(self, message): def warn(self, message):
self.log(message, self.__WARN) self.log(message, self.__WARN)
def log(self, message, level): def log(self, message, level):
if self.logLevel <= level: if self.logLevel <= level:
print '[BR%s %d] %s' %(self.prefix, level, message) print '[BR%s %d] %s' %(self.prefix, level, message)

View file

@ -1,6 +1,6 @@
class FakeFile: class FakeFile:
def poll(self): def poll(self):
return False return False
def communicate(self): def communicate(self):
return '', '' return '', ''

View file

@ -9,13 +9,13 @@ class MakeMkvInteraction:
def __init__(self): def __init__(self):
self.settings = settings.BluRaySettings() self.settings = settings.BluRaySettings()
self.log = brlog.BrLog('makemkvinteraction') self.log = brlog.BrLog('makemkvinteraction')
def discList(self): def discList(self):
# First stop any old one # First stop any old one
self.killMkv() self.killMkv()
tmpf = tempfile.NamedTemporaryFile(delete=False) tmpf = tempfile.NamedTemporaryFile(delete=False)
self.log.info('temporary file with disc info: %s' % tmpf.name) 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.settings.mkvLocation, tmpf.name))
self.log.info('Return code for disc info generation: %s' % str(sp)) self.log.info('Return code for disc info generation: %s' % str(sp))
if not os.path.isfile(tmpf.name): if not os.path.isfile(tmpf.name):
@ -50,15 +50,15 @@ class MakeMkvInteraction:
else: else:
# Treat as iso # Treat as iso
type = 'iso' type = 'iso'
# Check if the file is reachable through the filesystem, to prevent errors with smb:// shares etc. # Check if the file is reachable through the filesystem, to prevent errors with smb:// shares etc.
if not os.path.exists(choice) : if not os.path.exists(choice) :
dialog = xbmcgui.Dialog() dialog = xbmcgui.Dialog()
dialog.ok("Info", _(50073)) dialog.ok("Info", _(50073))
return False return False
return self.__runandregistershutdown('"%s" -r --cache=128 stream \'%s:%s\'' %(self.settings.mkvLocation, type, choice)) return self.__runandregistershutdown('"%s" -r --cache=128 stream \'%s:%s\'' %(self.settings.mkvLocation, type, choice))
def __runandregistershutdown(self, mkvStart): def __runandregistershutdown(self, mkvStart):
result = self.__runmkvstream(mkvStart) result = self.__runmkvstream(mkvStart)
@ -66,7 +66,7 @@ class MakeMkvInteraction:
return True return True
else: else:
return False return False
def __runmkvstream(self, mkvStart): def __runmkvstream(self, mkvStart):
self.log.info('Starting %s' %(mkvStart)) self.log.info('Starting %s' %(mkvStart))
@ -75,7 +75,7 @@ class MakeMkvInteraction:
timeSlept = 0 timeSlept = 0
proc = subprocess.Popen(mkvStart, shell=True) proc = subprocess.Popen(mkvStart, shell=True)
# Then wait for the stream to come up # Then wait for the stream to come up
while True: while True:
try: try:
urllib.urlretrieve(self.settings.rootURL) urllib.urlretrieve(self.settings.rootURL)
return proc.pid return proc.pid
@ -89,25 +89,25 @@ class MakeMkvInteraction:
timeSlept = timeSlept + 1 timeSlept = timeSlept + 1
if timeSlept > self.settings.waitTimeOut : if timeSlept > self.settings.waitTimeOut :
return -1 return -1
def killMkv(self): def killMkv(self):
# Linux # Linux
try : try :
self.log.info('attempting linux kill of makemkvcon') self.log.info('attempting linux kill of makemkvcon')
subprocess.call('killall -9 makemkvcon', shell=True) subprocess.call('killall -9 makemkvcon', shell=True)
self.log.info('Linux call successful') self.log.info('Linux call successful')
except: except:
pass pass
#Windows. #Windows.
try : 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) subprocess.call('taskkill /F /IM makemkvcon.exe', shell=True)
self.log.info('Windows call successful') self.log.info('Windows call successful')
except: except:
pass pass
def makeMkvExists(self): def makeMkvExists(self):
(fin, fout) = os.popen4('%s -r' %(self.settings.mkvLocation)) (fin, fout) = os.popen4('%s -r' %(self.settings.mkvLocation))
result = fout.read() result = fout.read()
@ -116,7 +116,7 @@ class MakeMkvInteraction:
self.log.info("MakeMkvCon found!") self.log.info("MakeMkvCon found!")
return True return True
else: 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)) % (self.settings.mkvLocation))
return False return False

View file

@ -8,7 +8,7 @@ class BrowseHandler:
self.lastKey = '' self.lastKey = ''
self.lastVal = '' self.lastVal = ''
self.titleMap = {} self.titleMap = {}
def start(self, url, title = 'none'): def start(self, url, title = 'none'):
# Initialize all locals # Initialize all locals
self.catchCharData = False self.catchCharData = False

View file

@ -10,7 +10,7 @@ class BluRaySettings:
def __init__(self): def __init__(self):
addon = xbmcaddon.Addon(__scriptID__) addon = xbmcaddon.Addon(__scriptID__)
self.log = brlog.BrLog('settings') self.log = brlog.BrLog('settings')
self.log.info('reading settings') self.log.info('reading settings')
params = self.getParams() params = self.getParams()
if len(sys.argv) >= 2: if len(sys.argv) >= 2:
@ -21,16 +21,16 @@ class BluRaySettings:
self.autoPlay = self.getBoolParam(params, "autoplay") self.autoPlay = self.getBoolParam(params, "autoplay")
self.disc = self.getParam(params, "disc") self.disc = self.getParam(params, "disc")
self.local = True self.local = True
self.portNumber = addon.getSetting('port_number') self.portNumber = addon.getSetting('port_number')
self.ipAddress = '127.0.0.1' 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.rootURL = 'http://%s:%s/' % (self.ipAddress, self.portNumber)
self.waitTimeOut = int(addon.getSetting('wait_timeout')) self.waitTimeOut = int(addon.getSetting('wait_timeout'))
# Sections: # Sections:
self.enableDisc = addon.getSetting('support_disc') == "true" self.enableDisc = addon.getSetting('support_disc') == "true"
self.enableFile = addon.getSetting('support_fileselect') == "true" self.enableFile = addon.getSetting('support_fileselect') == "true"
def getParam(self, params, name): def getParam(self, params, name):
try: try:
@ -47,7 +47,7 @@ class BluRaySettings:
return int(param) return int(param)
except: except:
return None return None
def getBoolParam (self, params, name): def getBoolParam (self, params, name):
try: try:
param = self.getParam(params,name) param = self.getParam(params,name)
@ -55,7 +55,7 @@ class BluRaySettings:
return 'True' == param return 'True' == param
except: except:
return None return None
def getParams(self): def getParams(self):
try: try:
param=[] param=[]
@ -78,4 +78,4 @@ class BluRaySettings:
return [] return []
def showSettings(self): def showSettings(self):
xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ]) xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ])

View file

@ -18,28 +18,28 @@ import settings, file, mkvparser, brlog, makemkv
_log = brlog.BrLog('tracker service') _log = brlog.BrLog('tracker service')
_log.info('Starting the BluRay tracker service') _log.info('Starting the Blu-Ray tracker service')
class MyPlayer(xbmc.Player): class MyPlayer(xbmc.Player):
def __init__(self): def __init__(self):
xbmc.Player.__init__(self) xbmc.Player.__init__(self)
self.makemkv = makemkv.MakeMkvInteraction() self.makemkv = makemkv.MakeMkvInteraction()
def onPlayBackStopped(self): def onPlayBackStopped(self):
_log.info('Playback stopped, trying to kill makemkv') _log.info('Playback stopped, trying to kill makemkv')
self.makemkv.killMkv() self.makemkv.killMkv()
def onPlayBackStarted(self): def onPlayBackStarted(self):
_log.info('Playback started') _log.info('Playback started')
myPlayer = MyPlayer() myPlayer = MyPlayer()
xbmc.sleep(4) xbmc.sleep(4)
if not makemkv.MakeMkvInteraction().makeMkvExists(): if not makemkv.MakeMkvInteraction().makeMkvExists():
imagePath = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'images', 'alerticon.png') 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): while (not xbmc.abortRequested):
xbmc.sleep(4) xbmc.sleep(4)