use default options instead of passing all over the place
This commit is contained in:
parent
ce51e8c2c4
commit
2a5d741ccf
3 changed files with 14 additions and 3 deletions
14
render.py
14
render.py
|
|
@ -506,6 +506,7 @@ def parse_lang(lang):
|
|||
|
||||
|
||||
def render_all(options):
|
||||
options = load_defaults(options)
|
||||
prefix = options['prefix']
|
||||
duration = int(options['duration'])
|
||||
base = int(options['offset'])
|
||||
|
|
@ -897,9 +898,22 @@ def scene_subtitles(scene, options):
|
|||
offset += clip['duration']
|
||||
return subs
|
||||
|
||||
|
||||
def load_defaults(options):
|
||||
path = os.path.join(options["prefix"], "options.json")
|
||||
if os.path.exists(path):
|
||||
with open(path) as fd:
|
||||
defaults = json.loads(fd)
|
||||
for key in defaults:
|
||||
if key not in options:
|
||||
options[key] = defaults[key]
|
||||
return options
|
||||
|
||||
|
||||
def update_subtitles(options):
|
||||
import item.models
|
||||
|
||||
options = load_defaults(options)
|
||||
prefix = Path(options['prefix'])
|
||||
base = int(options['offset'])
|
||||
lang, tlang = parse_lang(options["lang"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue