Private GIT

Skip to content
Snippets Groups Projects
Commit 4213a18c authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

Merge pull request #1996 from miigotu/try3-hopefully-good

Sleep in SCC, move torrent content download to after all checks to make sure we want it.
parents 1c6aa2ce c6f8d2b6
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ import subprocess ...@@ -49,7 +49,7 @@ import subprocess
from sickbeard.exceptions import MultipleShowObjectsException, ex from sickbeard.exceptions import MultipleShowObjectsException, ex
from sickbeard import logger, classes from sickbeard import logger, classes
from sickbeard.common import USER_AGENT, mediaExtensions, subtitleExtensions from sickbeard.common import USER_AGENT, cpu_presets, mediaExtensions, subtitleExtensions
from sickbeard import db from sickbeard import db
from sickbeard import encodingKludge as ek from sickbeard import encodingKludge as ek
from sickbeard import notifiers from sickbeard import notifiers
......
...@@ -147,7 +147,10 @@ class SCCProvider(generic.TorrentProvider): ...@@ -147,7 +147,10 @@ class SCCProvider(generic.TorrentProvider):
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season, sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
'episodenumber': ep_obj.scene_episode} + ' %s' % add_string 'episodenumber': ep_obj.scene_episode}
if len(add_string):
ep_string += ' %s' % add_string
search_string['Episode'].append(re.sub('\s+', ' ', ep_string)) search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
...@@ -188,6 +191,7 @@ class SCCProvider(generic.TorrentProvider): ...@@ -188,6 +191,7 @@ class SCCProvider(generic.TorrentProvider):
logger.log(u"Search string: " + searchURL, logger.DEBUG) logger.log(u"Search string: " + searchURL, logger.DEBUG)
try: try:
data += [x for x in [self.getURL(searchURL)] if x] data += [x for x in [self.getURL(searchURL)] if x]
time.sleep(cpu_presets[sickbeard.CPU_PRESET])
except Exception as e: except Exception as e:
logger.log(u"Unable to fetch data reason: {0}".format(str(e)), logger.WARNING) logger.log(u"Unable to fetch data reason: {0}".format(str(e)), logger.WARNING)
......
...@@ -199,18 +199,6 @@ def pickBestResult(results, show): ...@@ -199,18 +199,6 @@ def pickBestResult(results, show):
if show and cur_result.show is not show: if show and cur_result.show is not show:
continue continue
#TODO: Is this the cause of #1579 (Downloading wrong torrent)
if isinstance(cur_result, sickbeard.classes.SearchResult):
if cur_result.resultType == "torrent" and sickbeard.TORRENT_METHOD != "blackhole":
if not cur_result.url.startswith('magnet'):
cur_result.content = cur_result.provider.getURL(cur_result.url)
if not cur_result.content:
continue
else:
if not cur_result.url.startswith('magnet'):
cur_result.content = cur_result.provider.getURL(cur_result.url)
if not cur_result.content:
continue
# build the black And white list # build the black And white list
if show.is_anime: if show.is_anime:
...@@ -246,6 +234,14 @@ def pickBestResult(results, show): ...@@ -246,6 +234,14 @@ def pickBestResult(results, show):
logger.log(cur_result.name + u" has previously failed, rejecting it") logger.log(cur_result.name + u" has previously failed, rejecting it")
continue continue
# Download the torrent file contents only if it has passed all other checks!
# Must be done before setting bestResult
if cur_result.resultType == "torrent" and sickbeard.TORRENT_METHOD != "blackhole":
if len(cur_result.url) and not cur_result.url.startswith('magnet'):
cur_result.content = cur_result.provider.getURL(cur_result.url)
if not cur_result.content:
continue
if cur_result.quality in bestQualities and (not bestResult or bestResult.quality < cur_result.quality or bestResult not in bestQualities): if cur_result.quality in bestQualities and (not bestResult or bestResult.quality < cur_result.quality or bestResult not in bestQualities):
bestResult = cur_result bestResult = cur_result
elif cur_result.quality in anyQualities and (not bestResult or bestResult not in bestQualities) and (not bestResult or bestResult.quality < cur_result.quality): elif cur_result.quality in anyQualities and (not bestResult or bestResult not in bestQualities) and (not bestResult or bestResult.quality < cur_result.quality):
...@@ -660,6 +656,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False): ...@@ -660,6 +656,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False):
for epObj in multiResult.episodes: for epObj in multiResult.episodes:
if not multiResult.url.startswith('magnet'): if not multiResult.url.startswith('magnet'):
multiResult.content = multiResult.provider.getURL(cur_result.url) multiResult.content = multiResult.provider.getURL(cur_result.url)
multiResults[epObj.episode] = multiResult multiResults[epObj.episode] = multiResult
# don't bother with the single result if we're going to get it with a multi result # don't bother with the single result if we're going to get it with a multi result
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment