-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
Support list of names passed to search in tvdb.py #8758
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,38 +108,42 @@ def search(self, name, language=None, exact=False, indexer_id=False): | |
if not name: | ||
return result | ||
|
||
if re.match(r"^t?t?\d{7,8}$", name) or re.match(r"^\d{6}$", name): | ||
try: | ||
if re.match(r"^t?t?\d{7,8}$", name): | ||
result = self._search(imdbId=f'tt{name.strip("t")}', language=language) | ||
elif re.match(r"^\d{6}$", name): | ||
series = self._series(name, language=language) | ||
if series: | ||
result = [series.info(language)] | ||
except (requests.exceptions.RequestException, requests.exceptions.HTTPError, Exception): | ||
logger.debug(traceback.format_exc()) | ||
else: | ||
# Name as provided (usually from nfo) | ||
names = [name] | ||
if not exact: | ||
# Name without year and separator | ||
test = re.match(r"^(.+?)[. -]+\(\d{4}\)?$", name) | ||
if test: | ||
names.append(test.group(1).strip()) | ||
# Name with spaces | ||
if re.match(r"[. -_]", name): | ||
names.append(re.sub(r"[. -_]", " ", name).strip()) | ||
if test: | ||
# Name with spaces and without year | ||
names.append(re.sub(r"[. -_]", " ", test.group(1)).strip()) | ||
|
||
for attempt in set(n for n in names if n.strip()): | ||
if isinstance(name, str): | ||
if re.match(r"^t?t?\d{7,8}$", name) or re.match(r"^\d{6}$", name): | ||
try: | ||
result = self._search(attempt, language=language) | ||
if result: | ||
break | ||
if re.match(r"^t?t?\d{7,8}$", name): | ||
result = self._search(imdbId=f'tt{name.strip("t")}', language=language) | ||
elif re.match(r"^\d{6}$", name): | ||
series = self._series(name, language=language) | ||
if series: | ||
result = [series.info(language)] | ||
except (requests.exceptions.RequestException, requests.exceptions.HTTPError, Exception): | ||
logger.debug(traceback.format_exc()) | ||
else: | ||
# Name as provided (usually from nfo) | ||
names = [name] | ||
if not exact: | ||
# Name without year and separator | ||
test = re.match(r"^(.+?)[. -]+\(\d{4}\)?$", name) | ||
if test: | ||
names.append(test.group(1).strip()) | ||
# Name with spaces | ||
if re.match(r"[. -_]", name): | ||
names.append(re.sub(r"[. -_]", " ", name).strip()) | ||
if test: | ||
# Name with spaces and without year | ||
names.append(re.sub(r"[. -_]", " ", test.group(1)).strip()) | ||
|
||
for attempt in set(n for n in names if n.strip()): | ||
try: | ||
result = self._search(attempt, language=language) | ||
if result: | ||
break | ||
except (requests.exceptions.RequestException, requests.exceptions.HTTPError, Exception): | ||
logger.debug(traceback.format_exc()) | ||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this else needs removed. We don't want to search for ["fast", "&", "furious"] each individually, we want to join that list and search for the full string. |
||
for n in name: | ||
result.extend(self.search(n, language, exact, indexer_id)) | ||
Comment on lines
+145
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recursive call for list handling might lead to performance issues. Consider using a loop to handle each item in the list within the same method instance to avoid the overhead of recursive calls. This approach can also make the method easier to debug and maintain. |
||
|
||
return result | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this join the list like the other guessit fixes instead of just checking if it's a string?
On line 1 add:
After line 106 add:
Then remove the rest of the changes here (we know it's a string then)