use f-strings when building 'pattern'
This commit is contained in:
@@ -657,8 +657,8 @@ class TwitterExtractor(Extractor):
|
||||
class TwitterHomeExtractor(TwitterExtractor):
|
||||
"""Extractor for Twitter home timelines"""
|
||||
subcategory = "home"
|
||||
pattern = (BASE_PATTERN +
|
||||
r"/(?:home(?:/fo(?:llowing|r[-_ ]?you()))?|i/timeline)/?$")
|
||||
pattern = (rf"{BASE_PATTERN}/"
|
||||
rf"(?:home(?:/fo(?:llowing|r[-_ ]?you()))?|i/timeline)/?$")
|
||||
example = "https://x.com/home"
|
||||
|
||||
def tweets(self):
|
||||
@@ -670,7 +670,7 @@ class TwitterHomeExtractor(TwitterExtractor):
|
||||
class TwitterSearchExtractor(TwitterExtractor):
|
||||
"""Extractor for Twitter search results"""
|
||||
subcategory = "search"
|
||||
pattern = BASE_PATTERN + r"/search/?\?(?:[^&#]+&)*q=([^&#]+)"
|
||||
pattern = rf"{BASE_PATTERN}/search/?\?(?:[^&#]+&)*q=([^&#]+)"
|
||||
example = "https://x.com/search?q=QUERY"
|
||||
|
||||
def metadata(self):
|
||||
@@ -701,7 +701,7 @@ class TwitterSearchExtractor(TwitterExtractor):
|
||||
class TwitterHashtagExtractor(TwitterExtractor):
|
||||
"""Extractor for Twitter hashtags"""
|
||||
subcategory = "hashtag"
|
||||
pattern = BASE_PATTERN + r"/hashtag/([^/?#]+)"
|
||||
pattern = rf"{BASE_PATTERN}/hashtag/([^/?#]+)"
|
||||
example = "https://x.com/hashtag/NAME"
|
||||
|
||||
def items(self):
|
||||
@@ -712,7 +712,7 @@ class TwitterHashtagExtractor(TwitterExtractor):
|
||||
|
||||
class TwitterUserExtractor(Dispatch, TwitterExtractor):
|
||||
"""Extractor for a Twitter user"""
|
||||
pattern = (BASE_PATTERN + r"/(?:"
|
||||
pattern = (rf"{BASE_PATTERN}/(?:"
|
||||
r"([^/?#]+)/?(?:$|\?|#)"
|
||||
r"|i(?:/user/|ntent/user\?user_id=)(\d+))")
|
||||
example = "https://x.com/USER"
|
||||
@@ -889,7 +889,7 @@ class TwitterLikesExtractor(TwitterExtractor):
|
||||
class TwitterBookmarkExtractor(TwitterExtractor):
|
||||
"""Extractor for bookmarked tweets"""
|
||||
subcategory = "bookmark"
|
||||
pattern = BASE_PATTERN + r"/i/bookmarks()"
|
||||
pattern = rf"{BASE_PATTERN}/i/bookmarks()"
|
||||
example = "https://x.com/i/bookmarks"
|
||||
|
||||
def tweets(self):
|
||||
@@ -905,7 +905,7 @@ class TwitterBookmarkExtractor(TwitterExtractor):
|
||||
class TwitterListExtractor(TwitterExtractor):
|
||||
"""Extractor for Twitter lists"""
|
||||
subcategory = "list"
|
||||
pattern = BASE_PATTERN + r"/i/lists/(\d+)/?$"
|
||||
pattern = rf"{BASE_PATTERN}/i/lists/(\d+)/?$"
|
||||
example = "https://x.com/i/lists/12345"
|
||||
|
||||
def tweets(self):
|
||||
@@ -915,7 +915,7 @@ class TwitterListExtractor(TwitterExtractor):
|
||||
class TwitterListMembersExtractor(TwitterExtractor):
|
||||
"""Extractor for members of a Twitter list"""
|
||||
subcategory = "list-members"
|
||||
pattern = BASE_PATTERN + r"/i/lists/(\d+)/members"
|
||||
pattern = rf"{BASE_PATTERN}/i/lists/(\d+)/members"
|
||||
example = "https://x.com/i/lists/12345/members"
|
||||
|
||||
def items(self):
|
||||
@@ -951,7 +951,7 @@ class TwitterCommunityExtractor(TwitterExtractor):
|
||||
directory_fmt = ("{category}", "Communities",
|
||||
"{community[name]} ({community[id]})")
|
||||
archive_fmt = "C_{community[id]}_{tweet_id}_{num}"
|
||||
pattern = BASE_PATTERN + r"/i/communities/(\d+)"
|
||||
pattern = rf"{BASE_PATTERN}/i/communities/(\d+)"
|
||||
example = "https://x.com/i/communities/12345"
|
||||
|
||||
def tweets(self):
|
||||
@@ -965,7 +965,7 @@ class TwitterCommunitiesExtractor(TwitterExtractor):
|
||||
subcategory = "communities"
|
||||
directory_fmt = TwitterCommunityExtractor.directory_fmt
|
||||
archive_fmt = TwitterCommunityExtractor.archive_fmt
|
||||
pattern = BASE_PATTERN + r"/([^/?#]+)/communities/?$"
|
||||
pattern = rf"{BASE_PATTERN}/([^/?#]+)/communities/?$"
|
||||
example = "https://x.com/i/communities"
|
||||
|
||||
def tweets(self):
|
||||
@@ -977,7 +977,7 @@ class TwitterEventExtractor(TwitterExtractor):
|
||||
subcategory = "event"
|
||||
directory_fmt = ("{category}", "Events",
|
||||
"{event[id]} {event[short_title]}")
|
||||
pattern = BASE_PATTERN + r"/i/events/(\d+)"
|
||||
pattern = rf"{BASE_PATTERN}/i/events/(\d+)"
|
||||
example = "https://x.com/i/events/12345"
|
||||
|
||||
def metadata(self):
|
||||
@@ -990,7 +990,7 @@ class TwitterEventExtractor(TwitterExtractor):
|
||||
class TwitterTweetExtractor(TwitterExtractor):
|
||||
"""Extractor for individual tweets"""
|
||||
subcategory = "tweet"
|
||||
pattern = (BASE_PATTERN + r"/([^/?#]+|i/web)/status/(\d+)"
|
||||
pattern = (rf"{BASE_PATTERN}/([^/?#]+|i/web)/status/(\d+)"
|
||||
r"/?(?:$|\?|#|photo/|video/)")
|
||||
example = "https://x.com/USER/status/12345"
|
||||
|
||||
@@ -1071,7 +1071,7 @@ class TwitterTweetExtractor(TwitterExtractor):
|
||||
class TwitterQuotesExtractor(TwitterExtractor):
|
||||
"""Extractor for quotes of a Tweet"""
|
||||
subcategory = "quotes"
|
||||
pattern = BASE_PATTERN + r"/(?:[^/?#]+|i/web)/status/(\d+)/quotes"
|
||||
pattern = rf"{BASE_PATTERN}/(?:[^/?#]+|i/web)/status/(\d+)/quotes"
|
||||
example = "https://x.com/USER/status/12345/quotes"
|
||||
|
||||
def items(self):
|
||||
|
||||
Reference in New Issue
Block a user