|
|
@ -264,6 +264,27 @@ class TwitterMediaExtractor(TwitterExtractor):
|
|
|
|
return TwitterAPI(self).timeline_media(self.user)
|
|
|
|
return TwitterAPI(self).timeline_media(self.user)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TwitterLikesExtractor(TwitterExtractor):
|
|
|
|
|
|
|
|
"""Extractor for liked tweets"""
|
|
|
|
|
|
|
|
subcategory = "likes"
|
|
|
|
|
|
|
|
pattern = (r"(?:https?://)?(?:www\.|mobile\.)?twitter\.com"
|
|
|
|
|
|
|
|
r"/(?!search)([^/?&#]+)/likes(?!\w)")
|
|
|
|
|
|
|
|
test = ("https://twitter.com/supernaturepics/likes",)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tweets(self):
|
|
|
|
|
|
|
|
return TwitterAPI(self).timeline_favorites(self.user)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TwitterBookmarkExtractor(TwitterExtractor):
|
|
|
|
|
|
|
|
"""Extractor for bookmarked tweets"""
|
|
|
|
|
|
|
|
subcategory = "bookmark"
|
|
|
|
|
|
|
|
pattern = r"(?:https?://)?(?:www\.|mobile\.)?twitter\.com/i/bookmarks()"
|
|
|
|
|
|
|
|
test = ("https://twitter.com/i/bookmarks",)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tweets(self):
|
|
|
|
|
|
|
|
return TwitterAPI(self).timeline_bookmark()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TwitterSearchExtractor(TwitterExtractor):
|
|
|
|
class TwitterSearchExtractor(TwitterExtractor):
|
|
|
|
"""Extractor for all images from a search timeline"""
|
|
|
|
"""Extractor for all images from a search timeline"""
|
|
|
|
subcategory = "search"
|
|
|
|
subcategory = "search"
|
|
|
@ -344,16 +365,6 @@ class TwitterTweetExtractor(TwitterExtractor):
|
|
|
|
return TwitterAPI(self).tweet(self.tweet_id)
|
|
|
|
return TwitterAPI(self).tweet(self.tweet_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TwitterBookmarkExtractor(TwitterExtractor):
|
|
|
|
|
|
|
|
"""Extractor for bookmarked tweets"""
|
|
|
|
|
|
|
|
subcategory = "bookmark"
|
|
|
|
|
|
|
|
pattern = r"(?:https?://)?(?:www\.|mobile\.)?twitter\.com/i/bookmarks()"
|
|
|
|
|
|
|
|
test = ("https://twitter.com/i/bookmarks",)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tweets(self):
|
|
|
|
|
|
|
|
return TwitterAPI(self).bookmarks()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TwitterAPI():
|
|
|
|
class TwitterAPI():
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, extractor):
|
|
|
|
def __init__(self, extractor):
|
|
|
@ -430,6 +441,15 @@ class TwitterAPI():
|
|
|
|
endpoint = "2/timeline/media/{}.json".format(user["rest_id"])
|
|
|
|
endpoint = "2/timeline/media/{}.json".format(user["rest_id"])
|
|
|
|
return self._pagination(endpoint)
|
|
|
|
return self._pagination(endpoint)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def timeline_favorites(self, screen_name):
|
|
|
|
|
|
|
|
user = self.user_by_screen_name(screen_name)
|
|
|
|
|
|
|
|
endpoint = "2/timeline/favorites/{}.json".format(user["rest_id"])
|
|
|
|
|
|
|
|
return self._pagination(endpoint)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def timeline_bookmark(self):
|
|
|
|
|
|
|
|
endpoint = "2/timeline/bookmark.json"
|
|
|
|
|
|
|
|
return self._pagination(endpoint)
|
|
|
|
|
|
|
|
|
|
|
|
def search(self, query):
|
|
|
|
def search(self, query):
|
|
|
|
endpoint = "2/search/adaptive.json"
|
|
|
|
endpoint = "2/search/adaptive.json"
|
|
|
|
params = self.params.copy()
|
|
|
|
params = self.params.copy()
|
|
|
@ -437,10 +457,6 @@ class TwitterAPI():
|
|
|
|
return self._pagination(
|
|
|
|
return self._pagination(
|
|
|
|
endpoint, params, "sq-I-t-", "sq-cursor-bottom")
|
|
|
|
endpoint, params, "sq-I-t-", "sq-cursor-bottom")
|
|
|
|
|
|
|
|
|
|
|
|
def bookmarks(self):
|
|
|
|
|
|
|
|
endpoint = "2/timeline/bookmark.json"
|
|
|
|
|
|
|
|
return self._pagination(endpoint)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def user_by_screen_name(self, screen_name):
|
|
|
|
def user_by_screen_name(self, screen_name):
|
|
|
|
endpoint = "graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName"
|
|
|
|
endpoint = "graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName"
|
|
|
|
params = {
|
|
|
|
params = {
|
|
|
|