[skeb] add extractor for followed users (#5290)
needs 'Authorization' header from browser session -o headers.Authorization="Bearer ey…"
This commit is contained in:
@@ -790,7 +790,7 @@ Consider all listed sites to potentially be NSFW.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Skeb</td>
|
<td>Skeb</td>
|
||||||
<td>https://skeb.jp/</td>
|
<td>https://skeb.jp/</td>
|
||||||
<td>Followed Users, Posts, Search Results, User Profiles</td>
|
<td>Followed Creators, Followed Users, Posts, Search Results, User Profiles</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ class SkebExtractor(Extractor):
|
|||||||
def _init(self):
|
def _init(self):
|
||||||
self.thumbnails = self.config("thumbnails", False)
|
self.thumbnails = self.config("thumbnails", False)
|
||||||
self.article = self.config("article", False)
|
self.article = self.config("article", False)
|
||||||
self.headers = {
|
self.headers = {"Accept": "application/json, text/plain, */*"}
|
||||||
"Accept" : "application/json, text/plain, */*",
|
|
||||||
"Authorization": "Bearer null",
|
if "Authorization" not in self.session.headers:
|
||||||
}
|
self.headers["Authorization"] = "Bearer null"
|
||||||
|
|
||||||
def request(self, url, **kwargs):
|
def request(self, url, **kwargs):
|
||||||
while True:
|
while True:
|
||||||
@@ -55,6 +55,12 @@ class SkebExtractor(Extractor):
|
|||||||
url = file["file_url"]
|
url = file["file_url"]
|
||||||
yield Message.Url, url, text.nameext_from_url(url, post)
|
yield Message.Url, url, text.nameext_from_url(url, post)
|
||||||
|
|
||||||
|
def _items_users(self):
|
||||||
|
base = self.root + "/@"
|
||||||
|
for user in self.users():
|
||||||
|
user["_extractor"] = SkebUserExtractor
|
||||||
|
yield Message.Queue, base + user["screen_name"], user
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
"""Return post number"""
|
"""Return post number"""
|
||||||
|
|
||||||
@@ -83,6 +89,20 @@ class SkebExtractor(Extractor):
|
|||||||
return
|
return
|
||||||
params["offset"] += 30
|
params["offset"] += 30
|
||||||
|
|
||||||
|
def _pagination_users(self, endpoint, params):
|
||||||
|
url = "{}/api{}".format(self.root, endpoint)
|
||||||
|
params["offset"] = 0
|
||||||
|
params["limit"] = 90
|
||||||
|
|
||||||
|
while True:
|
||||||
|
data = self.request(
|
||||||
|
url, params=params, headers=self.headers).json()
|
||||||
|
yield from data
|
||||||
|
|
||||||
|
if len(data) < params["limit"]:
|
||||||
|
return
|
||||||
|
params["offset"] += params["limit"]
|
||||||
|
|
||||||
def _get_post_data(self, user_name, post_num):
|
def _get_post_data(self, user_name, post_num):
|
||||||
url = "{}/api/users/{}/works/{}".format(
|
url = "{}/api/users/{}/works/{}".format(
|
||||||
self.root, user_name, post_num)
|
self.root, user_name, post_num)
|
||||||
@@ -256,22 +276,23 @@ class SkebFollowingExtractor(SkebExtractor):
|
|||||||
pattern = r"(?:https?://)?skeb\.jp/@([^/?#]+)/following_creators"
|
pattern = r"(?:https?://)?skeb\.jp/@([^/?#]+)/following_creators"
|
||||||
example = "https://skeb.jp/@USER/following_creators"
|
example = "https://skeb.jp/@USER/following_creators"
|
||||||
|
|
||||||
def items(self):
|
items = SkebExtractor._items_users
|
||||||
for user in self.users():
|
|
||||||
url = "{}/@{}".format(self.root, user["screen_name"])
|
|
||||||
user["_extractor"] = SkebUserExtractor
|
|
||||||
yield Message.Queue, url, user
|
|
||||||
|
|
||||||
def users(self):
|
def users(self):
|
||||||
url = "{}/api/users/{}/following_creators".format(
|
endpoint = "/users/{}/following_creators".format(self.user_name)
|
||||||
self.root, self.user_name)
|
params = {"sort": "date"}
|
||||||
params = {"sort": "date", "offset": 0, "limit": 90}
|
return self._pagination_users(endpoint, params)
|
||||||
|
|
||||||
while True:
|
|
||||||
data = self.request(
|
|
||||||
url, params=params, headers=self.headers).json()
|
|
||||||
yield from data
|
|
||||||
|
|
||||||
if len(data) < params["limit"]:
|
class SkebFollowingUsersExtractor(SkebExtractor):
|
||||||
return
|
"""Extractor for your followed users"""
|
||||||
params["offset"] += params["limit"]
|
subcategory = "following-users"
|
||||||
|
pattern = r"(?:https?://)?skeb\.jp/following_users()"
|
||||||
|
example = "https://skeb.jp/following_users"
|
||||||
|
|
||||||
|
items = SkebExtractor._items_users
|
||||||
|
|
||||||
|
def users(self):
|
||||||
|
endpoint = "/following_users"
|
||||||
|
params = {}
|
||||||
|
return self._pagination_users(endpoint, params)
|
||||||
|
|||||||
@@ -273,6 +273,10 @@ SUBCATEGORY_MAP = {
|
|||||||
"sexcom": {
|
"sexcom": {
|
||||||
"pins": "User Pins",
|
"pins": "User Pins",
|
||||||
},
|
},
|
||||||
|
"skeb": {
|
||||||
|
"following" : "Followed Creators",
|
||||||
|
"following-users": "Followed Users",
|
||||||
|
},
|
||||||
"smugmug": {
|
"smugmug": {
|
||||||
"path": "Images from Users and Folders",
|
"path": "Images from Users and Folders",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -82,4 +82,12 @@ __tests__ = (
|
|||||||
"#class" : skeb.SkebFollowingExtractor,
|
"#class" : skeb.SkebFollowingExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://skeb.jp/following_users",
|
||||||
|
"#category": ("", "skeb", "following-users"),
|
||||||
|
"#class" : skeb.SkebFollowingUsersExtractor,
|
||||||
|
"#pattern" : skeb.SkebUserExtractor.pattern,
|
||||||
|
"#auth" : True,
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user