juliomalegria / python-craigslist

Simple Craigslist wrapper
MIT No Attribution
387 stars 165 forks source link

auto_title_status doesn't accept any of the filter parameters/options #97

Closed mnowicky closed 3 years ago

mnowicky commented 3 years ago

Hello, thanks for the great module! I did find what I believe to be a bug however.

It has to do with the "CraigslistForSale" sub-class. Specifically, the category "cto".

When issuing: CraigslistForSale.show_filters(category='cto')

we see that "auto_title_status" is a valid filter, with the options being listed as "clean", "salvage", "rebuilt", "parts only", "lien", and "missing".

However, when trying to use this filter, it appears as though it's only accepting each character individually. For instance:

If I set "auto_tite_status" to 'clean", I get returned:

'c' is not a valid option for auto_title_status
'l'  is not a valid option for auto_title_status
'e'  is not a valid option for auto_title_status
'a'  is not a valid option for auto_title_status
'n'  is not a valid option for auto_title_status

This happens no matter what I set this filter to.

I need to confirm, but this might affect all of the catgory specific filters that start with "auto_".

The specific call I'm making is:

clfs = CraigslistForSale(site=monterey, category=cto, filters={'auto_title_status': 'clean'})

Thank you!

irahorecka commented 3 years ago

In base.py, get_filters has a conditional that checks for whether filters value (e.g. 'clean') is an iterable; if it's not, it'll force the value into a list to make it an iterable. In your case, 'clean' (i.e. a str) is an iterable, so when the function tries to check the elements in the iterable to an accepted list of filter parameters, rather than pulling 'clean' from ['clean'], it pulls 'c' 'l' 'e' 'a' 'n' from 'clean'.

For now, a workaround is to encapsulate 'clean' in a list - i.e. filters={'auto_title_status': ['clean']}

mnowicky commented 3 years ago

Thank you!