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

[kemonoparty] add 'favorites' option (#2826) #2831

Merged
merged 5 commits into from
Aug 18, 2022

Conversation

enduser420
Copy link
Contributor

No description provided.

I forgot to remove this function after replacing regex method with the
'favorites' option
@one-bad-duck
Copy link

I've tested this with Ubuntu 20.04 in WSL and it is working using the new setting. One thing though is that URL inputs specifying posts or artists will be ignored so the setting is the only way to choose. That's fine for me, but I thought I'd point it out. If this is fine, this pull could close #2826 maybe.

@enduser420
Copy link
Contributor Author

I can make it recognize them, but should specifying them overwrite the config option? (is the config option useless?)

@mikf
Copy link
Owner

mikf commented Aug 16, 2022

(is the config option useless?)

Kind of, but I would still keep it, now that you have implemented it.

but should specifying them overwrite the config option?

Yes, use type from the URL params if given, otherwise fall back to the config option.


To capture URL arguments, extend pattern to

    pattern = BASE_PATTERN + r"/favorites(?:/?\?([^#]+))?"

and use text.parse_query in the constructor

    def __init__(self, match):
        KemonopartyExtractor.__init__(self, match)
        self.favorites = text.parse_query(match.group(2)).get("type")

@one-bad-duck
Copy link

one-bad-duck commented Aug 17, 2022

Thank you both very much. I tested it again using Coomer and Kemonoparty in Ubuntu 20.04 via WSL2. It works both ways and the URL does take priority over the option.

enduser420 and others added 2 commits August 18, 2022 02:34
- add test
- update API endpoints
  (/api/favorites does a perma-redirect to /api/v1/account/favorites)
- prevent unnecessary function calls for self.favorites
@mikf mikf merged commit 574e38a into mikf:master Aug 18, 2022
@@ -450,7 +450,7 @@ class KemonopartyFavoriteExtractor(KemonopartyExtractor):
def __init__(self, match):
KemonopartyExtractor.__init__(self, match)
self.favorites = text.parse_query(
match.group(2)).get("type") or self.config("favorites", "artist")
match.group(2)).get("type", self.config("favorites", "artist"))
Copy link
Owner

Choose a reason for hiding this comment

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

In a sense this is worse than before. because it always calls self.config() even if the URL query parameters have a type.

By using a or b, b only gets evaluated when a is empty and not at all when a has a "true" value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, thanks.

@enduser420 enduser420 deleted the kemono-favorites-option branch August 22, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants