use 'operator +' when building 'pattern'

This commit is contained in:
Mike Fährmann
2025-12-20 21:10:59 +01:00
parent e006d26c8e
commit d0f06be0d2
32 changed files with 129 additions and 129 deletions

View File

@@ -16,7 +16,7 @@ import random
BASE_PATTERN = (r"(?:https?://)?(?:www\.|mobile\.)?"
r"(?:(?:[fv]x)?twitter|(?:fix(?:up|v))?x)\.com")
USER_PATTERN = rf"{BASE_PATTERN}/([^/?#]+)"
USER_PATTERN = BASE_PATTERN + r"/([^/?#]+)"
class TwitterExtractor(Extractor):
@@ -749,7 +749,7 @@ class TwitterUserExtractor(Dispatch, TwitterExtractor):
class TwitterTimelineExtractor(TwitterExtractor):
"""Extractor for a Twitter user timeline"""
subcategory = "timeline"
pattern = rf"{USER_PATTERN}/timeline(?!\w)"
pattern = USER_PATTERN + r"/timeline(?!\w)"
example = "https://x.com/USER/timeline"
def _init_cursor(self):
@@ -846,7 +846,7 @@ class TwitterTimelineExtractor(TwitterExtractor):
class TwitterTweetsExtractor(TwitterExtractor):
"""Extractor for Tweets from a user's Tweets timeline"""
subcategory = "tweets"
pattern = rf"{USER_PATTERN}/tweets(?!\w)"
pattern = USER_PATTERN + r"/tweets(?!\w)"
example = "https://x.com/USER/tweets"
def tweets(self):
@@ -856,7 +856,7 @@ class TwitterTweetsExtractor(TwitterExtractor):
class TwitterRepliesExtractor(TwitterExtractor):
"""Extractor for Tweets from a user's timeline including replies"""
subcategory = "replies"
pattern = rf"{USER_PATTERN}/with_replies(?!\w)"
pattern = USER_PATTERN + r"/with_replies(?!\w)"
example = "https://x.com/USER/with_replies"
def tweets(self):
@@ -866,7 +866,7 @@ class TwitterRepliesExtractor(TwitterExtractor):
class TwitterHighlightsExtractor(TwitterExtractor):
"""Extractor for Tweets from a user's highlights timeline"""
subcategory = "highlights"
pattern = rf"{USER_PATTERN}/highlights(?!\w)"
pattern = USER_PATTERN + r"/highlights(?!\w)"
example = "https://x.com/USER/highlights"
def tweets(self):
@@ -876,7 +876,7 @@ class TwitterHighlightsExtractor(TwitterExtractor):
class TwitterMediaExtractor(TwitterExtractor):
"""Extractor for Tweets from a user's Media timeline"""
subcategory = "media"
pattern = rf"{USER_PATTERN}/media(?!\w)"
pattern = USER_PATTERN + r"/media(?!\w)"
example = "https://x.com/USER/media"
def tweets(self):
@@ -886,7 +886,7 @@ class TwitterMediaExtractor(TwitterExtractor):
class TwitterLikesExtractor(TwitterExtractor):
"""Extractor for liked tweets"""
subcategory = "likes"
pattern = rf"{USER_PATTERN}/likes(?!\w)"
pattern = USER_PATTERN + r"/likes(?!\w)"
example = "https://x.com/USER/likes"
def metadata(self):
@@ -936,7 +936,7 @@ class TwitterListMembersExtractor(TwitterExtractor):
class TwitterFollowingExtractor(TwitterExtractor):
"""Extractor for followed users"""
subcategory = "following"
pattern = rf"{USER_PATTERN}/following(?!\w)"
pattern = USER_PATTERN + r"/following(?!\w)"
example = "https://x.com/USER/following"
def items(self):
@@ -947,7 +947,7 @@ class TwitterFollowingExtractor(TwitterExtractor):
class TwitterFollowersExtractor(TwitterExtractor):
"""Extractor for a user's followers"""
subcategory = "followers"
pattern = rf"{USER_PATTERN}/followers(?!\w)"
pattern = USER_PATTERN + r"/followers(?!\w)"
example = "https://x.com/USER/followers"
def items(self):
@@ -1093,7 +1093,7 @@ class TwitterQuotesExtractor(TwitterExtractor):
class TwitterInfoExtractor(TwitterExtractor):
"""Extractor for a user's profile data"""
subcategory = "info"
pattern = rf"{USER_PATTERN}/info"
pattern = USER_PATTERN + r"/info"
example = "https://x.com/USER/info"
def items(self):
@@ -1112,7 +1112,7 @@ class TwitterAvatarExtractor(TwitterExtractor):
subcategory = "avatar"
filename_fmt = "avatar {date}.{extension}"
archive_fmt = "AV_{user[id]}_{date}"
pattern = rf"{USER_PATTERN}/photo"
pattern = USER_PATTERN + r"/photo"
example = "https://x.com/USER/photo"
def tweets(self):
@@ -1134,7 +1134,7 @@ class TwitterBackgroundExtractor(TwitterExtractor):
subcategory = "background"
filename_fmt = "background {date}.{extension}"
archive_fmt = "BG_{user[id]}_{date}"
pattern = rf"{USER_PATTERN}/header_photo"
pattern = USER_PATTERN + r"/header_photo"
example = "https://x.com/USER/header_photo"
def tweets(self):