[cleanup] WS and namming consistency
This commit is contained in:
parent
2ccbc80565
commit
7f923f8ce0
8 changed files with 44 additions and 44 deletions
|
@ -13,8 +13,8 @@
|
|||
<extension point="xbmc.service" library="service.py">
|
||||
</extension>
|
||||
<extension point="xbmc.addon.metadata">
|
||||
<summary>Play BluRays from XBMC with MakeMKV</summary>
|
||||
<description>Uses MakeMKV streaming ability to play BlueRay Discs</description>
|
||||
<summary>Play Blu-Ray from XBMC with MakeMKV</summary>
|
||||
<description>Uses MakeMKV streaming ability to play Blu-Ray Discs</description>
|
||||
<platform>all</platform>
|
||||
</extension>
|
||||
</addon>
|
||||
|
|
|
@ -15,24 +15,24 @@
|
|||
<string id="50005">duration</string>
|
||||
<string id="50006">chapters</string>
|
||||
<!-- Progress Dialog -->
|
||||
<string id="50050">Starting BluRay script</string>
|
||||
<string id="50050">Starting Blu-Ray script</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="50054">Starting Image</string>
|
||||
<string id="50055">Starting Directory</string>
|
||||
<string id="50056">Waiting for stream</string>
|
||||
|
||||
|
||||
<!-- Plugin strings -->
|
||||
<string id="50060">Settings</string>
|
||||
|
||||
|
||||
<string id="50061">Play Disc %s: %s</string>
|
||||
<string id="50062">Browse Disc %s: %s</string>
|
||||
<string id="50063">Play Filelocation</string>
|
||||
<string id="50064">Browse Filelocation</string>
|
||||
<string id="50065">Play Remote location</string>
|
||||
<string id="50066">Browse Remote location</string>
|
||||
|
||||
|
||||
<!-- Error messages -->
|
||||
<string id="50070">Running MakeMKV ended abnormally. Is it installed?</string>
|
||||
<string id="50071">unable to find autoplay stream</string>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class FakeFile:
|
||||
def poll(self):
|
||||
return False
|
||||
|
||||
|
||||
def communicate(self):
|
||||
return '', ''
|
||||
return '', ''
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class BrowseHandler:
|
|||
self.lastKey = ''
|
||||
self.lastVal = ''
|
||||
self.titleMap = {}
|
||||
|
||||
|
||||
def start(self, url, title = 'none'):
|
||||
# Initialize all locals
|
||||
self.catchCharData = False
|
||||
|
|
|
@ -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 ])
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue