From 6c6c469fbd4277d80b3309b796466c32ec19a0d0 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 8 Aug 2021 20:29:42 -0700 Subject: Prefix youtube URLs in video descriptions and channel about page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #75 Signed-off-by: Jesús --- youtube/util.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'youtube/util.py') diff --git a/youtube/util.py b/youtube/util.py index 462d371..4070f12 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -515,6 +515,13 @@ def update_query_string(query_string, items): return urllib.parse.urlencode(parameters, doseq=True) +YOUTUBE_DOMAINS = ('youtube.com', 'youtu.be', 'youtube-nocookie.com') +YOUTUBE_URL_RE_STR = r'https?://(?:[a-zA-Z0-9_-]*\.)?(?:' +YOUTUBE_URL_RE_STR += r'|'.join(map(re.escape, YOUTUBE_DOMAINS)) +YOUTUBE_URL_RE_STR += r')(?:/[^"]*)?' +YOUTUBE_URL_RE = re.compile(YOUTUBE_URL_RE_STR) + + def prefix_url(url): if url is None: return None -- cgit v1.2.3