Fix preview_thumbnails
use 'deep_get' for storyboard
This commit is contained in:
parent
263469cd30
commit
1fbc0cdd46
@ -521,19 +521,19 @@ def get_storyboard_vtt():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
spec_url = request.args.get('spec_url')
|
spec_url = request.args.get('spec_url')
|
||||||
url, *l = spec_url.split('|')
|
url, *boards = spec_url.split('|')
|
||||||
url1, q = url.split('?')
|
base_url, q = url.split('?')
|
||||||
q = parse_qs(q)
|
q = parse_qs(q) # for url query
|
||||||
|
|
||||||
storyboard = None
|
storyboard = None
|
||||||
wanted_height = 90
|
wanted_height = 90
|
||||||
|
|
||||||
for i, board in enumerate(l):
|
for i, board in enumerate(boards):
|
||||||
*t, _, sigh = board.split("#")
|
*t, _, sigh = board.split("#")
|
||||||
width, height, count, width_cnt, height_cnt, interval = map(int, t)
|
width, height, count, width_cnt, height_cnt, interval = map(int, t)
|
||||||
if height != wanted_height: continue
|
if height != wanted_height: continue
|
||||||
q['sigh'] = [sigh]
|
q['sigh'] = [sigh]
|
||||||
url = f"{url1}?{urlencode(q, doseq=True)}"
|
url = f"{base_url}?{urlencode(q, doseq=True)}"
|
||||||
storyboard = SimpleNamespace(
|
storyboard = SimpleNamespace(
|
||||||
url = url.replace("$L", str(i)).replace("$N", "M$M"),
|
url = url.replace("$L", str(i)).replace("$N", "M$M"),
|
||||||
width = width,
|
width = width,
|
||||||
@ -553,8 +553,8 @@ def get_storyboard_vtt():
|
|||||||
m, s = divmod(s, 60)
|
m, s = divmod(s, 60)
|
||||||
return f"{h:02}:{m:02}:{s:02}.{ms:03}"
|
return f"{h:02}:{m:02}:{s:02}.{ms:03}"
|
||||||
|
|
||||||
r = "WEBVTT"
|
r = "WEBVTT" # result
|
||||||
ts = 0
|
ts = 0 # current timestamp
|
||||||
|
|
||||||
for i in range(storyboard.storyboard_count):
|
for i in range(storyboard.storyboard_count):
|
||||||
url = '/' + storyboard.url.replace("$M", str(i))
|
url = '/' + storyboard.url.replace("$M", str(i))
|
||||||
|
@ -669,8 +669,7 @@ def extract_watch_info(polymer_json):
|
|||||||
|
|
||||||
# other stuff
|
# other stuff
|
||||||
info['author_url'] = 'https://www.youtube.com/channel/' + info['author_id'] if info['author_id'] else None
|
info['author_url'] = 'https://www.youtube.com/channel/' + info['author_id'] if info['author_id'] else None
|
||||||
sb = player_response.get('storyboards')
|
info['storyboard_spec_url'] = deep_get(player_response, 'storyboards', 'playerStoryboardSpecRenderer', 'spec')
|
||||||
info['storyboard_spec_url'] = sb['playerStoryboardSpecRenderer']['spec'] if sb else None
|
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user