Code refactoring
This commit is contained in:
parent
65fde9088f
commit
78e4a17430
1 changed files with 27 additions and 28 deletions
55
default.py
55
default.py
|
@ -43,7 +43,7 @@ import variables as v
|
||||||
import loghandler
|
import loghandler
|
||||||
|
|
||||||
loghandler.config()
|
loghandler.config()
|
||||||
log = logging.getLogger("PLEX.default")
|
log = logging.getLogger('PLEX.default')
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -51,11 +51,10 @@ HANDLE = int(argv[1])
|
||||||
|
|
||||||
|
|
||||||
class Main():
|
class Main():
|
||||||
|
|
||||||
# MAIN ENTRY POINT
|
# MAIN ENTRY POINT
|
||||||
# @utils.profiling()
|
# @utils.profiling()
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug("Full sys.argv received: %s" % argv)
|
log.debug('Full sys.argv received: %s' % argv)
|
||||||
# Parse parameters
|
# Parse parameters
|
||||||
params = dict(parse_qsl(argv[2][1:]))
|
params = dict(parse_qsl(argv[2][1:]))
|
||||||
mode = params.get('mode', '')
|
mode = params.get('mode', '')
|
||||||
|
@ -80,7 +79,7 @@ class Main():
|
||||||
entrypoint.getNextUpEpisodes(params['tagname'],
|
entrypoint.getNextUpEpisodes(params['tagname'],
|
||||||
int(params['limit']))
|
int(params['limit']))
|
||||||
|
|
||||||
elif mode == "inprogressepisodes":
|
elif mode == 'inprogressepisodes':
|
||||||
entrypoint.getInProgressEpisodes(params['tagname'],
|
entrypoint.getInProgressEpisodes(params['tagname'],
|
||||||
int(params['limit']))
|
int(params['limit']))
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ class Main():
|
||||||
params.get('type'),
|
params.get('type'),
|
||||||
params.get('folderid'))
|
params.get('folderid'))
|
||||||
|
|
||||||
elif mode == "getsubfolders":
|
elif mode == 'getsubfolders':
|
||||||
entrypoint.GetSubFolders(itemid)
|
entrypoint.GetSubFolders(itemid)
|
||||||
|
|
||||||
elif mode == 'watchlater':
|
elif mode == 'watchlater':
|
||||||
|
@ -104,10 +103,10 @@ class Main():
|
||||||
elif mode == 'channels':
|
elif mode == 'channels':
|
||||||
entrypoint.channels()
|
entrypoint.channels()
|
||||||
|
|
||||||
elif mode == "settings":
|
elif mode == 'settings':
|
||||||
executebuiltin('Addon.OpenSettings(%s)' % v.ADDON_ID)
|
executebuiltin('Addon.OpenSettings(%s)' % v.ADDON_ID)
|
||||||
|
|
||||||
elif mode == "enterPMS":
|
elif mode == 'enterPMS':
|
||||||
entrypoint.enterPMS()
|
entrypoint.enterPMS()
|
||||||
|
|
||||||
elif mode == 'reset':
|
elif mode == 'reset':
|
||||||
|
@ -125,47 +124,47 @@ class Main():
|
||||||
elif mode == 'switchuser':
|
elif mode == 'switchuser':
|
||||||
entrypoint.switchPlexUser()
|
entrypoint.switchPlexUser()
|
||||||
|
|
||||||
elif mode in ("manualsync", "repair"):
|
elif mode in ('manualsync', 'repair'):
|
||||||
if window('plex_online') != "true":
|
if window('plex_online') != 'true':
|
||||||
# Server is not online, do not run the sync
|
# Server is not online, do not run the sync
|
||||||
dialog('ok',
|
dialog('ok',
|
||||||
heading=lang(29999),
|
heading=lang(29999),
|
||||||
message=lang(39205))
|
message=lang(39205))
|
||||||
log.error("Not connected to a PMS.")
|
log.error('Not connected to a PMS.')
|
||||||
else:
|
else:
|
||||||
if mode == 'repair':
|
if mode == 'repair':
|
||||||
window('plex_runLibScan', value="repair")
|
window('plex_runLibScan', value='repair')
|
||||||
log.info("Requesting repair lib sync")
|
log.info('Requesting repair lib sync')
|
||||||
elif mode == 'manualsync':
|
elif mode == 'manualsync':
|
||||||
log.info("Requesting full library scan")
|
log.info('Requesting full library scan')
|
||||||
window('plex_runLibScan', value="full")
|
window('plex_runLibScan', value='full')
|
||||||
|
|
||||||
elif mode == "texturecache":
|
elif mode == 'texturecache':
|
||||||
window('plex_runLibScan', value='del_textures')
|
window('plex_runLibScan', value='del_textures')
|
||||||
|
|
||||||
elif mode == "chooseServer":
|
elif mode == 'chooseServer':
|
||||||
entrypoint.chooseServer()
|
entrypoint.chooseServer()
|
||||||
|
|
||||||
elif mode == "refreshplaylist":
|
elif mode == 'refreshplaylist':
|
||||||
log.info('Requesting playlist/nodes refresh')
|
log.info('Requesting playlist/nodes refresh')
|
||||||
window('plex_runLibScan', value="views")
|
window('plex_runLibScan', value='views')
|
||||||
|
|
||||||
elif mode == "deviceid":
|
elif mode == 'deviceid':
|
||||||
self.deviceid()
|
self.deviceid()
|
||||||
|
|
||||||
elif mode == 'fanart':
|
elif mode == 'fanart':
|
||||||
log.info('User requested fanarttv refresh')
|
log.info('User requested fanarttv refresh')
|
||||||
window('plex_runLibScan', value='fanart')
|
window('plex_runLibScan', value='fanart')
|
||||||
|
|
||||||
elif "/extrafanart" in argv[0]:
|
elif '/extrafanart' in argv[0]:
|
||||||
plexpath = argv[2][1:]
|
plexpath = argv[2][1:]
|
||||||
plexid = itemid
|
plexid = itemid
|
||||||
entrypoint.getExtraFanArt(plexid, plexpath)
|
entrypoint.getExtraFanArt(plexid, plexpath)
|
||||||
entrypoint.getVideoFiles(plexid, plexpath)
|
entrypoint.getVideoFiles(plexid, plexpath)
|
||||||
|
|
||||||
# Called by e.g. 3rd party plugin video extras
|
# Called by e.g. 3rd party plugin video extras
|
||||||
elif ("/Extras" in argv[0] or "/VideoFiles" in argv[0] or
|
elif ('/Extras' in argv[0] or '/VideoFiles' in argv[0] or
|
||||||
"/Extras" in argv[2]):
|
'/Extras' in argv[2]):
|
||||||
plexId = itemid or None
|
plexId = itemid or None
|
||||||
entrypoint.getVideoFiles(plexId, params)
|
entrypoint.getVideoFiles(plexId, params)
|
||||||
|
|
||||||
|
@ -173,7 +172,7 @@ class Main():
|
||||||
entrypoint.doMainListing()
|
entrypoint.doMainListing()
|
||||||
|
|
||||||
def play(self):
|
def play(self):
|
||||||
# Put the request into the "queue"
|
# Put the request into the 'queue'
|
||||||
while window('plex_play_new_item'):
|
while window('plex_play_new_item'):
|
||||||
sleep(50)
|
sleep(50)
|
||||||
window('plex_play_new_item',
|
window('plex_play_new_item',
|
||||||
|
@ -200,16 +199,16 @@ class Main():
|
||||||
try:
|
try:
|
||||||
deviceId = getDeviceId(reset=True)
|
deviceId = getDeviceId(reset=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("Failed to generate a new device Id: %s" % e)
|
log.error('Failed to generate a new device Id: %s' % e)
|
||||||
dialog('ok', lang(29999), lang(33032))
|
dialog('ok', lang(29999), lang(33032))
|
||||||
else:
|
else:
|
||||||
log.info("Successfully removed old device ID: %s New deviceId:"
|
log.info('Successfully removed old device ID: %s New deviceId:'
|
||||||
"%s" % (deviceId_old, deviceId))
|
'%s' % (deviceId_old, deviceId))
|
||||||
# "Kodi will now restart to apply the changes"
|
# 'Kodi will now restart to apply the changes'
|
||||||
dialog('ok', lang(29999), lang(33033))
|
dialog('ok', lang(29999), lang(33033))
|
||||||
executebuiltin('RestartApp')
|
executebuiltin('RestartApp')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
log.info('%s started' % v.ADDON_ID)
|
log.info('%s started' % v.ADDON_ID)
|
||||||
Main()
|
Main()
|
||||||
log.info('%s stopped' % v.ADDON_ID)
|
log.info('%s stopped' % v.ADDON_ID)
|
||||||
|
|
Loading…
Reference in a new issue