1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-26 04:32:51 +01:00

[pixiv] add extractor for illusts from followed users

This commit is contained in:
Mike Fährmann 2018-05-15 13:02:49 +02:00
parent 7f899bd5d8
commit 909d105ae6
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 32 additions and 7 deletions

View File

@ -88,8 +88,8 @@ Turboimagehost https://turboimagehost.com/ individual Images
==================== =================================== ================================================== ================
.. |Images from Use-0| replace:: Images from Users, Albums, Challenges, individual Images, Likes, Search Results
.. |Collections, De-1| replace:: Collections, Deviations, Favorites, Folders, Galleries, Journals
.. |Collections, De-1| replace:: Collections, Deviations, Favorites, Folders, Galleries, Journals, Popular Images
.. |Images from Use-2| replace:: Images from Users, Albums, Favorites, Galleries, Groups, individual Images, Search Results
.. |Images from Use-3| replace:: Images from Users, Doujin, Favorites, individual Images
.. |Images from Use-4| replace:: Images from Users, Bookmarks, Favorites, pixiv.me Links, Rankings, Individual Images
.. |Images from Use-4| replace:: Images from Users, Bookmarks, Favorites, Follows, pixiv.me Links, Rankings, Search Results, Individual Images
.. |Albums, individ-5| replace:: Albums, individual Images, Images from Users and Folders

View File

@ -240,9 +240,7 @@ class PixivBookmarkExtractor(PixivFavoriteExtractor):
def get_metadata(self, user=None):
self.api.login()
user = self.api.user_info
self.user_id = user["id"]
return PixivFavoriteExtractor.get_metadata(self, user)
return PixivFavoriteExtractor.get_metadata(self, self.api.user)
class PixivRankingExtractor(PixivExtractor):
@ -364,6 +362,29 @@ class PixivSearchExtractor(PixivExtractor):
return {"search": self.search_info}
class PixivFollowExtractor(PixivExtractor):
"""Extractor for new illustrations from your followed artists"""
subcategory = "follow"
archive_fmt = "F_{user_follow[id]}_{id}{num}.{extension}"
directory_fmt = ["{category}", "following"]
pattern = [r"(?:https?://)?(?:www\.|touch\.)?pixiv\.net"
r"/bookmark_new_illust\.php"]
test = [
("https://www.pixiv.net/bookmark_new_illust.php", None),
("https://touch.pixiv.net/bookmark_new_illust.php", None),
]
def __init__(self, match):
PixivExtractor.__init__(self)
def works(self):
return self.api.illust_follow()
def get_metadata(self, user=None):
self.api.login()
return {"user_follow": self.api.user}
class PixivAppAPI():
"""Minimal interface for the Pixiv App API for mobile devices
@ -378,7 +399,7 @@ class PixivAppAPI():
self.session = extractor.session
self.log = extractor.log
self.username, self.password = extractor._get_auth_info()
self.user_info = None
self.user = None
self.client_id = extractor.config(
"client-id", self.CLIENT_ID)
@ -395,7 +416,7 @@ class PixivAppAPI():
def login(self):
"""Login and gain an access token"""
self.user_info, auth = self._login_impl(
self.user, auth = self._login_impl(
self.username, self.password)
self.session.headers["Authorization"] = auth
@ -424,6 +445,10 @@ class PixivAppAPI():
params = {"illust_id": illust_id}
return self._call("v1/illust/detail", params)["illust"]
def illust_follow(self, restrict="all"):
params = {"restrict": restrict}
return self._pagination("v2/illust/follow", params)
def illust_ranking(self, mode="day", date=None):
params = {"mode": mode, "date": date}
return self._pagination("v1/illust/ranking", params)