You've already forked FrameTour-RenderWorker
对接
This commit is contained in:
@ -2,6 +2,8 @@ import json
|
||||
import os
|
||||
import logging
|
||||
|
||||
from util import api, oss
|
||||
|
||||
TEMPLATES = {}
|
||||
logger = logging.getLogger("template")
|
||||
|
||||
@ -71,8 +73,42 @@ def get_template_def(template_id):
|
||||
return TEMPLATES.get(template_id)
|
||||
|
||||
def download_template(template_id):
|
||||
logger.info(f"下载模板:{template_id}")
|
||||
...
|
||||
template_info = api.get_template_info(template_id)
|
||||
# download template assets
|
||||
overall_template = template_info['overall_template']
|
||||
video_parts = template_info['video_parts']
|
||||
def _download_assets(_template):
|
||||
if 'source' in _template:
|
||||
if str(_template['source']).startswith("http"):
|
||||
_, _fn = os.path.split(_template['source'])
|
||||
oss.download_from_oss(_template['source'], os.path.join(template_info['local_path'], _fn))
|
||||
_template['source'] = _fn
|
||||
if 'overlays' in _template:
|
||||
for i in range(len(_template['overlays'])):
|
||||
overlay = _template['overlays'][i]
|
||||
if str(overlay).startswith("http"):
|
||||
_, _fn = os.path.split(overlay)
|
||||
oss.download_from_oss(overlay, os.path.join(template_info['local_path'], _fn))
|
||||
_template['overlays'][i] = _fn
|
||||
if 'luts' in _template:
|
||||
for i in range(len(_template['luts'])):
|
||||
lut = _template['luts'][i]
|
||||
if str(lut).startswith("http"):
|
||||
_, _fn = os.path.split(lut)
|
||||
oss.download_from_oss(lut, os.path.join(template_info['local_path'], _fn))
|
||||
_template['luts'][i] = _fn
|
||||
if 'audios' in _template:
|
||||
for i in range(len(_template['audios'])):
|
||||
if str(_template['audios'][i]).startswith("http"):
|
||||
_, _fn = os.path.split(_template['audios'][i])
|
||||
oss.download_from_oss(_template['audios'][i], os.path.join(template_info['local_path'], _fn))
|
||||
_template['audios'][i] = _fn
|
||||
_download_assets(overall_template)
|
||||
for video_part in video_parts:
|
||||
_download_assets(video_part)
|
||||
with open(os.path.join(template_info['local_path'], 'template.json'), 'w', encoding='utf-8') as f:
|
||||
json.dump(template_info, f)
|
||||
load_template(template_id, template_info['local_path'])
|
||||
|
||||
|
||||
def analyze_template(template_id):
|
||||
|
Reference in New Issue
Block a user