refactor
This commit is contained in:
parent
843a4338d8
commit
038271f57f
18
addon.py
18
addon.py
@ -10,6 +10,14 @@ ADDON = xbmcaddon.Addon()
|
|||||||
CWD = ADDON.getAddonInfo('path').decode('utf-8')
|
CWD = ADDON.getAddonInfo('path').decode('utf-8')
|
||||||
#CWD = ADDON.getAddonInfo('path') # for kodi 19
|
#CWD = ADDON.getAddonInfo('path') # for kodi 19
|
||||||
|
|
||||||
|
def list_programs(cinematic_path):
|
||||||
|
dirs, files = xbmcvfs.listdir(cinematic_path)
|
||||||
|
programs = []
|
||||||
|
for filename in files:
|
||||||
|
if filename.endswith('.json'):
|
||||||
|
programs.append(filename)
|
||||||
|
return programs
|
||||||
|
|
||||||
def files_from_dir(count, location):
|
def files_from_dir(count, location):
|
||||||
print("fetching %d files from %s" % (count, location))
|
print("fetching %d files from %s" % (count, location))
|
||||||
dirs, files = xbmcvfs.listdir(location)
|
dirs, files = xbmcvfs.listdir(location)
|
||||||
@ -30,18 +38,14 @@ if __name__ == '__main__':
|
|||||||
if name == 'dbid':
|
if name == 'dbid':
|
||||||
dbid = int(value)
|
dbid = int(value)
|
||||||
|
|
||||||
path = ADDON.getSettingString('cinematic_path')
|
cinematic_path = ADDON.getSettingString('cinematic_path')
|
||||||
dirs, files = xbmcvfs.listdir(path)
|
programs = list_programs(cinematic_path)
|
||||||
programs = []
|
|
||||||
for filename in files:
|
|
||||||
if filename.endswith('.json'):
|
|
||||||
programs.append(filename)
|
|
||||||
|
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
ret = dialog.select('Cinematic: Select a program', programs)
|
ret = dialog.select('Cinematic: Select a program', programs)
|
||||||
del dialog
|
del dialog
|
||||||
|
|
||||||
program_file = path + programs[ret]
|
program_file = cinematic_path + programs[ret]
|
||||||
|
|
||||||
filehandle = xbmcvfs.File(program_file)
|
filehandle = xbmcvfs.File(program_file)
|
||||||
program_json = filehandle.read()
|
program_json = filehandle.read()
|
||||||
|
Loading…
Reference in New Issue
Block a user