From c7c64c60025e1331517e94d680f7867093e3bd3b Mon Sep 17 00:00:00 2001 From: sax Date: Wed, 25 Sep 2013 14:05:16 +0200 Subject: [PATCH 1/2] Changed implementation of "scene_only" parameter to use filter criteria instead of parsing the information from query result. --- .../providers/torrent/torrentshack/main.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/couchpotato/core/providers/torrent/torrentshack/main.py b/couchpotato/core/providers/torrent/torrentshack/main.py index 353b606e..bc7077bb 100644 --- a/couchpotato/core/providers/torrent/torrentshack/main.py +++ b/couchpotato/core/providers/torrent/torrentshack/main.py @@ -15,7 +15,7 @@ class TorrentShack(TorrentProvider): 'login' : 'https://torrentshack.net/login.php', 'login_check': 'https://torrentshack.net/inbox.php', 'detail' : 'https://torrentshack.net/torrent/%s', - 'search' : 'https://torrentshack.net/torrents.php?searchstr=%s&filter_cat[%d]=1', + 'search' : 'https://torrentshack.net/torrents.php?action=advanced&searchstr=%s&scene=%s&filter_cat[%d]=1', 'download' : 'https://torrentshack.net/%s', } @@ -31,7 +31,14 @@ class TorrentShack(TorrentProvider): def _searchOnTitle(self, title, movie, quality, results): - url = self.urls['search'] % (tryUrlencode('"%s" %s' % (title.replace(':', ''), movie['library']['year'])), self.getCatId(quality['identifier'])[0]) + # scene only unset by default + scene_only = "" + if self.conf('scene_only'): + scene_only = "1" + + url = self.urls['search'] % (tryUrlencode('"%s" %s' % (title.replace(':', ''), movie['library']['year'])), + scene_only, + self.getCatId(quality['identifier'])[0]) data = self.getHTMLData(url, opener = self.login_opener) if data: @@ -49,22 +56,15 @@ class TorrentShack(TorrentProvider): link = result.find('span', attrs = {'class' : 'torrent_name_link'}).parent url = result.find('td', attrs = {'class' : 'torrent_td'}).find('a') - extra_info = '' - if result.find('span', attrs = {'class' : 'torrent_extra_info'}): - extra_info = result.find('span', attrs = {'class' : 'torrent_extra_info'}).text - - if not self.conf('scene_only') or extra_info != '[NotScene]': - results.append({ - 'id': link['href'].replace('torrents.php?torrentid=', ''), - 'name': unicode(link.span.string).translate({ord(u'\xad'): None}), - 'url': self.urls['download'] % url['href'], - 'detail_url': self.urls['download'] % link['href'], - 'size': self.parseSize(result.find_all('td')[4].string), - 'seeders': tryInt(result.find_all('td')[6].string), - 'leechers': tryInt(result.find_all('td')[7].string), - }) - else: - log.info('Not adding release %s [NotScene]' % unicode(link.span.string).translate({ord(u'\xad'): None})) + results.append({ + 'id': link['href'].replace('torrents.php?torrentid=', ''), + 'name': unicode(link.span.string).translate({ord(u'\xad'): None}), + 'url': self.urls['download'] % url['href'], + 'detail_url': self.urls['download'] % link['href'], + 'size': self.parseSize(result.find_all('td')[4].string), + 'seeders': tryInt(result.find_all('td')[6].string), + 'leechers': tryInt(result.find_all('td')[7].string), + }) except: log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc())) From 3310bdf5517e7af276c2b95adb2e89e26c563468 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 28 Sep 2013 14:30:20 +0200 Subject: [PATCH 2/2] Don't use quotes for torrentshack --- couchpotato/core/providers/torrent/torrentshack/main.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/couchpotato/core/providers/torrent/torrentshack/main.py b/couchpotato/core/providers/torrent/torrentshack/main.py index bc7077bb..6b3b5548 100644 --- a/couchpotato/core/providers/torrent/torrentshack/main.py +++ b/couchpotato/core/providers/torrent/torrentshack/main.py @@ -31,14 +31,9 @@ class TorrentShack(TorrentProvider): def _searchOnTitle(self, title, movie, quality, results): - # scene only unset by default - scene_only = "" - if self.conf('scene_only'): - scene_only = "1" + scene_only = '1' if self.conf('scene_only') else '' - url = self.urls['search'] % (tryUrlencode('"%s" %s' % (title.replace(':', ''), movie['library']['year'])), - scene_only, - self.getCatId(quality['identifier'])[0]) + url = self.urls['search'] % (tryUrlencode('%s %s' % (title.replace(':', ''), movie['library']['year'])), scene_only, self.getCatId(quality['identifier'])[0]) data = self.getHTMLData(url, opener = self.login_opener) if data: