From 82c28015e2c45cf2dcf24f69397cd0e25846a8f6 Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 15 Aug 2022 00:23:22 +0200 Subject: [PATCH] reddit: support shorts urls --- app/reddit/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/reddit/lib.py b/app/reddit/lib.py index fde236e..b7ce21c 100644 --- a/app/reddit/lib.py +++ b/app/reddit/lib.py @@ -51,7 +51,7 @@ def parse_reddit_videos(data): continue try: # Note: youtube.com/ is not valid (404s), but seen in the wild. - match = re.match(r'^https?://(?:www.|m.)?(?:youtube.com/watch\?(?:.*&)?v=|youtu.be/|youtube.com/embed/|youtube.com/)([-_0-9A-Za-z]+)(?:[?&#]t=([0-9hms:]+))?', e['url']) + match = re.match(r'^https?://(?:www.|m.)?(?:youtube.com/watch\?(?:.*&)?v=|youtu.be/|youtube.com/(?:embed|shorts)/|youtube.com/)([-_0-9A-Za-z]+)(?:[?&#]t=([0-9hms:]+))?', e['url']) video_id = match.group(1) timestamp = match.group(2) maybe_length = re.match(r'.*[\[(](?:00:)?(\d\d?(?::\d\d){1,2})[\])]', e['title']) # .* to match last occurence in line (probably terrible for performance?) -- 2.39.3