From a71ed25b198d4ef76cb254c720dd1cc334d187e2 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 25 Apr 2014 14:22:31 -0700 Subject: [PATCH] Fixes issues with searches and importing existing shows --- lib/tvdb_api/tvdb_api.py | 1 + lib/tvrage_api/tvrage_api.py | 3 ++- sickbeard/classes.py | 15 ++++++++++----- sickbeard/webserve.py | 3 ++- tests/tests.py | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index 8b59a7a8..bb503e56 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -919,6 +919,7 @@ class Tvdb: selected_series = self._getSeries(key) if isinstance(selected_series, dict): selected_series = [selected_series] + [[self._setShowData(show['id'], k, v) for k,v in show.items()] for show in selected_series] return selected_series #test = self._getSeries(key) #sids = self._nameToSid(key) diff --git a/lib/tvrage_api/tvrage_api.py b/lib/tvrage_api/tvrage_api.py index de4a77e8..54674a73 100644 --- a/lib/tvrage_api/tvrage_api.py +++ b/lib/tvrage_api/tvrage_api.py @@ -30,7 +30,7 @@ try: except ImportError: import xml.etree.ElementTree as ElementTree -from dateutil.parser import parse +from lib.dateutil.parser import parse from cachecontrol import caches from tvrage_ui import BaseUI @@ -658,6 +658,7 @@ class TVRage: selected_series = self._getSeries(key) if isinstance(selected_series, dict): selected_series = [selected_series] + [[self._setShowData(show['id'], k, v) for k, v in show.items()] for show in selected_series] return selected_series #test = self._getSeries(key) #sids = self._nameToSid(key) diff --git a/sickbeard/classes.py b/sickbeard/classes.py index 2ec2f335..391ee59a 100644 --- a/sickbeard/classes.py +++ b/sickbeard/classes.py @@ -21,6 +21,7 @@ import sickbeard import urllib import datetime +from lib.dateutil import parser from common import USER_AGENT, Quality @@ -154,16 +155,20 @@ class AllShowsListUI: if allSeries: if 'searchterm' in self.config: searchterm = self.config['searchterm'] - # try to pick a show that's in my show list for curShow in allSeries: if curShow in searchResults: continue - searchterm = re.escape(searchterm) - if re.search(searchterm, curShow['seriesname'], flags=re.I) and 'firstaired' in curShow: - searchResults.append(curShow) + if 'seriesname' in curShow: + if searchterm.lower() in curShow['seriesname'].lower(): + if 'firstaired' not in curShow: + curShow['firstaired'] = str(datetime.date.fromordinal(1)) + curShow['firstaired'] = re.sub("([-]0{2}){1,}", "", curShow['firstaired']) + fixDate = parser.parse(curShow['firstaired'], fuzzy=True).date() + curShow['firstaired'] = fixDate.strftime("%Y-%m-%d") + searchResults.append(curShow) - return searchResults + return searchResults class ShowListUI: """ diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index eb36346d..98c2879d 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -1977,7 +1977,8 @@ class NewHomeAddShows: try: # add search results results.setdefault(indexer, []).extend(t[search_term]) - except:continue + except Exception, e: + continue map(final_results.extend, diff --git a/tests/tests.py b/tests/tests.py index 48faf86b..4ab22f94 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -31,7 +31,7 @@ from sickbeard import classes class APICheck(unittest.TestCase): lang = "en" - search_term = 'Reign (2013)' + search_term = 'Gold Rush South America' results = {} final_results = []