[pixiv] support fetching privately followed users (fixes #1628)
This commit is contained in:
@@ -321,34 +321,30 @@ class PixivFavoriteExtractor(PixivExtractor):
|
|||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
uid, kind, self.tag, query = match.groups()
|
uid, kind, self.tag, query = match.groups()
|
||||||
|
query = text.parse_query(query)
|
||||||
|
|
||||||
if query:
|
if not uid:
|
||||||
self.query = text.parse_query(query)
|
uid = query.get("id")
|
||||||
uid = self.query.get("id")
|
|
||||||
if not uid:
|
if not uid:
|
||||||
self.subcategory = "bookmark"
|
self.subcategory = "bookmark"
|
||||||
elif self.query.get("type") == "user":
|
|
||||||
self.subcategory = "following"
|
if kind == "following" or query.get("type") == "user":
|
||||||
self.items = self._items_following
|
self.subcategory = "following"
|
||||||
else:
|
self.items = self._items_following
|
||||||
self.query = {}
|
|
||||||
if kind == "following":
|
|
||||||
self.subcategory = "following"
|
|
||||||
self.items = self._items_following
|
|
||||||
|
|
||||||
PixivExtractor.__init__(self, match)
|
PixivExtractor.__init__(self, match)
|
||||||
|
self.query = query
|
||||||
self.user_id = uid
|
self.user_id = uid
|
||||||
|
|
||||||
def works(self):
|
def works(self):
|
||||||
tag = None
|
tag = None
|
||||||
restrict = "public"
|
|
||||||
|
|
||||||
if "tag" in self.query:
|
if "tag" in self.query:
|
||||||
tag = text.unquote(self.query["tag"])
|
tag = text.unquote(self.query["tag"])
|
||||||
elif self.tag:
|
elif self.tag:
|
||||||
tag = text.unquote(self.tag)
|
tag = text.unquote(self.tag)
|
||||||
|
|
||||||
if "rest" in self.query and self.query["rest"] == "hide":
|
restrict = "public"
|
||||||
|
if self.query.get("rest") == "hide":
|
||||||
restrict = "private"
|
restrict = "private"
|
||||||
|
|
||||||
return self.api.user_bookmarks_illust(self.user_id, tag, restrict)
|
return self.api.user_bookmarks_illust(self.user_id, tag, restrict)
|
||||||
@@ -364,9 +360,11 @@ class PixivFavoriteExtractor(PixivExtractor):
|
|||||||
return {"user_bookmark": user}
|
return {"user_bookmark": user}
|
||||||
|
|
||||||
def _items_following(self):
|
def _items_following(self):
|
||||||
yield Message.Version, 1
|
restrict = "public"
|
||||||
|
if self.query.get("rest") == "hide":
|
||||||
|
restrict = "private"
|
||||||
|
|
||||||
for preview in self.api.user_following(self.user_id):
|
for preview in self.api.user_following(self.user_id, restrict):
|
||||||
user = preview["user"]
|
user = preview["user"]
|
||||||
user["_extractor"] = PixivUserExtractor
|
user["_extractor"] = PixivUserExtractor
|
||||||
url = "https://www.pixiv.net/users/{}".format(user["id"])
|
url = "https://www.pixiv.net/users/{}".format(user["id"])
|
||||||
@@ -622,8 +620,8 @@ class PixivAppAPI():
|
|||||||
params = {"user_id": user_id}
|
params = {"user_id": user_id}
|
||||||
return self._call("v1/user/detail", params)["user"]
|
return self._call("v1/user/detail", params)["user"]
|
||||||
|
|
||||||
def user_following(self, user_id):
|
def user_following(self, user_id, restrict="public"):
|
||||||
params = {"user_id": user_id}
|
params = {"user_id": user_id, "restrict": restrict}
|
||||||
return self._pagination("v1/user/following", params, "user_previews")
|
return self._pagination("v1/user/following", params, "user_previews")
|
||||||
|
|
||||||
def user_illusts(self, user_id):
|
def user_illusts(self, user_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user