[fix] emby: strip year in search#2966
Conversation
flexget/components/emby/api_emby.py
Outdated
| if not isinstance(name, str): | ||
| return name | ||
|
|
||
| new_name = re.sub(r'^(.*) \(\d{4}\)(.*)', r'\1\2', new_name) |
There was a problem hiding this comment.
Wouldn't it be cleaner to search and strip the year disregarding the wildcards before and after?
new_name = re.sub(r' ?\(\d{4}\)', '', new_name)
There was a problem hiding this comment.
I changed to the tools
|
We have a utility to split out years, does it work for this purpose, or is yours more specific to this case? Flexget/flexget/utils/tools.py Lines 357 to 379 in 97ca6d2 |
|
That works for me... I'll change it... Tks |
flexget/components/emby/api_emby.py
Outdated
| EmbyApi.set_common_search_arg(args) | ||
|
|
||
| args['SearchTerm'] = kwargs.get('title') | ||
| args['SearchTerm'] = EmbyApi.strip_year(kwargs.get('title')) |
There was a problem hiding this comment.
I don't think you need a helper function to call the helper function. The existing split_title_year already does everything your helper does.
| args['SearchTerm'] = EmbyApi.strip_year(kwargs.get('title')) | |
| args['SearchTerm'], _ = split_title_year(kwargs.get('title') |
or
| args['SearchTerm'] = EmbyApi.strip_year(kwargs.get('title')) | |
| args['SearchTerm'] = split_title_year(kwargs.get('title')[0] |
Now that I've written that, I sorta want to change our helper to return a named tuple, so we could use .title rather than [0]
There was a problem hiding this comment.
I made that tool return a namedtuple now, so you can call .title on the result
There was a problem hiding this comment.
I pushed a new change, to remove the declaration of the now unused method
There was a problem hiding this comment.
I added the use of the named tuple
|
Looks good, thanks! |
Motivation for changes:
In emby all search should be preformed without the year
Detailed changes: