mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-03-18 02:11:36 +00:00
Remove with requests when it is unnecessary
This commit is contained in:
parent
73b4fbabf7
commit
68cfbb809f
6 changed files with 244 additions and 244 deletions
|
|
@ -16,12 +16,12 @@ def extract_captions_from_dict(captions, *, lang=None, label=None):
|
|||
return captions
|
||||
|
||||
url = next(caption["second__remoteUrl"] for caption in captions["captions"] if caption["languageCode"] == lang or caption["label"] == label)
|
||||
with requests.get(url) as r:
|
||||
r.raise_for_status()
|
||||
# remove extraneous " align:start position:0%" on timestamps lines on auto-generated captions
|
||||
if (lang and "auto-generated" in lang) or (label and "auto-generated" in label):
|
||||
return re.sub(r"^([0-9:.]+ --> [0-9:.]+).*$", r"\1", r.content.decode("utf8"), flags=re.MULTILINE)
|
||||
return r
|
||||
r = requests.get(url)
|
||||
r.raise_for_status()
|
||||
# remove extraneous " align:start position:0%" on timestamps lines on auto-generated captions
|
||||
if (lang and "auto-generated" in lang) or (label and "auto-generated" in label):
|
||||
return re.sub(r"^([0-9:.]+ --> [0-9:.]+).*$", r"\1", r.content.decode("utf8"), flags=re.MULTILINE)
|
||||
return r
|
||||
|
||||
def extract_captions_from_video(id):
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue