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

Fix: Update guid filter examples for fetchItems #1350

Merged
merged 4 commits into from Feb 4, 2024

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Jan 30, 2024

Description

Some why imdb:// or themoviedb:// regex does not filter the items, feels like pattern has "^" in it added by default.

I checked the code and it's not:

unless the re.match does it magically.
but using a complete agent name just works!

also changes iregex-> regex, the guids are always lowercase, no need for case insensitive match

additionally adds "tt12345" for legacy imdb entries

and <Guid id="xxx"> tag matching example.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

@JonnyWong16 JonnyWong16 merged commit 019d3b8 into pkkid:master Feb 4, 2024
3 of 5 checks passed
@glensc glensc deleted the guid-filters branch February 5, 2024 14:59
@glensc
Copy link
Contributor Author

glensc commented Feb 5, 2024

Some why imdb:// or themoviedb:// regex does not filter the items, feels like pattern has "^" in it added by default.

@JonnyWong16 can you comment why it behaves like that? i did not find code that would support that.

also thanks for the merge.

@JonnyWong16
Copy link
Collaborator

JonnyWong16 commented Feb 5, 2024

re.match() matches the start of a string.

https://docs.python.org/3/library/re.html#search-vs-match

@glensc
Copy link
Contributor Author

glensc commented Feb 5, 2024

So, using re.match rather re.search was a design error and fixing now is unwanted breaking change?

@JonnyWong16
Copy link
Collaborator

I don't know what the original design intent was, but it does make more sense to change it to re.search() instead. The user can specify ^ in their regex if they want to match the start of the string.

@glensc
Copy link
Contributor Author

glensc commented Feb 5, 2024

@glensc
Copy link
Contributor Author

glensc commented Feb 5, 2024

i'm wondering that istartswith and iendswith should also lower() the q:

    'startswith': lambda v, q: v.startswith(q),
    'istartswith': lambda v, q: v.lower().startswith(q),
    'endswith': lambda v, q: v.endswith(q),
    'iendswith': lambda v, q: v.lower().endswith(q),

if user puts uppercase search keyword the match would not be made.

in fact iexact and icontains do that for both arguments:

    'iexact': lambda v, q: v.lower() == q.lower(),
    'contains': lambda v, q: q in v,
    'icontains': lambda v, q: q.lower() in v.lower(),

@JonnyWong16
Copy link
Collaborator

I think doing q.lower() makes sense.

@glensc
Copy link
Contributor Author

glensc commented Feb 6, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants