From 423599ce9547ebfe580cfca7590f5067c93528c8 Mon Sep 17 00:00:00 2001 From: fireattack Date: Mon, 25 Mar 2024 11:45:04 +0800 Subject: [PATCH] [twitter] fix pattern for single tweet (#5371) - Add optional slash - Update tests to include some non-standard tweet URLs --- gallery_dl/extractor/twitter.py | 2 +- test/results/twitter.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index a5bd9840..97387df7 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -736,7 +736,7 @@ class TwitterEventExtractor(TwitterExtractor): class TwitterTweetExtractor(TwitterExtractor): """Extractor for individual tweets""" subcategory = "tweet" - pattern = BASE_PATTERN + r"/([^/?#]+|i/web)/status/(\d+)/?$" + pattern = BASE_PATTERN + r"/([^/?#]+|i/web)/status/(\d+)/?(?:$|[?#])" example = "https://twitter.com/USER/status/12345" def __init__(self, match): diff --git a/test/results/twitter.py b/test/results/twitter.py index 2d43ebf8..4ceb63b9 100644 --- a/test/results/twitter.py +++ b/test/results/twitter.py @@ -316,7 +316,7 @@ __tests__ = ( }, { - "#url" : "https://twitter.com/perrypumas/status/1065692031626829824", + "#url" : "https://twitter.com/perrypumas/status/1065692031626829824?s=20", "#comment" : "video", "#category": ("", "twitter", "tweet"), "#class" : twitter.TwitterTweetExtractor, @@ -324,7 +324,7 @@ __tests__ = ( }, { - "#url" : "https://twitter.com/playpokemon/status/1263832915173048321", + "#url" : "https://twitter.com/playpokemon/status/1263832915173048321/", "#comment" : "content with emoji, newlines, hashtags (#338)", "#category": ("", "twitter", "tweet"), "#class" : twitter.TwitterTweetExtractor,