1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-11 03:45:01 -05:00

Merge pull request #747 from echel0n/dev

Dev
This commit is contained in:
adam111316 2014-08-25 14:24:21 +08:00
commit 00d5d498b6
5 changed files with 24 additions and 21 deletions

View File

@ -143,14 +143,15 @@ class GenericClient(object):
def _get_torrent_hash(self, result):
if result.url.startswith('magnet'):
torrent_hash = re.findall('urn:btih:([\w]{32,40})', result.url)[0]
if len(torrent_hash) == 32:
torrent_hash = b16encode(b32decode(torrent_hash)).lower()
result.hash = re.findall('urn:btih:([\w]{32,40})', result.url)[0]
if len(result.hash) == 32:
result.hash = b16encode(b32decode(result.hash)).lower()
else:
result.content = result.provider.getURL(result.url)
info = bdecode(result.content)["info"]
torrent_hash = sha1(bencode(info)).hexdigest()
result.hash = sha1(bencode(info)).hexdigest()
return torrent_hash
return result
def sendTORRENT(self, result):
@ -166,6 +167,9 @@ class GenericClient(object):
# Sets per provider seed ratio
result.ratio = result.provider.seedRatio()
# lazy fix for now, I'm sure we already do this somewhere else too
result = self._get_torrent_hash(result)
if result.url.startswith('magnet'):
r_code = self._add_torrent_uri(result)
else:

View File

@ -84,8 +84,6 @@ class TransmissionAPI(GenericClient):
if result.ratio:
ratio = result.ratio
torrent_id = self._get_torrent_hash(result)
mode = 0
if ratio:
if float(ratio) == -1:
@ -95,7 +93,7 @@ class TransmissionAPI(GenericClient):
ratio = float(ratio)
mode = 1 # Stop seeding at seedRatioLimit
arguments = {'ids': [torrent_id],
arguments = {'ids': [result.hash],
'seedRatioLimit': ratio,
'seedRatioMode': mode
}
@ -108,9 +106,7 @@ class TransmissionAPI(GenericClient):
def _set_torrent_priority(self, result):
torrent_id = self._get_torrent_hash(result)
arguments = {'ids': [torrent_id]}
arguments = {'ids': [result.hash]}
if result.priority == -1:
arguments['priority-low'] = []

View File

@ -221,16 +221,22 @@ class GenericProvider:
Returns: A tuple containing two strings representing title and URL respectively
"""
title = item.title if item.title else None
title = None
url = None
if 'title' in item:
title = item.title
if title:
title = u'' + title
title = title.replace(' ', '.')
url = item.link if item.link else None
if 'link' in item:
url = item.link
if url:
url = url.replace('&', '&')
return (title, url)
return title, url
def findSearchResults(self, show, season, episodes, search_mode, manualSearch=False):

View File

@ -206,15 +206,14 @@ class NewznabProvider(generic.NZBProvider):
params['apikey'] = self.key
results = []
keep_searching = 1
while True:
search_url = self.url + 'api?' + urllib.urlencode(params)
logger.log(u"Search url: " + search_url, logger.DEBUG)
data = self.cache.getRSSFeed(search_url)
if data and self._checkAuthFromData(data):
for item in data:
if data and 'entries' in data and self._checkAuthFromData(data):
for item in data.entries:
(title, url) = self._get_title_and_url(item)
@ -247,8 +246,6 @@ class NewznabProvider(generic.NZBProvider):
return results
def findPropers(self, search_date=None):
search_terms = ['.proper.', '.repack.']

View File

@ -258,7 +258,7 @@ def update_scene_exceptions(indexer_id, scene_exceptions, season=-1):
"""
global exceptionsCache
myDB = db.DBConnection('cache.db')
myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=?', [indexer_id])
myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=? and season=?', [indexer_id, season])
logger.log(u"Updating scene exceptions", logger.MESSAGE)