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

Moebooru: Collect entire collection instead of single post #44

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

Conversation

dearrrfish
Copy link
Contributor

New behavior for handling Moebooru links:

  • Given either parent or child link of a collection, the entire collection will be collected.

@y-young y-young added the enhancement New feature or request label Mar 20, 2022
Copy link
Owner

@y-young y-young left a 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"):
Copy link
Owner

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

@y-young y-young Mar 20, 2022

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants