mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-03-07 13:01:37 +00:00
Captions: Error checking
This commit is contained in:
parent
8e69928756
commit
c837828a22
2 changed files with 22 additions and 8 deletions
|
|
@ -29,6 +29,12 @@ def extract_captions_from_video(id):
|
|||
def extract_captions_from_api(id):
|
||||
url = "https://video.google.com/timedtext?hl=en&type=list&v=%s" % id
|
||||
with requests.get(url) as r:
|
||||
if r.status_code == 404:
|
||||
return {
|
||||
"error": "Video unavailable",
|
||||
"identifier": "NOT_FOUND"
|
||||
}
|
||||
|
||||
r.raise_for_status()
|
||||
|
||||
transcript = ET.fromstring(r.content.decode("utf8"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue