mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[pixiv] implement 'metadata-bookmark' option (#3417)
This commit is contained in:
parent
0895e6afee
commit
362cd6991b
@ -1859,7 +1859,7 @@ Description
|
||||
Note: gallery-dl comes with built-in tokens for ``mastodon.social``,
|
||||
``pawoo`` and ``baraag``. For other instances, you need to obtain an
|
||||
``access-token`` in order to use usernames in place of numerical
|
||||
user IDs.
|
||||
user IDs.
|
||||
|
||||
|
||||
extractor.[mastodon].reblogs
|
||||
@ -2168,6 +2168,17 @@ Description
|
||||
It is possible to use ``"all"`` instead of listing all values separately.
|
||||
|
||||
|
||||
extractor.pixiv.refresh-token
|
||||
-----------------------------
|
||||
Type
|
||||
``string``
|
||||
Description
|
||||
The ``refresh-token`` value you get
|
||||
from running ``gallery-dl oauth:pixiv`` (see OAuth_) or
|
||||
by using a third-party tool like
|
||||
`gppt <https://github.com/eggplants/get-pixivpy-token>`__.
|
||||
|
||||
|
||||
extractor.pixiv.metadata
|
||||
------------------------
|
||||
Type
|
||||
@ -2178,6 +2189,20 @@ Description
|
||||
Fetch extended ``user`` metadata.
|
||||
|
||||
|
||||
extractor.pixiv.metadata-bookmark
|
||||
---------------------------------
|
||||
Type
|
||||
``bool``
|
||||
Default
|
||||
``false``
|
||||
Description
|
||||
For works bookmarked by
|
||||
`your own account <extractor.pixiv.refresh-token_>`__,
|
||||
fetch bookmark tags as ``tags_bookmark`` metadata.
|
||||
|
||||
Note: This requires 1 additional API call per bookmarked post.
|
||||
|
||||
|
||||
extractor.pixiv.work.related
|
||||
----------------------------
|
||||
Type
|
||||
@ -2309,7 +2334,7 @@ Description
|
||||
Retrieve additional comments by resolving the ``more`` comment
|
||||
stubs in the base comment tree.
|
||||
|
||||
This requires 1 additional API call for every 100 extra comments.
|
||||
Note: This requires 1 additional API call for every 100 extra comments.
|
||||
|
||||
|
||||
extractor.reddit.date-min & .date-max
|
||||
|
@ -237,6 +237,7 @@
|
||||
"refresh-token": null,
|
||||
"include": "artworks",
|
||||
"metadata": false,
|
||||
"metadata-bookmark": false,
|
||||
"tags": "japanese",
|
||||
"ugoira": true
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2014-2022 Mike Fährmann
|
||||
# Copyright 2014-2023 Mike Fährmann
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
@ -45,7 +45,8 @@ class PixivExtractor(Extractor):
|
||||
work["tags"] = [tag["name"] for tag in work["tags"]]
|
||||
|
||||
ratings = {0: "General", 1: "R-18", 2: "R-18G"}
|
||||
userdata = self.config("metadata")
|
||||
meta_user = self.config("metadata")
|
||||
meta_bookmark = self.config("metadata-bookmark")
|
||||
metadata = self.metadata()
|
||||
|
||||
works = self.works()
|
||||
@ -61,8 +62,12 @@ class PixivExtractor(Extractor):
|
||||
del work["image_urls"]
|
||||
del work["meta_pages"]
|
||||
|
||||
if userdata:
|
||||
if meta_user:
|
||||
work.update(self.api.user_detail(work["user"]["id"]))
|
||||
if meta_bookmark and work["is_bookmarked"]:
|
||||
detail = self.api.illust_bookmark_detail(work["id"])
|
||||
work["tags_bookmark"] = [tag["name"] for tag in detail["tags"]
|
||||
if tag["is_registered"]]
|
||||
if transform_tags:
|
||||
transform_tags(work)
|
||||
work["num"] = 0
|
||||
@ -398,6 +403,8 @@ class PixivFavoriteExtractor(PixivExtractor):
|
||||
# own bookmarks
|
||||
("https://www.pixiv.net/bookmark.php", {
|
||||
"url": "90c1715b07b0d1aad300bce256a0bc71f42540ba",
|
||||
"keyword": {"tags_bookmark": ["47", "hitman"]},
|
||||
"options": (("metadata-bookmark", True),),
|
||||
}),
|
||||
# own bookmarks with tag (#596)
|
||||
("https://www.pixiv.net/bookmark.php?tag=foobar", {
|
||||
@ -880,6 +887,11 @@ class PixivAppAPI():
|
||||
params = {"illust_id": illust_id}
|
||||
return self._call("/v1/illust/detail", params)["illust"]
|
||||
|
||||
def illust_bookmark_detail(self, illust_id):
|
||||
params = {"illust_id": illust_id}
|
||||
return self._call(
|
||||
"/v2/illust/bookmark/detail", params)["bookmark_detail"]
|
||||
|
||||
def illust_follow(self, restrict="all"):
|
||||
params = {"restrict": restrict}
|
||||
return self._pagination("/v2/illust/follow", params)
|
||||
@ -900,9 +912,16 @@ class PixivAppAPI():
|
||||
return self._pagination("/v1/search/illust", params)
|
||||
|
||||
def user_bookmarks_illust(self, user_id, tag=None, restrict="public"):
|
||||
"""Return illusts bookmarked by a user"""
|
||||
params = {"user_id": user_id, "tag": tag, "restrict": restrict}
|
||||
return self._pagination("/v1/user/bookmarks/illust", params)
|
||||
|
||||
def user_bookmark_tags_illust(self, user_id, restrict="public"):
|
||||
"""Return bookmark tags defined by a user"""
|
||||
params = {"user_id": user_id, "restrict": restrict}
|
||||
return self._pagination(
|
||||
"/v1/user/bookmark-tags/illust", params, "bookmark_tags")
|
||||
|
||||
@memcache(keyarg=1)
|
||||
def user_detail(self, user_id):
|
||||
params = {"user_id": user_id}
|
||||
|
Loading…
Reference in New Issue
Block a user