OwenCochell / cursepy

A CurseForge API written in python
MIT License
7 stars 1 forks source link

The search filter doesn't work #3

Closed Arweix closed 2 years ago

Arweix commented 2 years ago

My code:

from cursepy import CurseClient

client = CurseClient()
search = client.get_search()
search.pageSize = 5
search.filter = "witchery"
for i in client.search(432, client.ADDON_SEARCH, search):
    print(i.name)

Output:

Just Enough Items (JEI)
Mouse Tweaks
Controlling
JourneyMap
AppleSkin

It looks like the search filter is not working

OwenCochell commented 2 years ago

Hello! Thank you for pointing this out, this is indeed a bug. The value should be searchFilter instead of just filter. After this change, your code should look like this:

from cursepy import CurseClient

client = CurseClient()
search = client.get_search()
search.pageSize = 5
search.searchFilter = "witchery"  # Here is the changed line, use 'searchFilter' instead of 'filter'
for i in client.search(432, client.ADDON_SEARCH, search):
    print(i.name)

After applying the change, here are my results when running your code:

Witchery
Witchery: Rewitched
WitcheryPatch
Witchery- Style Vampirism
Witchery Master Patch

You can now upgrade cursepy via pip and it will work, the specific version you want is 1.1.3.

Also just a side note, the category ID for the search method should not be a handler ID such as ADDON_SEARCH, and instead should be a valid category ID. You can find all valid Minecraft IDs by using the categories() method on a CurseGame instance like so:

client.game(423).categories()

Alternatively, you can use the MinecraftWrapper class, which auto fills most of this info for you. Here is an example of searching the modpack category:

from cursepy import MinecraftWrapper

client = MinecraftWrapper()
search = client.get_search()
search.searchFilter = "Test"

client.search_modpacks(search)

Thanks again for pointing this out! I really appreciate it. please let me know if this issue or any others make themselves known.

Arweix commented 2 years ago

Thanks for fixing the bug! How it works, I'll take note of Minecraft Wrapper. A very convenient and useful thing! Good luck :)