Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mmmpipi
Copy link

@mmmpipi mmmpipi commented Jan 6, 2025

No description provided.

Comment on lines +84 to +85
class BilibiliUserArticleFavlistExtractor(BilibiliExtractor):
subcategory = "user-article-favlist"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines +86 to +88
pattern = (r"(?:https?://)?(?:space.bilibili.com)"
r"/(\d+)/(?:favlist\?fid=opus)"
r"(?:&ftype=opus)?")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.log.warning("no 'SESSDATA' cookie set")
self.log.error("'SESSDATA' cookie required")

Comment on lines +100 to +102
mid = self.api.login_user_id()
if str(mid) != self.groups[0]:
raise exception.StopExtraction("This is not you favlist url!")
Copy link
Owner

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.

Comment on lines +156 to +164
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants