From 286fce9afd76e00544f1c0ec52a40c55589768b2 Mon Sep 17 00:00:00 2001 From: bwq Date: Fri, 22 Jun 2012 01:36:47 +0200 Subject: [PATCH] Replaced all tabs. --- .../providers/torrent/sceneaccess/__init__.py | 2 +- .../providers/torrent/sceneaccess/main.py | 86 +++++++-------- .../providers/torrent/scenehd/__init__.py | 2 +- .../core/providers/torrent/scenehd/main.py | 100 +++++++++--------- .../torrent/torrentleech/__init__.py | 2 +- .../providers/torrent/torrentleech/main.py | 86 +++++++-------- 6 files changed, 139 insertions(+), 139 deletions(-) diff --git a/couchpotato/core/providers/torrent/sceneaccess/__init__.py b/couchpotato/core/providers/torrent/sceneaccess/__init__.py index 385f015f..3a128638 100644 --- a/couchpotato/core/providers/torrent/sceneaccess/__init__.py +++ b/couchpotato/core/providers/torrent/sceneaccess/__init__.py @@ -16,7 +16,7 @@ config = [{ 'type': 'enabler', 'default': False, }, - { + { 'name': 'username', 'default': '', }, diff --git a/couchpotato/core/providers/torrent/sceneaccess/main.py b/couchpotato/core/providers/torrent/sceneaccess/main.py index d42a7b07..09d7dfa9 100644 --- a/couchpotato/core/providers/torrent/sceneaccess/main.py +++ b/couchpotato/core/providers/torrent/sceneaccess/main.py @@ -46,64 +46,64 @@ class SceneAccess(TorrentProvider): if data: cat_ids = self.getCatId(quality['identifier']) - - try: - cookiejar = cookielib.CookieJar() - opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) - urllib2.install_opener(opener) - params = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), submit='come on in')) - f = opener.open('https://www.sceneaccess.eu/login', params) - data = f.read() - f.close() - f = opener.open(searchUrl) - data = f.read() - f.close() - except (IOError, URLError): + try: + cookiejar = cookielib.CookieJar() + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) + urllib2.install_opener(opener) + params = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), submit='come on in')) + f = opener.open('https://www.sceneaccess.eu/login', params) + data = f.read() + f.close() + f = opener.open(searchUrl) + data = f.read() + f.close() + + except (IOError, URLError): log.error('Failed to open %s.' % url) - return results + return results html = BeautifulSoup(data) - try: - resultsTable = html.find('table', attrs = {'id' : 'torrents-table'}) - entries = resultsTable.findAll('tr', attrs = {'class' : 'tt_row'}) - for result in entries: - new = { - 'type': 'torrent', + try: + resultsTable = html.find('table', attrs = {'id' : 'torrents-table'}) + entries = resultsTable.findAll('tr', attrs = {'class' : 'tt_row'}) + for result in entries: + new = { + 'type': 'torrent', 'check_nzb': False, 'description': '', 'provider': self.getName(), } - link = result.find('td', attrs = {'class' : 'ttr_name'}).find('a') - new['name'] = link['title'] - new['id'] = link['href'].replace('details?id=', '') + link = result.find('td', attrs = {'class' : 'ttr_name'}).find('a') + new['name'] = link['title'] + new['id'] = link['href'].replace('details?id=', '') url = result.find('td', attrs = {'class' : 'td_dl'}).find('a') new['url'] = self.urls['download'] % url['href'] - new['size'] = self.parseSize(result.find('td', attrs = {'class' : 'ttr_size'}).contents[0]) - new['seeders'] = int(result.find('td', attrs = {'class' : 'ttr_seeders'}).find('a').string) - leechers = result.find('td', attrs = {'class' : 'ttr_leechers'}).find('a') - if leechers: - new['leechers'] = int(leechers.string) - else: - new['leechers'] = 0 - - new['imdbid'] = movie['library']['identifier'] - new['extra_score'] = self.extra_score - new['score'] = fireEvent('score.calculate', new, movie, single = True) - is_correct_movie = fireEvent('searcher.correct_movie', nzb = new, movie = movie, quality = quality, + new['size'] = self.parseSize(result.find('td', attrs = {'class' : 'ttr_size'}).contents[0]) + new['seeders'] = int(result.find('td', attrs = {'class' : 'ttr_seeders'}).find('a').string) + leechers = result.find('td', attrs = {'class' : 'ttr_leechers'}).find('a') + if leechers: + new['leechers'] = int(leechers.string) + else: + new['leechers'] = 0 + + new['imdbid'] = movie['library']['identifier'] + new['extra_score'] = self.extra_score + new['score'] = fireEvent('score.calculate', new, movie, single = True) + is_correct_movie = fireEvent('searcher.correct_movie', nzb = new, movie = movie, quality = quality, imdb_results = True, single_category = False, single = True) if is_correct_movie: - new['download'] = self.download + new['download'] = self.download results.append(new) self.found(new) - return results + return results - except: - log.info("No results found at SceneAccess") - return [] + except: + log.info("No results found at SceneAccess") + return [] def extra_score(self, nzb): url = self.urls['detail'] % nzb['id'] @@ -123,9 +123,9 @@ class SceneAccess(TorrentProvider): imdbDiv = str(imdbDiv).decode("utf-8", "replace") imdbIdAlt = re.sub('tt[0]*', 'tt', imdbId) - if 'imdb.com/title/' + imdbId in imdbDiv or 'imdb.com/title/' + imdbIdAlt in imdbDiv: - return 50 - return 0 + if 'imdb.com/title/' + imdbId in imdbDiv or 'imdb.com/title/' + imdbIdAlt in imdbDiv: + return 50 + return 0 def download(self, url = '', nzb_id = ''): torrent = self.urlopen(url) diff --git a/couchpotato/core/providers/torrent/scenehd/__init__.py b/couchpotato/core/providers/torrent/scenehd/__init__.py index 010b2784..d4b7a0b8 100644 --- a/couchpotato/core/providers/torrent/scenehd/__init__.py +++ b/couchpotato/core/providers/torrent/scenehd/__init__.py @@ -16,7 +16,7 @@ config = [{ 'type': 'enabler', 'default': False, }, - { + { 'name': 'username', 'default': '', }, diff --git a/couchpotato/core/providers/torrent/scenehd/main.py b/couchpotato/core/providers/torrent/scenehd/main.py index 4e6d5539..497f2d09 100644 --- a/couchpotato/core/providers/torrent/scenehd/main.py +++ b/couchpotato/core/providers/torrent/scenehd/main.py @@ -39,77 +39,77 @@ class SceneHD(TorrentProvider): data = self.getCache(cache_key, searchUrl) if data: - - try: - cookiejar = cookielib.CookieJar() - opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) - urllib2.install_opener(opener) - params = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), ssl='yes')) - f = opener.open('http://scenehd.org/takelogin.php', params) - data = f.read() - f.close() - f = opener.open(searchUrl) - data = f.read() - f.close() - except (IOError, URLError): + try: + cookiejar = cookielib.CookieJar() + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) + urllib2.install_opener(opener) + params = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), ssl='yes')) + f = opener.open('http://scenehd.org/takelogin.php', params) + data = f.read() + f.close() + f = opener.open(searchUrl) + data = f.read() + f.close() + + except (IOError, URLError): log.error('Failed to open %s.' % url) - return results + return results html = BeautifulSoup(data) - - try: - resultsTable = html.findAll('table')[6] - entries = resultsTable.findAll('tr') - for result in entries[1:]: - new = { - 'type': 'torrent', + + try: + resultsTable = html.findAll('table')[6] + entries = resultsTable.findAll('tr') + for result in entries[1:]: + new = { + 'type': 'torrent', 'check_nzb': False, 'description': '', 'provider': self.getName(), } - allCells = result.findAll('td') - new['size'] = self.parseSize(allCells[7].string.replace('GiB', 'GB')) + allCells = result.findAll('td') + new['size'] = self.parseSize(allCells[7].string.replace('GiB', 'GB')) new['seeders'] = allCells[10].find('a').string - leechers = allCells[11].find('a') - if leechers: - new['leechers'] = leechers.string + leechers = allCells[11].find('a') + if leechers: + new['leechers'] = leechers.string else: - new['leechers'] = allCells[11].string - - detailLink = allCells[2].find('a') - details = detailLink['href'] - new['id'] = details.replace('details.php?id=', '') - new['name'] = detailLink['title'] - - imdbLink = allCells[1].find('a') - if imdbLink: - new['imdbresult'] = imdbLink['href'].replace('http://www.imdb.com/title/','').rstrip('/') - else: - new['imdbresult'] = 'tt00000000' - - new['url'] = self.urls['download'] % new['id'] - new['imdbid'] = movie['library']['identifier'] - new['extra_score'] = self.extra_score - new['score'] = fireEvent('score.calculate', new, movie, single = True) - is_correct_movie = fireEvent('searcher.correct_movie', nzb = new, movie = movie, quality = quality, + new['leechers'] = allCells[11].string + + detailLink = allCells[2].find('a') + details = detailLink['href'] + new['id'] = details.replace('details.php?id=', '') + new['name'] = detailLink['title'] + + imdbLink = allCells[1].find('a') + if imdbLink: + new['imdbresult'] = imdbLink['href'].replace('http://www.imdb.com/title/','').rstrip('/') + else: + new['imdbresult'] = 'tt00000000' + + new['url'] = self.urls['download'] % new['id'] + new['imdbid'] = movie['library']['identifier'] + new['extra_score'] = self.extra_score + new['score'] = fireEvent('score.calculate', new, movie, single = True) + is_correct_movie = fireEvent('searcher.correct_movie', nzb = new, movie = movie, quality = quality, imdb_results = True, single_category = False, single = True) if is_correct_movie: - new['download'] = self.download + new['download'] = self.download results.append(new) self.found(new) - return results + return results - except: - log.info("No results found at SceneHD") - return [] + except: + log.info("No results found at SceneHD") + return [] def extra_score(self, nzb): imdbIdAlt = re.sub('tt[0]*', 'tt', nzb['imdbresult']) if nzb['imdbresult'] == nzb['imdbid'] or imdbIdAlt == nzb['imdbid']: - return 50 + return 50 return 0 def download(self, url = '', nzb_id = ''): diff --git a/couchpotato/core/providers/torrent/torrentleech/__init__.py b/couchpotato/core/providers/torrent/torrentleech/__init__.py index 0fb62804..19627e11 100644 --- a/couchpotato/core/providers/torrent/torrentleech/__init__.py +++ b/couchpotato/core/providers/torrent/torrentleech/__init__.py @@ -16,7 +16,7 @@ config = [{ 'type': 'enabler', 'default': False, }, - { + { 'name': 'username', 'default': '', }, diff --git a/couchpotato/core/providers/torrent/torrentleech/main.py b/couchpotato/core/providers/torrent/torrentleech/main.py index daecc149..0a693dc1 100644 --- a/couchpotato/core/providers/torrent/torrentleech/main.py +++ b/couchpotato/core/providers/torrent/torrentleech/main.py @@ -24,7 +24,7 @@ class TorrentLeech(TorrentProvider): 'test' : 'http://torrentleech.org/', 'detail' : 'http://torrentleech.org/torrent/%s', 'search' : 'http://torrentleech.org/torrents/browse/index/query/%s/categories/%d', - 'download' : 'http://torrentleech.org%s', + 'download' : 'http://torrentleech.org%s', } cat_ids = [ @@ -46,66 +46,66 @@ class TorrentLeech(TorrentProvider): return results cache_key = 'torrentleech.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) - searchUrl = self.urls['search'] % (quote_plus(getTitle(movie['library']) + ' ' + quality['identifier']), self.getCatId(quality['identifier'])[0]) + searchUrl = self.urls['search'] % (quote_plus(getTitle(movie['library']) + ' ' + quality['identifier']), self.getCatId(quality['identifier'])[0]) data = self.getCache(cache_key, searchUrl) - if data: + if data: cat_ids = self.getCatId(quality['identifier']) - - try: - cookiejar = cookielib.CookieJar() - opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) - urllib2.install_opener(opener) - params = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), remember_me='on', login='submit')) - f = opener.open('http://torrentleech.org/user/account/login/', params) - data = f.read() - f.close() - f = opener.open(searchUrl) - data = f.read() - f.close() - except (IOError, URLError): + try: + cookiejar = cookielib.CookieJar() + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) + urllib2.install_opener(opener) + params = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), remember_me='on', login='submit')) + f = opener.open('http://torrentleech.org/user/account/login/', params) + data = f.read() + f.close() + f = opener.open(searchUrl) + data = f.read() + f.close() + + except (IOError, URLError): log.error('Failed to open %s.' % url) - return results + return results - html = BeautifulSoup(data) + html = BeautifulSoup(data) try: - resultsTable = html.find('table', attrs = {'id' : 'torrenttable'}) - entries = resultsTable.findAll('tr') - for result in entries[1:]: - new = { - 'type': 'torrent', + resultsTable = html.find('table', attrs = {'id' : 'torrenttable'}) + entries = resultsTable.findAll('tr') + for result in entries[1:]: + new = { + 'type': 'torrent', 'check_nzb': False, 'description': '', 'provider': self.getName(), } - link = result.find('td', attrs = {'class' : 'name'}).find('a') - new['name'] = link.string - new['id'] = link['href'].replace('/torrent/', '') + link = result.find('td', attrs = {'class' : 'name'}).find('a') + new['name'] = link.string + new['id'] = link['href'].replace('/torrent/', '') url = result.find('td', attrs = {'class' : 'quickdownload'}).find('a') new['url'] = self.urls['download'] % url['href'] - new['size'] = self.parseSize(result.findAll('td')[4].string) - new['seeders'] = int(result.find('td', attrs = {'class' : 'seeders'}).string) - new['leechers'] = int(result.find('td', attrs = {'class' : 'leechers'}).string) - new['imdbid'] = movie['library']['identifier'] - - new['extra_score'] = self.extra_score - new['score'] = fireEvent('score.calculate', new, movie, single = True) - is_correct_movie = fireEvent('searcher.correct_movie', nzb = new, movie = movie, quality = quality, + new['size'] = self.parseSize(result.findAll('td')[4].string) + new['seeders'] = int(result.find('td', attrs = {'class' : 'seeders'}).string) + new['leechers'] = int(result.find('td', attrs = {'class' : 'leechers'}).string) + new['imdbid'] = movie['library']['identifier'] + + new['extra_score'] = self.extra_score + new['score'] = fireEvent('score.calculate', new, movie, single = True) + is_correct_movie = fireEvent('searcher.correct_movie', nzb = new, movie = movie, quality = quality, imdb_results = True, single_category = False, single = True) if is_correct_movie: - new['download'] = self.download + new['download'] = self.download results.append(new) self.found(new) - return results + return results - except: - log.info("No results found at TorrentLeech") - return [] + except: + log.info("No results found at TorrentLeech") + return [] def extra_score(self, nzb): url = self.urls['detail'] % nzb['id'] @@ -121,10 +121,10 @@ class TorrentLeech(TorrentProvider): return '' imdbIdAlt = re.sub('tt[0]*', 'tt', imdbId) - data = unicode(data, errors='ignore') - if 'imdb.com/title/' + imdbId in data or 'imdb.com/title/' + imdbIdAlt in data: - return 50 - return 0 + data = unicode(data, errors='ignore') + if 'imdb.com/title/' + imdbId in data or 'imdb.com/title/' + imdbIdAlt in data: + return 50 + return 0 def download(self, url = '', nzb_id = ''): torrent = self.urlopen(url)