~cadence/tube-devel

NewLeaf: Remove extraneous " align:start position:0%" on auto-generated captions v1 APPLIED

~lomanic
~lomanic: 1
 Remove extraneous " align:start position:0%" on auto-generated captions

 1 files changed, 4 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~cadence/tube-devel/patches/21804/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH NewLeaf] Remove extraneous " align:start position:0%" on auto-generated captions Export this patch

~lomanic
From: Lomanic <lomanic@hotmail.fr>

---
 extractors/captions.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/extractors/captions.py b/extractors/captions.py
index 2bf5287..1bd8a34 100644
--- a/extractors/captions.py
+++ b/extractors/captions.py
@@ -3,6 +3,7 @@ from extractors.video import extract_video
from tools.converters import escape_html_textcontent, get_subtitle_api_url
from urllib.parse import urlencode
import xml.etree.ElementTree as ET
import re

def extract_captions(id, **kwargs):
	if "label" in kwargs and "auto-generated" in kwargs["label"]:
@@ -20,6 +21,9 @@ def extract_captions_from_dict(captions, *, lang=None, label=None):
	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

# List of captions directly from youtube, but no automatic
-- 
2.30.2
You made a fair argument. Patch applied.