Filter paid fanclubs from timeline if -p is provided#130
Filter paid fanclubs from timeline if -p is provided#130xWTF wants to merge 2 commits intobitbybyte:masterfrom
Conversation
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 |
There was a problem hiding this comment.
Will test this later, I'm a little skittish about raising exceptions but I doubt there's a problem here.
fantiadl/models.py
Outdated
| 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{}" |
There was a problem hiding this comment.
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})There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Motivation
Some creators post low-res images on free tier, which will be downloaded when using
-nflag (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_freewhen-pis specified with-n. Since in the original implementation-nwon't have any effect when-pspecified, 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-nor-por-f: Same as previous implementation