initial commit

This commit is contained in:
Ronald Schaten 2021-03-15 15:35:24 +01:00
commit 031b0c8f1e
4 changed files with 93 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
Installation:
git clone git@www.0x50.de:rschaten/script.cinematic.git script.cinemavision

70
addon.py Normal file
View File

@ -0,0 +1,70 @@
import xbmc
import xbmcgui
import xbmcaddon
import xbmcvfs
import json
import random
import sys
ADDON = xbmcaddon.Addon()
CWD = ADDON.getAddonInfo('path').decode('utf-8')
#CWD = ADDON.getAddonInfo('path') # for kodi 19
def files_from_dir(count, location):
print("fetching %d files from %s" % (count, location))
dirs, files = xbmcvfs.listdir(location)
files = random.sample(files, count)
for i in range(len(files)):
files[i] = location + files[i]
return files
def trailers_from_net(count, genre, rating):
files = []
for i in range(count):
files.append("TODO: find trailer %d" % i)
return files
if __name__ == '__main__':
for arg in sys.argv[1:]:
(name, value) = arg.split('=')
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)
dialog = xbmcgui.Dialog()
ret = dialog.select('Cinematic: Select a program', programs)
del dialog
program_file = path + programs[ret]
filehandle = xbmcvfs.File(program_file)
program_json = filehandle.read()
filehandle.close()
program_data = json.loads(program_json)
print("=== conducting program %s" % program_data['name'])
filelist = []
for item in program_data['items']:
print("selecting %s" % item['name'])
settings = item['settings']
if settings['source'] == 'file':
filelist.append(settings['location'])
elif settings['source'] == 'dir':
filelist.extend(files_from_dir(settings['count'], settings['location']))
elif settings['source'] == 'trailer':
genre = 'TODO: find feature genre'
rating = 'TODO: find feature rating'
filelist.extend(trailers_from_net(settings['count'], genre, rating))
elif settings['source'] == 'feature':
filelist.append("TODO: find feature %d" % dbid)
print('=== playlist')
for filename in filelist:
print(" * %s" % filename)

15
addon.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.cinemavision" name="Cinematic" version="0.1" provider-name="Cinematic">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
</requires>
<extension point="xbmc.python.script" library="addon.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Execute a movie theater like workflow.</summary>
<description lang="en">Idea taken from the seemingly abandoned CinemaVision plugin.</description>
<language></language>
<platform>all</platform>
</extension>
</addon>

6
resources/settings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="Locations">
<setting id="cinematic_path" label="Main Directory" type="folder" source="files" />
</category>
</settings>