mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-05-04 16:41:37 +00:00
Captions: Python code cleanup and optimisation
This commit is contained in:
parent
6709aa30c2
commit
8e69928756
2 changed files with 19 additions and 30 deletions
|
|
@ -173,22 +173,21 @@ def extract_video(id):
|
|||
"second__width": format["width"],
|
||||
"second__height": format["height"]
|
||||
})
|
||||
|
||||
if "requested_subtitles" in info and info["requested_subtitles"]:
|
||||
|
||||
if info.get("requested_subtitles"):
|
||||
for language_code, subtitle in info["requested_subtitles"].items():
|
||||
|
||||
if language_code != "live_chat":
|
||||
subtitle_url = subtitle["url"]
|
||||
label = get_language_label_from_url(subtitle_url)
|
||||
subtitle_api_url = get_subtitle_api_url(id, label, language_code)
|
||||
if language_code == "live_chat":
|
||||
continue
|
||||
|
||||
result["captions"].append({
|
||||
"label": label if label != "" else language_code,
|
||||
"languageCode": language_code,
|
||||
"url": subtitle_api_url,
|
||||
"second__subtitleUrl": subtitle_url # Direct YouTube url
|
||||
})
|
||||
subtitle_url = subtitle["url"]
|
||||
label = get_language_label_from_url(subtitle_url)
|
||||
subtitle_api_url = get_subtitle_api_url(id, label, language_code)
|
||||
result["captions"].append({
|
||||
"label": label if label != "" else language_code,
|
||||
"languageCode": language_code,
|
||||
"url": subtitle_api_url,
|
||||
"second__subtitleUrl": subtitle_url # Direct YouTube url
|
||||
})
|
||||
|
||||
|
||||
result = get_more_stuff_from_file(info["id"], result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue