render from uploaded source
This commit is contained in:
parent
2680a96072
commit
0aaf1a9263
1 changed files with 14 additions and 5 deletions
19
edit.py
19
edit.py
|
@ -13,7 +13,6 @@ import ox.web.auth
|
||||||
|
|
||||||
|
|
||||||
base_url = None
|
base_url = None
|
||||||
stream_resolution = 480
|
|
||||||
prefix = '/mnt'
|
prefix = '/mnt'
|
||||||
render = './cache'
|
render = './cache'
|
||||||
pandora_client_config = {}
|
pandora_client_config = {}
|
||||||
|
@ -101,15 +100,24 @@ def sort_clips(edit, sort):
|
||||||
s = sorted(clips, key=lambda c: ids.index(c['id']) if c['id'] in ids else -1)
|
s = sorted(clips, key=lambda c: ids.index(c['id']) if c['id'] in ids else -1)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def cache_clips(api, videos):
|
def cache_clips(api, videos, use_source=False):
|
||||||
for clip in videos:
|
for clip in videos:
|
||||||
out = '%s/%s.mp4' % (render, clip['oshash'])
|
out = '%s/%s.mp4' % (render, clip['oshash'])
|
||||||
if 'path' in clip:
|
if 'path' in clip:
|
||||||
clip['src'] = clip['path']
|
clip['src'] = clip['path']
|
||||||
clip['path'] = out
|
clip['path'] = out
|
||||||
if not os.path.exists(out):
|
if not os.path.exists(out):
|
||||||
print(clip['url'], out)
|
url = clip['url']
|
||||||
api.save_url(clip['url'], out)
|
if use_source:
|
||||||
|
name = url.split('/')[-1].split('.')[0]
|
||||||
|
resolution, part = name.split('p')
|
||||||
|
if part and part.isdigit():
|
||||||
|
part = int(part)
|
||||||
|
else:
|
||||||
|
part = 1
|
||||||
|
url = '/'.join(url.split('/')[:-1] + ['download', 'source', str(part)])
|
||||||
|
print(url, out)
|
||||||
|
api.save_url(url, out)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -129,6 +137,7 @@ if __name__ == '__main__':
|
||||||
opts = parser.parse_args()
|
opts = parser.parse_args()
|
||||||
edit_url = opts.url
|
edit_url = opts.url
|
||||||
use_local = opts.source == 'local'
|
use_local = opts.source == 'local'
|
||||||
|
use_source = opts.source == 'source'
|
||||||
prefix = opts.prefix
|
prefix = opts.prefix
|
||||||
parts = edit_url.split('/')
|
parts = edit_url.split('/')
|
||||||
site = parts[2]
|
site = parts[2]
|
||||||
|
@ -229,7 +238,7 @@ if __name__ == '__main__':
|
||||||
position = math.ceil(position / (1/25)) * 1/25
|
position = math.ceil(position / (1/25)) * 1/25
|
||||||
|
|
||||||
if not use_local:
|
if not use_local:
|
||||||
cache_clips(api, videos)
|
cache_clips(api, videos, use_source)
|
||||||
|
|
||||||
name = normalize(edit_id)
|
name = normalize(edit_id)
|
||||||
if sort_by != 'year':
|
if sort_by != 'year':
|
||||||
|
|
Loading…
Reference in a new issue