Skip to content

Filter paid fanclubs from timeline if -p is provided#130

Open
xWTF wants to merge 2 commits intobitbybyte:masterfrom
xWTF:master
Open

Filter paid fanclubs from timeline if -p is provided#130
xWTF wants to merge 2 commits intobitbybyte:masterfrom
xWTF:master

Conversation

@xWTF
Copy link
Contributor

@xWTF xWTF commented Aug 31, 2024

Motivation

Some creators post low-res images on free tier, which will be downloaded when using -n flag (I'm using this to fetch new posts automatically) and mess up the library.

Being able to filter out non-paid posts when downloading from timeline addresses the above issue.

Implementation

Added a check to append free_plan=not_free when -p is specified with -n. Since in the original implementation -n won't have any effect when -p specified, this should not change any intended behavior.

Behavior changes:

  • -n -p: Download latest paid posts
  • -f -n: Throw a misuse error
  • -f -p: Throw a misuse error
  • -n or -p or -f: Same as previous implementation

@bitbybyte bitbybyte added the enhancement New feature or request label Sep 10, 2024
@bitbybyte
Copy link
Owner

bitbybyte commented Sep 27, 2024

Since in the original implementation -n won't have any effect when -p specified, this should not change any intended behavior.

I think it's fine for this PR if no behavior changes, but it'd probably be nice to do this eventually.

if cmdl_opts.download_fanclubs:
try:

# Download based on flags
Copy link
Owner

Choose a reason for hiding this comment

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

Will test this later, I'm a little skittish about raising exceptions but I doubt there's a problem here.

POST_RELATIVE_URL = "/posts/"

TIMELINES_API = "https://fantia.jp/api/v1/me/timelines/posts?page={}&per=24"
TIMELINES_API = "https://fantia.jp/api/v1/me/timelines/posts?page={}&per=24{}"
Copy link
Owner

Choose a reason for hiding this comment

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

Remove this, and if necessary refactor the other use of this constant to pass params, e.g.:

TIMELINES_API = "https://fantia.jp/api/v1/me/timelines/posts"
PAGE_PER_N = 24

response = self.session.get(TIMELINES_API, params={"page": page_number, "per": PAGE_PER_N})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LGTM, initially I just tried to minimalize changes to code, passing params is definitely better.
I'm a bit busy recently, these requested changes might come in 3-7 days.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Requested changes have been applied. It's very unlikely that the number 24 will change or anyone would like to change it, so I didn't introduce a new constant.

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.

2 participants