Compare commits
No commits in common. "afd0e519b756c7720218c381ce7d030a9e2dec73" and "2680a960724b9b8ae4a7981d63f002b552c27ced" have entirely different histories.
afd0e519b7
...
2680a96072
2 changed files with 7 additions and 16 deletions
19
edit.py
19
edit.py
|
|
@ -13,6 +13,7 @@ import ox.web.auth
|
|||
|
||||
|
||||
base_url = None
|
||||
stream_resolution = 480
|
||||
prefix = '/mnt'
|
||||
render = './cache'
|
||||
pandora_client_config = {}
|
||||
|
|
@ -100,24 +101,15 @@ def sort_clips(edit, sort):
|
|||
s = sorted(clips, key=lambda c: ids.index(c['id']) if c['id'] in ids else -1)
|
||||
return s
|
||||
|
||||
def cache_clips(api, videos, use_source=False):
|
||||
def cache_clips(api, videos):
|
||||
for clip in videos:
|
||||
out = '%s/%s.mp4' % (render, clip['oshash'])
|
||||
if 'path' in clip:
|
||||
clip['src'] = clip['path']
|
||||
clip['path'] = out
|
||||
if not os.path.exists(out):
|
||||
url = clip['url']
|
||||
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)
|
||||
print(clip['url'], out)
|
||||
api.save_url(clip['url'], out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
@ -137,7 +129,6 @@ if __name__ == '__main__':
|
|||
opts = parser.parse_args()
|
||||
edit_url = opts.url
|
||||
use_local = opts.source == 'local'
|
||||
use_source = opts.source == 'source'
|
||||
prefix = opts.prefix
|
||||
parts = edit_url.split('/')
|
||||
site = parts[2]
|
||||
|
|
@ -238,7 +229,7 @@ if __name__ == '__main__':
|
|||
position = math.ceil(position / (1/25)) * 1/25
|
||||
|
||||
if not use_local:
|
||||
cache_clips(api, videos, use_source)
|
||||
cache_clips(api, videos)
|
||||
|
||||
name = normalize(edit_id)
|
||||
if sort_by != 'year':
|
||||
|
|
|
|||
|
|
@ -70,8 +70,7 @@ for clip in edit:
|
|||
})
|
||||
position += duration
|
||||
continue
|
||||
src_info = ox.avinfo(clip['path'])
|
||||
clip_aspect = src_info['video'][0]['width'] / src_info['video'][0]['height']
|
||||
clip_aspect = clip['resolution'][0] / clip['resolution'][1]
|
||||
if clip_aspect < aspect:
|
||||
x = width
|
||||
y = int(x / clip_aspect)
|
||||
|
|
@ -104,6 +103,7 @@ for clip in edit:
|
|||
print('skip empty clip', clip)
|
||||
else:
|
||||
files.append(out)
|
||||
src_info = ox.avinfo(clip['path'])
|
||||
vid = src_info['video'][0]['id']
|
||||
if not src_info['audio']:
|
||||
audio = ['-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=48000']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue