mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2024-11-21 23:27:29 +00:00
Don't fail if captions field is missing
This commit is contained in:
parent
be8a2dad5f
commit
5125bb9461
@ -285,26 +285,27 @@ def get_more_stuff_from_file(id, result):
|
|||||||
f["qualityLabel"] = label
|
f["qualityLabel"] = label
|
||||||
f["second__order"] = format_order(f)
|
f["second__order"] = format_order(f)
|
||||||
|
|
||||||
for track in player_response["captions"]["playerCaptionsTracklistRenderer"]["captionTracks"]:
|
if "captions" in player_response:
|
||||||
# safely editing the track format by taking apart the url...
|
for track in player_response["captions"]["playerCaptionsTracklistRenderer"]["captionTracks"]:
|
||||||
url = track["baseUrl"]
|
# safely editing the track format by taking apart the url...
|
||||||
parts = urlparse(url)
|
url = track["baseUrl"]
|
||||||
qs = parse_qs(parts.query)
|
parts = urlparse(url)
|
||||||
qs["format"] = ["vtt"]
|
qs = parse_qs(parts.query)
|
||||||
qs = urlencode(qs, doseq=True)
|
qs["format"] = ["vtt"]
|
||||||
# ...and putting it back together...
|
qs = urlencode(qs, doseq=True)
|
||||||
parts = parts._replace(query=qs)
|
# ...and putting it back together...
|
||||||
url = parts.geturl()
|
parts = parts._replace(query=qs)
|
||||||
# now make the caption object
|
url = parts.geturl()
|
||||||
label = combine_runs(track["name"])
|
# now make the caption object
|
||||||
language_code = track["languageCode"]
|
label = combine_runs(track["name"])
|
||||||
subtitle_api_url = get_subtitle_api_url(id, label, language_code)
|
language_code = track["languageCode"]
|
||||||
result["captions"].append({
|
subtitle_api_url = get_subtitle_api_url(id, label, language_code)
|
||||||
"label": label,
|
result["captions"].append({
|
||||||
"languageCode": language_code,
|
"label": label,
|
||||||
"url": subtitle_api_url,
|
"languageCode": language_code,
|
||||||
"second__remoteUrl": url
|
"url": subtitle_api_url,
|
||||||
})
|
"second__remoteUrl": url
|
||||||
|
})
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
print("messed up extracting recommendations.")
|
print("messed up extracting recommendations.")
|
||||||
|
Loading…
Reference in New Issue
Block a user