-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bilibili] bilibili User Articles FavList support #6781
base: master
Are you sure you want to change the base?
Conversation
class BilibiliUserArticleFavlistExtractor(BilibiliExtractor): | ||
subcategory = "user-article-favlist" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class BilibiliUserArticleFavlistExtractor(BilibiliExtractor): | |
subcategory = "user-article-favlist" | |
class BilibiliUserArticlesFavoriteExtractor(BilibiliExtractor): | |
subcategory = "user-articles-favorite" |
To stay consistent with the naming of the existing user-articles
extractor and other favorite
extractors
pattern = (r"(?:https?://)?(?:space.bilibili.com)" | ||
r"/(\d+)/(?:favlist\?fid=opus)" | ||
r"(?:&ftype=opus)?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pattern = (r"(?:https?://)?(?:space.bilibili.com)" | |
r"/(\d+)/(?:favlist\?fid=opus)" | |
r"(?:&ftype=opus)?") | |
pattern = (r"(?:https?://)?space\.bilibili\.com" | |
r"/(\d+)/favlist\?fid=opus") |
pattern = (r"(?:https?://)?(?:space.bilibili.com)" | ||
r"/(\d+)/(?:favlist\?fid=opus)" | ||
r"(?:&ftype=opus)?") | ||
example = "https://space.bilibili.com/123456/favlist?fid=opus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example = "https://space.bilibili.com/123456/favlist?fid=opus" | |
example = "https://space.bilibili.com/12345/favlist?fid=opus" |
Example URL IDs are 12345
everywhere else.
BilibiliExtractor._init(self) | ||
if self._warning: | ||
if not self.cookies_check(("SESSDATA",)): | ||
self.log.warning("no 'SESSDATA' cookie set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.log.warning("no 'SESSDATA' cookie set") | |
self.log.error("'SESSDATA' cookie required") |
mid = self.api.login_user_id() | ||
if str(mid) != self.groups[0]: | ||
raise exception.StopExtraction("This is not you favlist url!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing an extra API request here is unnecessary. Just let the next API fail.
data = self._call(endpoint, params) | ||
|
||
for item in data["data"]["items"]: | ||
yield item | ||
|
||
if not data["data"]["has_more"]: | ||
break | ||
|
||
params["page"] = params["page"] + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = self._call(endpoint, params) | |
for item in data["data"]["items"]: | |
yield item | |
if not data["data"]["has_more"]: | |
break | |
params["page"] = params["page"] + 1 | |
data = self._call(endpoint, params)["data"] | |
yield from data["items"] | |
if not data.get("has_more"): | |
break | |
params["page"] += 1 |
No description provided.