Removed unused stuff

This commit is contained in:
Arne Bultman 2011-12-26 21:13:33 +01:00
parent 2dd34be950
commit 0b8957b4cb
5 changed files with 42 additions and 106 deletions

View file

@ -21,44 +21,44 @@ import settings, file, mkvparser, brlog, makemkv
_log = brlog.BrLog() _log = brlog.BrLog()
_log.info('Starting the BluRay script') #@UndefinedVariable _log.info('Starting the BluRay script')
class BluRayStarter: class BluRayStarter:
def __init__(self): def __init__(self):
_log.info('Staring') #@UndefinedVariable _log.info('Staring')
self.settings = settings.BluRaySettings() self.settings = settings.BluRaySettings()
self.makemkv = makemkv.MakeMkvInteraction() self.makemkv = makemkv.MakeMkvInteraction()
def killAndStart(self, mkvStart): def killAndStart(self, mkvStart):
if self.settings.local: if self.settings.local:
_log.info('Running makemkvcon locally') #@UndefinedVariable _log.info('Running makemkvcon locally')
self.killMkv() self.killMkv()
# Determine if we're doing the disc or if we're browsing.. # Determine if we're doing the disc or if we're browsing..
_log.info(mkvStart) #@UndefinedVariable _log.info(mkvStart)
return subprocess.Popen(mkvStart, shell=True) return subprocess.Popen(mkvStart, shell=True)
else: else:
_log.info('connecting to remote stream, returning fake file browse class..') #@UndefinedVariable _log.info('connecting to remote stream, returning fake file browse class..')
return file.FakeFile() return file.FakeFile()
def killMkv(self): def killMkv(self):
# Linux # Linux
try : try :
_log.info('attempting linux kill of makemkvcon') #@UndefinedVariable _log.info('attempting linux kill of makemkvcon')
subprocess.call('killall -9 makemkvcon', shell=True) subprocess.call('killall -9 makemkvcon', shell=True)
_log.info('Linux call successful') #@UndefinedVariable _log.info('Linux call successful')
except: except:
pass pass
#Windows. #Windows.
try : try :
_log.info('attempting windows kill of makemkvcon') #@UndefinedVariable _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)
_log.info('Windows call successful') #@UndefinedVariable _log.info('Windows call successful')
except: except:
pass pass
def browse(self, url) : def browse(self, url) :
_log.info('starting browser handler') #@UndefinedVariable _log.info('starting browser handler')
h = mkvparser.BrowseHandler() h = mkvparser.BrowseHandler()
h.start(url) h.start(url)
for k,v in h.titleMap.iteritems() : #@UnusedVariable for k,v in h.titleMap.iteritems() : #@UnusedVariable
@ -87,9 +87,7 @@ class BluRayStarter:
_log.info('Showing categories') _log.info('Showing categories')
self.CATEGORIES() self.CATEGORIES()
_log.info('Showing categories done') _log.info('Showing categories done')
# _log.info(__addon__.)
xbmcplugin.endOfDirectory(int(sys.argv[1])) xbmcplugin.endOfDirectory(int(sys.argv[1]))
if mode == 1 : if mode == 1 :
_log.info( 'Entering Disc mode') _log.info( 'Entering Disc mode')
self.process(self.makemkv.startStream(self.settings.disc)) self.process(self.makemkv.startStream(self.settings.disc))
@ -99,7 +97,7 @@ class BluRayStarter:
mystarter.process('') mystarter.process('')
elif mode == 2: elif mode == 2:
_log.info( 'Entering Browse mode') _log.info( 'Entering Browse mode')
d = xbmcgui.Dialog() #@UndefinedVariable d = xbmcgui.Dialog()
choice = d.browse(1, 'Select folder', 'video', 'index.bdmv|.iso|.isoRenamedMeansSkip!|.MDS|.CUE|.CDI|.CCD', False, False, '') choice = d.browse(1, 'Select folder', 'video', 'index.bdmv|.iso|.isoRenamedMeansSkip!|.MDS|.CUE|.CDI|.CCD', False, False, '')
if choice <> '': if choice <> '':
self.process(self.makemkv.startFileStream(choice)) self.process(self.makemkv.startFileStream(choice))
@ -130,21 +128,21 @@ class BluRayStarter:
_log.info( 'Playing file ' + testfile) _log.info( 'Playing file ' + testfile)
li = xbmcgui.ListItem(path = testfile) li = xbmcgui.ListItem(path = testfile)
li.setProperty('IsPlayable', 'true') li.setProperty('IsPlayable', 'true')
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li) #@UndefinedVariable xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
else: else:
self.message(_(50071)) self.message(_(50071))
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) #@UndefinedVariable xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
else: else:
# Add the selections as selectable files. # Add the selections as selectable files.
self.browse(self.settings.rootURL) self.browse(self.settings.rootURL)
xbmcplugin.endOfDirectory(int(sys.argv[1])) #@UndefinedVariable xbmcplugin.endOfDirectory(int(sys.argv[1]))
except : except :
self.message(_(50072)) self.message(_(50072))
self.pDialog.close() self.pDialog.close()
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) #@UndefinedVariable xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
raise raise
def CATEGORIES(self): def CATEGORIES(self):
@ -152,22 +150,18 @@ class BluRayStarter:
if self.settings.enableDisc: if self.settings.enableDisc:
disclist = self.makemkv.discList() disclist = self.makemkv.discList()
for disc in disclist: for disc in disclist:
self.addDir(_(50061) %(disc[0], disc[1]),1, True, disc[0]) self.addDir(_(50061) %(disc[0], disc[1]),1, True, disc[0], disc[1])
for disc in disclist: for disc in disclist:
self.addDir(_(50062) %(disc[0], disc[1]),1, False, disc[0]) self.addDir(_(50062) %(disc[0], disc[1]),1, False, disc[0], disc[1])
# Filelocation # Filelocation
if self.settings.enableFile: if self.settings.enableFile:
self.addDir(_(50063),2, True) self.addDir(_(50063),2, True)
self.addDir(_(50064),2, False) self.addDir(_(50064),2, False)
# Remote self.addDir(_(50060),20, True, '0', 'settings', False)
# if self.settings.enableRemote:
# self.addDir(_(50065),3, True)
# self.addDir(_(50066),3, False)
self.addDir(_(50060),20, True, '0', False)
xbmcplugin.endOfDirectory(int(sys.argv[1])) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def addDir(self, name,mode, autoplay, disc = '0', isPlayable = True): def addDir(self, name,mode, autoplay, disc = '0', disc_title ='idontknow', isPlayable = True):
u=sys.argv[0]+"?mode="+str(mode)+"&autoplay="+urllib.quote_plus(str(autoplay)) + "&disc=" + disc u=sys.argv[0]+"?mode="+str(mode)+"&autoplay="+urllib.quote_plus(str(autoplay)) + "&disc=" + disc
_log.info(u) _log.info(u)
icon = "DefaultVideoPlaylists.png" icon = "DefaultVideoPlaylists.png"
@ -182,13 +176,13 @@ class BluRayStarter:
def addLink(self, name,url): def addLink(self, name,url):
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage='') #@UndefinedVariable liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage='')
liz.setInfo( type="Video", infoLabels={ "Title": name } ) liz.setInfo( type="Video", infoLabels={ "Title": name } )
liz.setProperty("IsPlayable" , "true") liz.setProperty("IsPlayable" , "true")
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz) #@UndefinedVariable xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
def message(self, messageText): def message(self, messageText):
dialog = xbmcgui.Dialog() #@UndefinedVariable dialog = xbmcgui.Dialog()
dialog.ok("Info", messageText) dialog.ok("Info", messageText)
_log.info("args") _log.info("args")

