syntax corrections and version bump
This commit is contained in:
parent
dab2624c88
commit
ad4637f4cf
15 changed files with 1960 additions and 1950 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*.pyo
|
*.pyo
|
||||||
*.pyc
|
*.pyc
|
||||||
|
.*
|
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.makemkvbluray" name="BluRay Player with MakeMKV"
|
<addon
|
||||||
version="1.1.0" provider-name="Magnetism">
|
id="plugin.makemkvbluray"
|
||||||
|
name="BluRay Player with MakeMKV"
|
||||||
|
version="1.1.1"
|
||||||
|
provider-name="desolat">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.0" />
|
<import addon="xbmc.python" version="2.0" />
|
||||||
</requires>
|
</requires>
|
||||||
|
@ -11,7 +14,7 @@
|
||||||
</extension>
|
</extension>
|
||||||
<extension point="xbmc.addon.metadata">
|
<extension point="xbmc.addon.metadata">
|
||||||
<summary>Play BluRays from XBMC with MakeMKV</summary>
|
<summary>Play BluRays from XBMC with MakeMKV</summary>
|
||||||
<description>Awesomeness </description>
|
<description>Uses MakeMKV streaming ability to play BlueRay Discs</description>
|
||||||
<platform>all</platform>
|
<platform>all</platform>
|
||||||
</extension>
|
</extension>
|
||||||
</addon>
|
</addon>
|
||||||
|
|
302
default.py
302
default.py
|
@ -3,7 +3,7 @@ import xbmcplugin, xbmcaddon
|
||||||
|
|
||||||
|
|
||||||
__scriptname__ = "MakeMKV BluRay Watch Plugin"
|
__scriptname__ = "MakeMKV BluRay Watch Plugin"
|
||||||
__scriptID__ = "plugin.makemkvbluray"
|
__scriptID__ = "plugin.makemkvbluray"
|
||||||
__author__ = "Magnetism"
|
__author__ = "Magnetism"
|
||||||
__url__ = "http://bultsblog.com/arne"
|
__url__ = "http://bultsblog.com/arne"
|
||||||
__credits__ = ""
|
__credits__ = ""
|
||||||
|
@ -24,166 +24,166 @@ _log = brlog.BrLog()
|
||||||
_log.info('Starting the BluRay script')
|
_log.info('Starting the BluRay script')
|
||||||
|
|
||||||
class BluRayStarter:
|
class BluRayStarter:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
_log.info('Staring')
|
_log.info('Staring')
|
||||||
self.settings = settings.BluRaySettings()
|
self.settings = settings.BluRaySettings()
|
||||||
self.makemkv = makemkv.MakeMkvInteraction()
|
self.makemkv = makemkv.MakeMkvInteraction()
|
||||||
|
|
||||||
def killAndStart(self, mkvStart):
|
|
||||||
if self.settings.local:
|
|
||||||
_log.info('Running makemkvcon locally')
|
|
||||||
self.killMkv()
|
|
||||||
# Determine if we're doing the disc or if we're browsing..
|
|
||||||
_log.info(mkvStart)
|
|
||||||
return subprocess.Popen(mkvStart, shell=True)
|
|
||||||
else:
|
|
||||||
_log.info('connecting to remote stream, returning fake file browse class..')
|
|
||||||
return file.FakeFile()
|
|
||||||
|
|
||||||
def killMkv(self):
|
|
||||||
# Linux
|
|
||||||
try :
|
|
||||||
_log.info('attempting linux kill of makemkvcon')
|
|
||||||
subprocess.call('killall -9 makemkvcon', shell=True)
|
|
||||||
_log.info('Linux call successful')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
#Windows.
|
|
||||||
try :
|
|
||||||
_log.info('attempting windows kill of makemkvcon')
|
|
||||||
subprocess.call('taskkill /F /IM makemkvcon.exe', shell=True)
|
|
||||||
_log.info('Windows call successful')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def browse(self, url) :
|
|
||||||
_log.info('starting browser handler')
|
|
||||||
h = mkvparser.BrowseHandler()
|
|
||||||
h.start(url)
|
|
||||||
for k,v in h.titleMap.iteritems() : #@UnusedVariable
|
|
||||||
self.addLink("%s %s, %s %s" %(_(50005), v['duration'], _(50006), v['chaptercount']),v['file'])
|
|
||||||
|
|
||||||
|
|
||||||
def getMainFeatureTitle(self, url):
|
|
||||||
h = mkvparser.BrowseHandler()
|
|
||||||
h.start(url)
|
|
||||||
# Play the longest feature on the disc:
|
|
||||||
largest = 0
|
|
||||||
largestTitle = ''
|
|
||||||
for k,v in h.titleMap.iteritems() : #@UnusedVariable
|
|
||||||
m = re.search('(\d+):(\d+):(\d+)', v['duration'])
|
|
||||||
length = int(m.group(1)) * 3600 + int(m.group(2)) * 60 + int(m.group(3))
|
|
||||||
if length > largest :
|
|
||||||
largest = length
|
|
||||||
largestTitle = v['file']
|
|
||||||
_log.info('largest: %d, %s' %(largest,largestTitle))
|
|
||||||
return largestTitle
|
|
||||||
|
|
||||||
def handleListing(self):
|
|
||||||
mode = self.settings.paramMode
|
|
||||||
_log.info( 'mode: ' + str(mode))
|
|
||||||
if mode ==None:
|
|
||||||
_log.info('Showing categories')
|
|
||||||
self.CATEGORIES()
|
|
||||||
_log.info('Showing categories done')
|
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
|
||||||
if mode == 1 :
|
|
||||||
_log.info( 'Entering Disc mode')
|
|
||||||
self.process(self.makemkv.startStream(self.settings.disc))
|
|
||||||
elif mode == 3 :
|
|
||||||
_log.info( 'Entering Remote mode')
|
|
||||||
mystarter = BluRayStarter()
|
|
||||||
mystarter.process('')
|
|
||||||
elif mode == 2:
|
|
||||||
_log.info( 'Entering Browse mode')
|
|
||||||
d = xbmcgui.Dialog()
|
|
||||||
choice = d.browse(1, 'Select folder', 'video', 'index.bdmv|.iso|.isoRenamedMeansSkip!|.MDS|.CUE|.CDI|.CCD', False, False, '')
|
|
||||||
if choice <> '':
|
|
||||||
self.process(self.makemkv.startFileStream(choice))
|
|
||||||
|
|
||||||
if mode == 20:
|
|
||||||
self.settings.showSettings()
|
|
||||||
|
|
||||||
def process(self, ready):
|
|
||||||
try :
|
|
||||||
if ready:
|
|
||||||
_log.info( 'Stream ready. ')
|
|
||||||
# the Stream has started, start auto playback?
|
|
||||||
if self.settings.autoPlay:
|
|
||||||
_log.info( 'Autoplay selected')
|
|
||||||
title = self.getMainFeatureTitle(self.settings.rootURL)
|
|
||||||
_log.info( 'Main feature determined to be : ' + title)
|
|
||||||
opener = urllib.URLopener()
|
|
||||||
testfile = ''
|
|
||||||
try:
|
|
||||||
testfile = title
|
|
||||||
opener.open(testfile)
|
|
||||||
except IOError:
|
|
||||||
testfile = ''
|
|
||||||
|
|
||||||
del opener
|
|
||||||
|
|
||||||
if testfile<>'':
|
|
||||||
_log.info( 'Playing file ' + testfile)
|
|
||||||
li = xbmcgui.ListItem(path = testfile)
|
|
||||||
li.setProperty('IsPlayable', 'true')
|
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
|
|
||||||
else:
|
|
||||||
self.message(_(50071))
|
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
|
|
||||||
|
|
||||||
|
def killAndStart(self, mkvStart):
|
||||||
|
if self.settings.local:
|
||||||
|
_log.info('Running makemkvcon locally')
|
||||||
|
self.killMkv()
|
||||||
|
# Determine if we're doing the disc or if we're browsing..
|
||||||
|
_log.info(mkvStart)
|
||||||
|
return subprocess.Popen(mkvStart, shell=True)
|
||||||
else:
|
else:
|
||||||
# Add the selections as selectable files.
|
_log.info('connecting to remote stream, returning fake file browse class..')
|
||||||
self.browse(self.settings.rootURL)
|
return file.FakeFile()
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
|
||||||
|
def killMkv(self):
|
||||||
|
# Linux
|
||||||
|
try :
|
||||||
|
_log.info('attempting linux kill of makemkvcon')
|
||||||
|
subprocess.call('killall -9 makemkvcon', shell=True)
|
||||||
|
_log.info('Linux call successful')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
#Windows.
|
||||||
|
try :
|
||||||
|
_log.info('attempting windows kill of makemkvcon')
|
||||||
|
subprocess.call('taskkill /F /IM makemkvcon.exe', shell=True)
|
||||||
|
_log.info('Windows call successful')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def browse(self, url) :
|
||||||
|
_log.info('starting browser handler')
|
||||||
|
h = mkvparser.BrowseHandler()
|
||||||
|
h.start(url)
|
||||||
|
for k,v in h.titleMap.iteritems() : #@UnusedVariable
|
||||||
|
self.addLink("%s %s, %s %s" %(_(50005), v['duration'], _(50006), v['chaptercount']),v['file'])
|
||||||
|
|
||||||
|
|
||||||
except :
|
def getMainFeatureTitle(self, url):
|
||||||
self.message(_(50072))
|
h = mkvparser.BrowseHandler()
|
||||||
self.pDialog.close()
|
h.start(url)
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
|
# Play the longest feature on the disc:
|
||||||
raise
|
largest = 0
|
||||||
|
largestTitle = ''
|
||||||
|
for k,v in h.titleMap.iteritems() : #@UnusedVariable
|
||||||
|
m = re.search('(\d+):(\d+):(\d+)', v['duration'])
|
||||||
|
length = int(m.group(1)) * 3600 + int(m.group(2)) * 60 + int(m.group(3))
|
||||||
|
if length > largest :
|
||||||
|
largest = length
|
||||||
|
largestTitle = v['file']
|
||||||
|
_log.info('largest: %d, %s' %(largest,largestTitle))
|
||||||
|
return largestTitle
|
||||||
|
|
||||||
def CATEGORIES(self):
|
def handleListing(self):
|
||||||
# Disc
|
mode = self.settings.paramMode
|
||||||
if self.settings.enableDisc:
|
_log.info( 'mode: ' + str(mode))
|
||||||
disclist = self.makemkv.discList()
|
if mode == None:
|
||||||
for disc in disclist:
|
_log.info('Showing categories')
|
||||||
self.addDir(_(50061) %(disc[0], disc[1]),1, True, disc[0], disc[1])
|
self.CATEGORIES()
|
||||||
for disc in disclist:
|
_log.info('Showing categories done')
|
||||||
self.addDir(_(50062) %(disc[0], disc[1]),1, False, disc[0], disc[1])
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
# Filelocation
|
if mode == 1 :
|
||||||
if self.settings.enableFile:
|
_log.info( 'Entering Disc mode')
|
||||||
self.addDir(_(50063),2, True)
|
self.process(self.makemkv.startStream(self.settings.disc))
|
||||||
self.addDir(_(50064),2, False)
|
elif mode == 3 :
|
||||||
self.addDir(_(50060),20, True, '0', 'settings', False)
|
_log.info( 'Entering Remote mode')
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
mystarter = BluRayStarter()
|
||||||
|
mystarter.process('')
|
||||||
|
elif mode == 2:
|
||||||
|
_log.info( 'Entering Browse mode')
|
||||||
|
d = xbmcgui.Dialog()
|
||||||
|
choice = d.browse(1, 'Select folder', 'video', 'index.bdmv|.iso|.isoRenamedMeansSkip!|.MDS|.CUE|.CDI|.CCD', False, False, '')
|
||||||
|
if choice <> '':
|
||||||
|
self.process(self.makemkv.startFileStream(choice))
|
||||||
|
|
||||||
|
if mode == 20:
|
||||||
|
self.settings.showSettings()
|
||||||
|
|
||||||
|
def process(self, ready):
|
||||||
|
try :
|
||||||
|
if ready:
|
||||||
|
_log.info( 'Stream ready. ')
|
||||||
|
# the Stream has started, start auto playback?
|
||||||
|
if self.settings.autoPlay:
|
||||||
|
_log.info( 'Autoplay selected')
|
||||||
|
title = self.getMainFeatureTitle(self.settings.rootURL)
|
||||||
|
_log.info( 'Main feature determined to be : ' + title)
|
||||||
|
opener = urllib.URLopener()
|
||||||
|
testfile = ''
|
||||||
|
try:
|
||||||
|
testfile = title
|
||||||
|
opener.open(testfile)
|
||||||
|
except IOError:
|
||||||
|
testfile = ''
|
||||||
|
|
||||||
|
del opener
|
||||||
|
|
||||||
|
if testfile<>'':
|
||||||
|
_log.info( 'Playing file ' + testfile)
|
||||||
|
li = xbmcgui.ListItem(path = testfile)
|
||||||
|
li.setProperty('IsPlayable', 'true')
|
||||||
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
|
||||||
|
else:
|
||||||
|
self.message(_(50071))
|
||||||
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Add the selections as selectable files.
|
||||||
|
self.browse(self.settings.rootURL)
|
||||||
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
def addDir(self, name,mode, autoplay, disc = '0', disc_title ='idontknow', isPlayable = True):
|
except :
|
||||||
u=sys.argv[0]+"?mode="+str(mode)+"&autoplay="+urllib.quote_plus(str(autoplay)) + "&disc=" + disc
|
self.message(_(50072))
|
||||||
_log.info(u)
|
self.pDialog.close()
|
||||||
icon = "DefaultVideoPlaylists.png"
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
|
||||||
if autoplay:
|
raise
|
||||||
icon= "DefaultVideo.png"
|
|
||||||
liz=xbmcgui.ListItem(name, iconImage=icon, thumbnailImage='')
|
def CATEGORIES(self):
|
||||||
if autoplay and isPlayable:
|
# Disc
|
||||||
liz.setProperty("IsPlayable", "true")
|
if self.settings.enableDisc:
|
||||||
liz.setInfo( type="Video", infoLabels={ "Title": name } )
|
disclist = self.makemkv.discList()
|
||||||
_log.info(name)
|
for disc in disclist:
|
||||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz, isFolder= not autoplay)
|
self.addDir(_(50061) %(disc[0], disc[1]),1, True, disc[0], disc[1])
|
||||||
|
for disc in disclist:
|
||||||
|
self.addDir(_(50062) %(disc[0], disc[1]),1, False, disc[0], disc[1])
|
||||||
|
# Filelocation
|
||||||
|
if self.settings.enableFile:
|
||||||
|
self.addDir(_(50063),2, True)
|
||||||
|
self.addDir(_(50064),2, False)
|
||||||
|
self.addDir(_(50060),20, True, '0', 'settings', False)
|
||||||
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
def addLink(self, name,url):
|
def addDir(self, name,mode, autoplay, disc = '0', disc_title ='idontknow', isPlayable = True):
|
||||||
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage='')
|
u=sys.argv[0]+"?mode="+str(mode)+"&autoplay="+urllib.quote_plus(str(autoplay)) + "&disc=" + disc
|
||||||
liz.setInfo( type="Video", infoLabels={ "Title": name } )
|
_log.info(u)
|
||||||
liz.setProperty("IsPlayable" , "true")
|
icon = "DefaultVideoPlaylists.png"
|
||||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
|
if autoplay:
|
||||||
|
icon= "DefaultVideo.png"
|
||||||
|
liz=xbmcgui.ListItem(name, iconImage=icon, thumbnailImage='')
|
||||||
|
if autoplay and isPlayable:
|
||||||
|
liz.setProperty("IsPlayable", "true")
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Title": name } )
|
||||||
|
_log.info(name)
|
||||||
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz, isFolder= not autoplay)
|
||||||
|
|
||||||
def message(self, messageText):
|
|
||||||
dialog = xbmcgui.Dialog()
|
def addLink(self, name,url):
|
||||||
dialog.ok("Info", messageText)
|
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage='')
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Title": name } )
|
||||||
|
liz.setProperty("IsPlayable" , "true")
|
||||||
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
|
||||||
|
|
||||||
|
def message(self, messageText):
|
||||||
|
dialog = xbmcgui.Dialog()
|
||||||
|
dialog.ok("Info", messageText)
|
||||||
|
|
||||||
_log.info("args")
|
_log.info("args")
|
||||||
for arg in sys.argv:
|
for arg in sys.argv:
|
||||||
|
|
5
resources/lib/__init__.py
Normal file
5
resources/lib/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
'''
|
||||||
|
Created on 06.10.2012
|
||||||
|
|
||||||
|
@author: desolat
|
||||||
|
'''
|
|
@ -1,32 +1,32 @@
|
||||||
|
|
||||||
class BrLog:
|
class BrLog:
|
||||||
__DEBUG = 0
|
__DEBUG = 0
|
||||||
__INFO = 1
|
__INFO = 1
|
||||||
__WARN = 2
|
__WARN = 2
|
||||||
__ERROR = 3
|
__ERROR = 3
|
||||||
|
|
||||||
def __init__(self, prefix = ''):
|
def __init__(self, prefix = ''):
|
||||||
self.logLevel = self.__INFO
|
self.logLevel = self.__INFO
|
||||||
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)
|
||||||
|
|
|
@ -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 '', ''
|
|
@ -67,37 +67,37 @@ class MakeMkvInteraction:
|
||||||
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
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
if proc.poll() :
|
if proc.poll() :
|
||||||
if proc.proc != 0 :
|
if proc.proc != 0 :
|
||||||
self.message(_(50070))
|
self.message(_(50070))
|
||||||
return -1
|
return -1
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
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))
|
||||||
|
@ -107,7 +107,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.settings.mkvLocation))
|
self.log.info('MakeMkvcon seems not to be configured properly : %s'
|
||||||
|
% (self.settings.mkvLocation))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
import urllib, re, elementtree.ElementTree as ET
|
import urllib, re, elementtree.ElementTree as ET
|
||||||
|
|
||||||
class BrowseHandler:
|
class BrowseHandler:
|
||||||
def __init__(self) :
|
def __init__(self) :
|
||||||
self.catchCharData = False
|
self.catchCharData = False
|
||||||
self.keyColumn = False
|
self.keyColumn = False
|
||||||
self.map = {}
|
self.map = {}
|
||||||
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
|
||||||
self.keyColumn = False
|
self.keyColumn = False
|
||||||
self.map[url] = {}
|
self.map[url] = {}
|
||||||
self.currMap = self.map[url]
|
self.currMap = self.map[url]
|
||||||
self.lastKey = ''
|
self.lastKey = ''
|
||||||
self.lastVal = ''
|
self.lastVal = ''
|
||||||
filename, headers = urllib.urlretrieve(url)
|
filename, headers = urllib.urlretrieve(url)
|
||||||
del headers
|
del headers
|
||||||
|
|
||||||
XML = ET.parse(filename)
|
XML = ET.parse(filename)
|
||||||
elems = XML.getiterator(tag='{http://www.w3.org/1999/xhtml}td')
|
elems = XML.getiterator(tag='{http://www.w3.org/1999/xhtml}td')
|
||||||
for each in elems:
|
for each in elems:
|
||||||
self.keyColumn = not self.keyColumn
|
self.keyColumn = not self.keyColumn
|
||||||
if self.keyColumn:
|
if self.keyColumn:
|
||||||
self.lastKey = each.text
|
self.lastKey = each.text
|
||||||
else:
|
else:
|
||||||
txt = ''
|
txt = ''
|
||||||
# Check for href:
|
# Check for href:
|
||||||
refs = each.getiterator(tag='{http://www.w3.org/1999/xhtml}a')
|
refs = each.getiterator(tag='{http://www.w3.org/1999/xhtml}a')
|
||||||
for ref in refs:
|
for ref in refs:
|
||||||
txt = ref.get('href')
|
txt = ref.get('href')
|
||||||
|
|
||||||
if txt == '' :
|
if txt == '' :
|
||||||
txt = each.text
|
txt = each.text
|
||||||
|
|
||||||
self.currMap[self.lastKey] = txt
|
self.currMap[self.lastKey] = txt
|
||||||
|
|
||||||
# Now do some processing:
|
# Now do some processing:
|
||||||
for k, v in self.map[url].iteritems() :
|
for k, v in self.map[url].iteritems() :
|
||||||
if k == 'titles':
|
if k == 'titles':
|
||||||
# go straight ahead and parse some more:
|
# go straight ahead and parse some more:
|
||||||
self.start(v)
|
self.start(v)
|
||||||
if re.search('title\d+', k) :
|
if re.search('title\d+', k) :
|
||||||
self.titleMap[k] = {}
|
self.titleMap[k] = {}
|
||||||
self.start(v, k)
|
self.start(v, k)
|
||||||
if title != 'none':
|
if title != 'none':
|
||||||
if k == 'duration':
|
if k == 'duration':
|
||||||
self.titleMap[title]['duration'] = v
|
self.titleMap[title]['duration'] = v
|
||||||
elif k == 'file0':
|
elif k == 'file0':
|
||||||
self.titleMap[title]['file'] = v
|
self.titleMap[title]['file'] = v
|
||||||
elif k == 'chaptercount':
|
elif k == 'chaptercount':
|
||||||
self.titleMap[title]['chaptercount'] = v
|
self.titleMap[title]['chaptercount'] = v
|
||||||
|
|
||||||
|
|
|
@ -3,79 +3,79 @@ import sys
|
||||||
import urllib
|
import urllib
|
||||||
import brlog
|
import brlog
|
||||||
|
|
||||||
__scriptID__ = sys.modules[ "__main__" ].__scriptID__
|
__scriptID__ = sys.modules[ "__main__" ].__scriptID__
|
||||||
|
|
||||||
|
|
||||||
class BluRaySettings:
|
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:
|
||||||
self.handle = int(sys.argv[1])
|
self.handle = int(sys.argv[1])
|
||||||
self.paramUrl = self.getParam(params, 'url')
|
self.paramUrl = self.getParam(params, 'url')
|
||||||
self.paramName = self.getParam(params, "name")
|
self.paramName = self.getParam(params, "name")
|
||||||
self.paramMode = self.getIntParam(params, "mode")
|
self.paramMode = self.getIntParam(params, "mode")
|
||||||
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:
|
||||||
result = params[name]
|
result = params[name]
|
||||||
result = urllib.unquote_plus(result)
|
result = urllib.unquote_plus(result)
|
||||||
return result
|
return result
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getIntParam (self, params, name):
|
def getIntParam (self, params, name):
|
||||||
try:
|
try:
|
||||||
param = self.getParam(params,name)
|
param = self.getParam(params,name)
|
||||||
self.log.debug(name + ' = ' + param)
|
self.log.debug(name + ' = ' + param)
|
||||||
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)
|
||||||
self.log.debug(name + ' = ' + param)
|
self.log.debug(name + ' = ' + param)
|
||||||
return 'True' == param
|
return 'True' == param
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getParams(self):
|
def getParams(self):
|
||||||
try:
|
try:
|
||||||
param=[]
|
param=[]
|
||||||
paramstring=sys.argv[2]
|
paramstring=sys.argv[2]
|
||||||
self.log.info('raw param string: ' + paramstring)
|
self.log.info('raw param string: ' + paramstring)
|
||||||
if len(paramstring)>=2:
|
if len(paramstring)>=2:
|
||||||
params=sys.argv[2]
|
params=sys.argv[2]
|
||||||
cleanedparams=params.replace('?','')
|
cleanedparams=params.replace('?','')
|
||||||
if (params[len(params)-1]=='/'):
|
if (params[len(params)-1]=='/'):
|
||||||
params=params[0:len(params)-2]
|
params=params[0:len(params)-2]
|
||||||
pairsofparams=cleanedparams.split('&')
|
pairsofparams=cleanedparams.split('&')
|
||||||
param={}
|
param={}
|
||||||
for i in range(len(pairsofparams)):
|
for i in range(len(pairsofparams)):
|
||||||
splitparams={}
|
splitparams={}
|
||||||
splitparams=pairsofparams[i].split('=')
|
splitparams=pairsofparams[i].split('=')
|
||||||
if (len(splitparams))==2:
|
if (len(splitparams))==2:
|
||||||
param[splitparams[0]]=splitparams[1]
|
param[splitparams[0]]=splitparams[1]
|
||||||
return param
|
return param
|
||||||
except:
|
except:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def showSettings(self):
|
def showSettings(self):
|
||||||
xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ])
|
xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ])
|
||||||
|
|
|
@ -20,6 +20,7 @@ _log = brlog.BrLog('tracker service')
|
||||||
|
|
||||||
_log.info('Starting the BluRay tracker service')
|
_log.info('Starting the BluRay tracker service')
|
||||||
|
|
||||||
|
|
||||||
class MyPlayer(xbmc.Player):
|
class MyPlayer(xbmc.Player):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
xbmc.Player.__init__(self)
|
xbmc.Player.__init__(self)
|
||||||
|
@ -37,7 +38,7 @@ class MyPlayer(xbmc.Player):
|
||||||
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 bluray plugin cannot find MakeMkv. Please configure the plugin to point to it", "15000", "%s")' % (imagePath))
|
||||||
|
|
||||||
while (not xbmc.abortRequested):
|
while (not xbmc.abortRequested):
|
||||||
|
|
Loading…
Reference in a new issue