From 631759d833a394128a4790977e743ed8efb36076 Mon Sep 17 00:00:00 2001 From: sax Date: Tue, 28 May 2013 15:33:30 +0000 Subject: [PATCH] Added configuration option to search over scene releases only. Fixed release name issue (removed ­ element). --- .../torrent/torrentshack/__init__.py | 5 ++++ .../providers/torrent/torrentshack/main.py | 30 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/couchpotato/core/providers/torrent/torrentshack/__init__.py b/couchpotato/core/providers/torrent/torrentshack/__init__.py index 2d78da06..1c0d8a12 100644 --- a/couchpotato/core/providers/torrent/torrentshack/__init__.py +++ b/couchpotato/core/providers/torrent/torrentshack/__init__.py @@ -28,6 +28,11 @@ config = [{ 'default': '', 'type': 'password', }, + { + 'name': 'scene only', + 'type': 'bool', + 'default': False + }, { 'name': 'extra_score', 'advanced': True, diff --git a/couchpotato/core/providers/torrent/torrentshack/main.py b/couchpotato/core/providers/torrent/torrentshack/main.py index 2c428e28..08e0faf6 100644 --- a/couchpotato/core/providers/torrent/torrentshack/main.py +++ b/couchpotato/core/providers/torrent/torrentshack/main.py @@ -44,21 +44,29 @@ class TorrentShack(TorrentProvider): entries = result_table.find_all('tr', attrs = {'class' : 'torrent'}) - for result in entries[1:]: + for result in entries: link = result.find('span', attrs = {'class' : 'torrent_name_link'}).parent url = result.find('td', attrs = {'class' : 'torrent_td'}).find('a') - results.append({ - 'id': link['href'].replace('torrents.php?torrentid=', ''), - 'name': link.span.string, - 'url': self.urls['download'] % url['href'], - 'detail_url': self.urls['download'] % link['href'], - 'download': self.loginDownload, - '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), - }) + 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'], + 'download': self.loginDownload, + '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), + }) + log.info('Adding release %s' % unicode(link.span.string).translate({ord(u'\xad'): None})) + else: + log.info('Not adding release %s [NotScene]' % unicode(link.span.string).translate({ord(u'\xad'): None})) except: log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))