-
Notifications
You must be signed in to change notification settings - Fork 59
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
Moebooru: Collect entire collection instead of single post #44
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for your contribution! Generally this is a good idea, but there're things that need to be improved, take your time and feel free to ask if you have any question.
class Moebooru(object): | ||
def site(self, site_url: Optional[str] = 'yande.re'): | ||
def site(self, site_url: Optional[str] = "yande.re"): |
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.
Please adjust your code formatter to eliminate these changes, including the extra blank line above and the single quotes. The code format issue should be dealt later in a separate commit if necessary.
except json.decoder.JSONDecodeError as err: | ||
logger.error(err) | ||
return post, tags | ||
|
||
async def getCollection(self, parent_id: int): | ||
url = "https://" + self.url + "/post?tags=parent:" + str(parent_id) |
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.
There's an official API for post search, so we don't need to bother with the regex here.
e.g.: https://yande.re/post.json?tags=parent%3A12345, reference: https://yande.re/help/api#posts
if not parent_id and post["has_children"]: | ||
parent_id = post_id | ||
if parent_id: | ||
posts, tags = await self.getCollection(parent_id) |
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'm not sure that everyone needs both the parent and the children. Take myself as an example, when collecting a post with parent, I tend to choose the parent post, since in most cases it has the best quality. Therefore I would suggest giving user options like these:
- Only collect the post itself
- If the post has a parent, collect its parent only
- Collect the parent and children
New behavior for handling Moebooru links: