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') # 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):
|
||||
print("fetching %d files from %s" % (count, location))
|
||||
dirs, files = xbmcvfs.listdir(location)
|
||||
@ -30,18 +38,14 @@ if __name__ == '__main__':
|
||||
if name == 'dbid':
|
||||
dbid = int(value)
|
||||
|
||||
path = ADDON.getSettingString('cinematic_path')
|
||||
dirs, files = xbmcvfs.listdir(path)
|
||||
programs = []
|
||||
for filename in files:
|
||||
if filename.endswith('.json'):
|
||||
programs.append(filename)
|
||||
cinematic_path = ADDON.getSettingString('cinematic_path')
|
||||
programs = list_programs(cinematic_path)
|
||||
|
||||
dialog = xbmcgui.Dialog()
|
||||
ret = dialog.select('Cinematic: Select a program', programs)
|
||||
del dialog
|
||||
|
||||
program_file = path + programs[ret]
|
||||
program_file = cinematic_path + programs[ret]
|
||||
|
||||
filehandle = xbmcvfs.File(program_file)
|
||||
program_json = filehandle.read()
|
||||
|
Loading…
Reference in New Issue
Block a user