View file

@ -1,24 +1,16 @@
import subprocess, settings, brlog, tempfile, os, threading, xbmcgui, urllib, re, xbmc import subprocess, settings, brlog, tempfile, os, threading, xbmcgui, urllib, re, xbmc, xbmcplugin
from functools import partial from functools import partial
def killMkvOnPlaybackEnd(pid):
dialog = xbmcgui.Dialog() #@UndefinedVariable
dialog.ok("playback ended, about to kill %d"%(pid))
class MakeMkvInteraction: class MakeMkvInteraction:
def __init__(self): def __init__(self):
self.settings = settings.BluRaySettings() self.settings = settings.BluRaySettings()
self.progress = ProgressInfo()
self.progress.start()
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=True) tmpf = tempfile.NamedTemporaryFile(delete=True)
progressFile = self.progress.startProgress() sp = os.system(r'%s -r --cache=1 --messages=%s info disc:10' %(self.settings.mkvLocation, tmpf.name))
sp = os.system(r'%s -r --cache=1 --progress=%s --messages=%s info disc:10' %(self.settings.mkvLocation, progressFile, tmpf.name))
tmpf = open(tmpf.name) tmpf = open(tmpf.name)
content = tmpf.read() content = tmpf.read()
@ -34,7 +26,6 @@ class MakeMkvInteraction:
def startStream(self, disc): def startStream(self, disc):
self.log.info("Starting stream on disc %s with local url %s" %(disc, self.settings.rootURL)) self.log.info("Starting stream on disc %s with local url %s" %(disc, self.settings.rootURL))
# Then fork the makemkv process # Then fork the makemkv process
# progressFile = self.progress.startProgress(times = 2)
return self.__runandregistershutdown('%s -r --cache=128 stream disc:%s' %(self.settings.mkvLocation, disc)) return self.__runandregistershutdown('%s -r --cache=128 stream disc:%s' %(self.settings.mkvLocation, disc))
def startFileStream(self, choice): def startFileStream(self, choice):
@ -53,7 +44,7 @@ class MakeMkvInteraction:
# 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() #@UndefinedVariable dialog = xbmcgui.Dialog()
dialog.ok("Info", _(50073)) dialog.ok("Info", _(50073))
return False return False
@ -63,7 +54,6 @@ class MakeMkvInteraction:
def __runandregistershutdown(self, mkvStart): def __runandregistershutdown(self, mkvStart):
result = self.__runmkvstream(mkvStart) result = self.__runmkvstream(mkvStart)
if result >= 0: if result >= 0:
xbmc.Player().onPlayBackStopped(partial(killMkvOnPlaybackEnd, result))
return True return True
else: else:
return False return False
@ -95,54 +85,17 @@ class MakeMkvInteraction:
def killMkv(self): def killMkv(self):
# Linux # Linux
try : try :
self.log.info('attempting linux kill of makemkvcon') #@UndefinedVariable 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') #@UndefinedVariable self.log.info('Linux call successful')
except: except:
pass pass
#Windows. #Windows.
try : try :
self.log.info('attempting windows kill of makemkvcon') #@UndefinedVariable 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') #@UndefinedVariable self.log.info('Windows call successful')
except: except:
pass pass
class ProgressInfo(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.progressFile = None
self.showing = False
self.dialog = None
def run(self):
while True:
if self.showing:
busy = True
maxprg = 1000
current = 0
while self.showing:
line = self.progressFile.readline()
if line.startswith('PRGV:'):
progress = line[4:].split(',')
maxprg = int(progress[2])
current= int(progress[1])
self.dialog.update(int(float(current) / float(maxprg) * 1000.0) )
if current >= maxprg:
self.times = self.times - 1
if self.times == 0:
self.dialog.close()
self.showing = False
def startProgress(self, times = 1):
self.dialog = xbmcgui.DialogProgress()
self.dialog.create('XBMC', '', '')
self.progressFile = tempfile.NamedTemporaryFile()
self.times = times
self.showing = True
return self.progressFile.name

View file

@ -10,32 +10,26 @@ 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') #@UndefinedVariable self.log.info('reading settings')
params = self.getParams() params = self.getParams()
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 = self.paramMode <> 3 self.local = True
self.ipAddress = addon.getSetting('ip_address') #@UndefinedVariable self.portNumber = addon.getSetting('port_number')
self.portNumber = addon.getSetting('port_number') #@UndefinedVariable self.ipAddress = '127.0.0.1'
if (self.local):
#Make sure local means 127.0.0.1 ...
self.ipAddress = '127.0.0.1'
else :
#Remote so use that portnumber
self.portNumber = addon.getSetting('remote_port_number') #@UndefinedVariable
self.mkvLocation = addon.getSetting('mkvlocation') #@UndefinedVariable 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')) #@UndefinedVariable self.waitTimeOut = int(addon.getSetting('wait_timeout'))
# Sections: # Sections:
self.enableDisc = addon.getSetting('support_disc') == "true" #@UndefinedVariable self.enableDisc = addon.getSetting('support_disc') == "true"
self.enableFile = addon.getSetting('support_fileselect') == "true" #@UndefinedVariable self.enableFile = addon.getSetting('support_fileselect') == "true"
self.enableRemote = addon.getSetting('support_remote') == "true" #@UndefinedVariable
def getParam(self, params, name): def getParam(self, params, name):
try: try:
@ -83,4 +77,4 @@ class BluRaySettings:
return [] return []
def showSettings(self): def showSettings(self):
xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ]) #@UndefinedVariable xbmcaddon.Addon(__scriptID__).openSettings(sys.argv[ 0 ])

View file

@ -8,10 +8,5 @@
<setting type="lsep" label="51005"/> <setting type="lsep" label="51005"/>
<setting id="support_disc" type="bool" label="51006" default="true" /> <setting id="support_disc" type="bool" label="51006" default="true" />
<setting id="support_fileselect" type="bool" label="51007" default="true"/> <setting id="support_fileselect" type="bool" label="51007" default="true"/>
<setting id="support_remote" type="bool" label="51008" default="true"/>
<setting type="lsep" label="51000" visible="eq(-1,true)"/>
<setting id="ip_address" type="ipaddress" label="51001" default="127.0.0.1" visible="eq(-2,true)" />
<setting id="remote_port_number" type="number" label="51009" default="51000" visible="eq(-3,true)" />
</settings> </settings>

View file

@ -18,7 +18,7 @@ import settings, file, mkvparser, brlog, makemkv
_log = brlog.BrLog('tracker service') _log = brlog.BrLog('tracker service')
_log.info('Starting the BluRay tracker service') #@UndefinedVariable _log.info('Starting the BluRay tracker service')
class MyPlayer(xbmc.Player): class MyPlayer(xbmc.Player):
def __init__(self): def __init__(self):