aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/util.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2021-08-08 20:29:42 -0700
committerJesús <heckyel@hyperbola.info>2021-08-09 12:27:49 -0500
commit6c6c469fbd4277d80b3309b796466c32ec19a0d0 (patch)
treec65314b3680b62c8e4c2d482b027b9900b3d042b /youtube/util.py
parent2039972ab32ac7d7ceb6be811a7d7d9019377b2c (diff)
downloadyt-local-6c6c469fbd4277d80b3309b796466c32ec19a0d0.tar.lz
yt-local-6c6c469fbd4277d80b3309b796466c32ec19a0d0.tar.xz
yt-local-6c6c469fbd4277d80b3309b796466c32ec19a0d0.zip
Prefix youtube URLs in video descriptions and channel about page
Closes #75 Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/util.py')
-rw-r--r--youtube/util.py7
1 files changed, 7 insertions, 0 deletions
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