Skip to content

Commit

Permalink
Merge pull request #63 from pymedusa/url_check
Browse files Browse the repository at this point in the history
[Manual search] Fix "url not valid" check
  • Loading branch information
fernandog committed Mar 1, 2016
2 parents 286b5d2 + 737a0ee commit f77b377
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,25 +1375,27 @@ def manualSnatchSelect(self, show=None, season=None, episode=None, provider=None

# Try to retrieve the cached result from the providers cache table.
# TODO: the implicit sqlite rowid is used, should be replaced with an explicit PK column

sql_results = []
main_db_con = db.DBConnection('cache.db')

sql_return = main_db_con.action("SELECT * FROM '%s' WHERE rowid = ?" %
try:
main_db_con = db.DBConnection('cache.db')
sql_return = main_db_con.action("SELECT * FROM '%s' WHERE rowid = ?" %
(sickbeard.providers.getProviderClass(provider).get_id()), [rowid], fetchone=True)
except Exception as e:
return self._genericMessage("Error", "Couldn't read cached results. Error: {}".format(e))

try:
show = int(show) # fails if show id ends in a period SickRage/sickrage-issues#65
showObj = Show.find(sickbeard.showList, show)
except (ValueError, TypeError):
return self._genericMessage("Error", "Invalid show ID: %s" % str(show))

if showObj is None:
return self._genericMessage("Error", "Show not in show list")
if not showObj:
return self._genericMessage("Error", "Show is not in your library")

if (sql_return['url'] is None or sql_return['quality'] is None or
sql_return['release_group'] is None or
provider is None or sql_return['name'] is None):
return self._genericMessage("Error", "URL not valid")
if not (sql_return['url'] or sql_return['name'] or provider or episode):
return self._genericMessage("Error", "Cached result doesn't have all needed info to snatch episode")

# retrieve the episode object and fail if we can't get one
ep_obj = self._getEpisode(show, season, episode)
Expand Down

0 comments on commit f77b377

Please sign in to comment.