add render mode on pandora server
This commit is contained in:
parent
8a8c09dc07
commit
09e1f2833c
1 changed files with 28 additions and 13 deletions
41
edit.py
41
edit.py
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
import ox.web.auth
|
import ox.web.auth
|
||||||
|
@ -100,24 +101,37 @@ 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, use_source=False):
|
def get_pandora_media_path(oshash):
|
||||||
|
h = oshash
|
||||||
|
path = '/srv/pandora/data/media/' + '/'.join([h[:2], h[2:4], h[4:6], h[6:]])
|
||||||
|
path = glob('%s/data.*' % path)
|
||||||
|
if path:
|
||||||
|
path = path[0]
|
||||||
|
else:
|
||||||
|
path = ox.sorted_strings(glob('%s/*.mp4' % path))[-1]
|
||||||
|
return path
|
||||||
|
|
||||||
|
def cache_clips(api, videos, use_source=False, use_pandora=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):
|
||||||
url = clip['url']
|
if use_pandora:
|
||||||
if use_source:
|
os.symlink(get_pandora_media_path(clip['oshash']), out)
|
||||||
name = url.split('/')[-1].split('.')[0]
|
else:
|
||||||
resolution, part = name.split('p')
|
url = clip['url']
|
||||||
if part and part.isdigit():
|
if use_source:
|
||||||
part = int(part)
|
name = url.split('/')[-1].split('.')[0]
|
||||||
else:
|
resolution, part = name.split('p')
|
||||||
part = 1
|
if part and part.isdigit():
|
||||||
url = '/'.join(url.split('/')[:-1] + ['download', 'source', str(part)])
|
part = int(part)
|
||||||
print(url, out)
|
else:
|
||||||
api.save_url(url, out)
|
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__':
|
||||||
|
@ -138,6 +152,7 @@ if __name__ == '__main__':
|
||||||
edit_url = opts.url
|
edit_url = opts.url
|
||||||
use_local = opts.source == 'local'
|
use_local = opts.source == 'local'
|
||||||
use_source = opts.source == 'source'
|
use_source = opts.source == 'source'
|
||||||
|
use_pandora = opts.source == 'pandora'
|
||||||
prefix = opts.prefix
|
prefix = opts.prefix
|
||||||
parts = edit_url.split('/')
|
parts = edit_url.split('/')
|
||||||
site = parts[2]
|
site = parts[2]
|
||||||
|
@ -238,7 +253,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, use_source)
|
cache_clips(api, videos, use_source, use_pandora)
|
||||||
|
|
||||||
name = normalize(edit_id)
|
name = normalize(edit_id)
|
||||||
if sort_by != 'year':
|
if sort_by != 'year':
|
||||||
|
|
Loading…
Reference in a new issue