From b22763b37d7780140698725a0ed2632e2eb7a7c2 Mon Sep 17 00:00:00 2001 From: Ruud Burger Date: Thu, 26 Apr 2012 10:57:34 +0300 Subject: [PATCH 1/8] Use master branch to update master.. --- couchpotato/core/_base/updater/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index f5182228..9b4d8ca4 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -78,7 +78,7 @@ class BaseUpdater(Plugin): repo_user = 'RuudBurger' repo_name = 'CouchPotatoServer' - branch = 'develop' + branch = 'master' version = None update_failed = False From d1c2869f2cb4b3fac555cce732e92bb8fec97363 Mon Sep 17 00:00:00 2001 From: Ken Garland Date: Thu, 26 Apr 2012 23:30:33 -0300 Subject: [PATCH 2/8] Removed RUN_AS for group, don't assume the default group is the same as the username. Specifying group is not needed anyways. --- init/ubuntu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/ubuntu b/init/ubuntu index 8abc9e79..d6af148a 100644 --- a/init/ubuntu +++ b/init/ubuntu @@ -45,7 +45,7 @@ case "$1" in start) echo "Starting $DESC" rm -rf $PID_PATH || return 1 - install -d --mode=0755 -o $RUN_AS -g $RUN_AS $PID_PATH || return 1 + install -d --mode=0755 -o $RUN_AS $PID_PATH || return 1 start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS ;; stop) From ba8fef3c87484e4898a196ef9b25c69be68f9825 Mon Sep 17 00:00:00 2001 From: Riccardo Sirchia Date: Sun, 6 May 2012 18:02:51 +0200 Subject: [PATCH 3/8] Added support for direct messages in twitter notifications --- .../core/notifications/twitter/__init__.py | 7 +++++++ couchpotato/core/notifications/twitter/main.py | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/notifications/twitter/__init__.py b/couchpotato/core/notifications/twitter/__init__.py index 266a2877..5910b0a2 100644 --- a/couchpotato/core/notifications/twitter/__init__.py +++ b/couchpotato/core/notifications/twitter/__init__.py @@ -38,6 +38,13 @@ config = [{ 'advanced': True, 'description': 'Also send message when movie is snatched.', }, + { + 'name': 'direct_message', + 'default': 0, + 'type': 'bool', + 'advanced': True, + 'description': 'Use direct messages for the notifications (Also applies to the mentioned users).', + }, ], } ], diff --git a/couchpotato/core/notifications/twitter/main.py b/couchpotato/core/notifications/twitter/main.py index 700f7fa3..dcac0673 100644 --- a/couchpotato/core/notifications/twitter/main.py +++ b/couchpotato/core/notifications/twitter/main.py @@ -36,12 +36,24 @@ class Twitter(Notification): api = Api(self.consumer_key, self.consumer_secret, self.conf('access_token_key'), self.conf('access_token_secret')) + direct_message = self.conf('direct_message') + direct_message_users = self.conf('screen_name') + mention = self.conf('mention') if mention: - message = '%s @%s' % (message, mention.lstrip('@')) + if direct_message: + direct_message_users = '%s %s' % (direct_message_users, mention) + direct_message_users = direct_message_users.replace('@',' ') + direct_message_users = direct_message_users.replace(',',' ') + else: + message = '%s @%s' % (message, mention.lstrip('@')) try: - api.PostUpdate('[%s] %s' % (self.default_title, message)) + if direct_message: + for user in direct_message_users.split(): + api.PostDirectMessage(user, '[%s] %s' % (self.default_title, message)) + else: + api.PostUpdate('[%s] %s' % (self.default_title, message)) except Exception, e: log.error('Error sending tweet: %s' % e) return False From d4a5483fa034d960bb7160a076ee11507e3bdc78 Mon Sep 17 00:00:00 2001 From: Ruud Burger Date: Thu, 26 Apr 2012 10:57:34 +0300 Subject: [PATCH 4/8] Use master branch to update master.. --- couchpotato/core/_base/updater/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index c12c4b9f..17749239 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -80,7 +80,7 @@ class BaseUpdater(Plugin): repo_user = 'RuudBurger' repo_name = 'CouchPotatoServer' - branch = 'develop' + branch = 'master' version = None update_failed = False From fdf0d2d5b403bad860a06475b1dafce7c28e2da5 Mon Sep 17 00:00:00 2001 From: Ruud Burger Date: Thu, 26 Apr 2012 10:57:34 +0300 Subject: [PATCH 5/8] Use master branch to update master.. --- couchpotato/core/_base/updater/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index 0d7b04f6..87716610 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -80,7 +80,7 @@ class BaseUpdater(Plugin): repo_user = 'RuudBurger' repo_name = 'CouchPotatoServer' - branch = 'develop' + branch = 'master' version = None update_failed = False From 62bec0521bc6313cc08a7762e9d908bebaa400c2 Mon Sep 17 00:00:00 2001 From: Ruud Burger Date: Thu, 26 Apr 2012 10:57:34 +0300 Subject: [PATCH 6/8] Use master branch to update master.. --- couchpotato/core/_base/updater/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index 279cadd4..4c75c59a 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -94,7 +94,7 @@ class BaseUpdater(Plugin): repo_user = 'RuudBurger' repo_name = 'CouchPotatoServer' - branch = 'develop' + branch = 'master' version = None update_failed = False From 1a63baaa139fa6a69f1c1c1fc5612f56b207b076 Mon Sep 17 00:00:00 2001 From: bwq Date: Wed, 20 Jun 2012 20:26:54 +0200 Subject: [PATCH 7/8] Added 3 torrent providers - SceneAccess, SceneHD and TorrentLeech --- .../providers/torrent/sceneaccess/__init__.py | 31 ++++ .../providers/torrent/sceneaccess/main.py | 134 ++++++++++++++++++ .../providers/torrent/scenehd/__init__.py | 31 ++++ .../core/providers/torrent/scenehd/main.py | 119 ++++++++++++++++ .../torrent/torrentleech/__init__.py | 31 ++++ .../providers/torrent/torrentleech/main.py | 133 +++++++++++++++++ 6 files changed, 479 insertions(+) create mode 100644 couchpotato/core/providers/torrent/sceneaccess/__init__.py create mode 100644 couchpotato/core/providers/torrent/sceneaccess/main.py create mode 100644 couchpotato/core/providers/torrent/scenehd/__init__.py create mode 100644 couchpotato/core/providers/torrent/scenehd/main.py create mode 100644 couchpotato/core/providers/torrent/torrentleech/__init__.py create mode 100644 couchpotato/core/providers/torrent/torrentleech/main.py diff --git a/couchpotato/core/providers/torrent/sceneaccess/__init__.py b/couchpotato/core/providers/torrent/sceneaccess/__init__.py new file mode 100644 index 00000000..385f015f --- /dev/null +++ b/couchpotato/core/providers/torrent/sceneaccess/__init__.py @@ -0,0 +1,31 @@ +from .main import SceneAccess + +def start(): + return SceneAccess() + +config = [{ + 'name': 'sceneaccess', + 'groups': [ + { + 'tab': 'searcher', + 'subtab': 'providers', + 'name': 'SceneAccess', + 'options': [ + { + 'name': 'enabled', + 'type': 'enabler', + 'default': False, + }, + { + 'name': 'username', + 'default': '', + }, + { + 'name': 'password', + 'default': '', + 'type': 'password', + }, + ], + }, + ], +}] diff --git a/couchpotato/core/providers/torrent/sceneaccess/main.py b/couchpotato/core/providers/torrent/sceneaccess/main.py new file mode 100644 index 00000000..d42a7b07 --- /dev/null +++ b/couchpotato/core/providers/torrent/sceneaccess/main.py @@ -0,0 +1,134 @@ +from bs4 import BeautifulSoup +from couchpotato.core.event import fireEvent +from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.torrent.base import TorrentProvider +import StringIO +import gzip +import re +import traceback +import urllib +import urllib2 +import cookielib +from urllib import quote_plus +from urllib2 import URLError + +log = CPLog(__name__) + + +class SceneAccess(TorrentProvider): + + urls = { + 'test': 'https://www.sceneaccess.eu/', + 'detail': 'https://www.sceneaccess.eu/details?id=%s', + 'search': 'https://www.sceneaccess.eu/browse?search=%s&method=2&c%d=%d', + 'download': 'https://www.sceneaccess.eu/%s', + } + + cat_ids = [ + ([22], ['720p', '1080p']), + ([7], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr', 'brrip']), + ([8], ['dvdr']), + ] + + http_time_between_calls = 1 #seconds + + def search(self, movie, quality): + + results = [] + if self.isDisabled(): + return results + + cache_key = 'sceneaccess.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) + searchUrl = self.urls['search'] % (quote_plus(getTitle(movie['library']) + ' ' + quality['identifier']), self.getCatId(quality['identifier'])[0], self.getCatId(quality['identifier'])[0]) + data = self.getCache(cache_key, searchUrl) + + 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): + log.error('Failed to open %s.' % url) + 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', + '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=', '') + 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, + imdb_results = True, single_category = False, single = True) + + if is_correct_movie: + new['download'] = self.download + results.append(new) + self.found(new) + return results + + except: + log.info("No results found at SceneAccess") + return [] + + def extra_score(self, nzb): + url = self.urls['detail'] % nzb['id'] + imdbId = nzb['imdbid'] + return self.imdbMatch(url, imdbId) + + def imdbMatch(self, url, imdbId): + try: + data = urllib2.urlopen(url).read() + pass + except IOError: + log.error('Failed to open %s.' % url) + return '' + + html = BeautifulSoup(data) + imdbDiv = html.find('span', attrs = {'class':'i_link'}) + 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 + + def download(self, url = '', nzb_id = ''): + torrent = self.urlopen(url) + return torrent + + diff --git a/couchpotato/core/providers/torrent/scenehd/__init__.py b/couchpotato/core/providers/torrent/scenehd/__init__.py new file mode 100644 index 00000000..010b2784 --- /dev/null +++ b/couchpotato/core/providers/torrent/scenehd/__init__.py @@ -0,0 +1,31 @@ +from .main import SceneHD + +def start(): + return SceneHD() + +config = [{ + 'name': 'scenehd', + 'groups': [ + { + 'tab': 'searcher', + 'subtab': 'providers', + 'name': 'SceneHD', + 'options': [ + { + 'name': 'enabled', + 'type': 'enabler', + 'default': False, + }, + { + 'name': 'username', + 'default': '', + }, + { + 'name': 'password', + 'default': '', + 'type': 'password', + }, + ], + }, + ], +}] diff --git a/couchpotato/core/providers/torrent/scenehd/main.py b/couchpotato/core/providers/torrent/scenehd/main.py new file mode 100644 index 00000000..4e6d5539 --- /dev/null +++ b/couchpotato/core/providers/torrent/scenehd/main.py @@ -0,0 +1,119 @@ +from bs4 import BeautifulSoup +from couchpotato.core.event import fireEvent +from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.torrent.base import TorrentProvider +import StringIO +import gzip +import re +import traceback +import urllib +import urllib2 +import cookielib +from urllib import quote_plus +from urllib2 import URLError + + +log = CPLog(__name__) + + +class SceneHD(TorrentProvider): + + urls = { + 'test': 'http://scenehd.org/', + 'detail': 'http://scenehd.org/details.php?id=%s', + 'search': 'http://scenehd.org/browse.php?ajax&search=%s', + 'download': 'http://scenehd.org/download.php?id=%s', + } + + http_time_between_calls = 1 #seconds + + def search(self, movie, quality): + + results = [] + if self.isDisabled(): + return results + + cache_key = 'scenehd.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) + searchUrl = self.urls['search'] % (quote_plus(getTitle(movie['library']) + ' ' + quality['identifier'])) + 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): + log.error('Failed to open %s.' % url) + return results + + html = BeautifulSoup(data) + + 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')) + new['seeders'] = allCells[10].find('a').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, + imdb_results = True, single_category = False, single = True) + + if is_correct_movie: + new['download'] = self.download + results.append(new) + self.found(new) + return results + + 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 0 + + def download(self, url = '', nzb_id = ''): + torrent = self.urlopen(url) + return torrent + + diff --git a/couchpotato/core/providers/torrent/torrentleech/__init__.py b/couchpotato/core/providers/torrent/torrentleech/__init__.py new file mode 100644 index 00000000..0fb62804 --- /dev/null +++ b/couchpotato/core/providers/torrent/torrentleech/__init__.py @@ -0,0 +1,31 @@ +from .main import TorrentLeech + +def start(): + return TorrentLeech() + +config = [{ + 'name': 'torrentleech', + 'groups': [ + { + 'tab': 'searcher', + 'subtab': 'providers', + 'name': 'TorrentLeech', + 'options': [ + { + 'name': 'enabled', + 'type': 'enabler', + 'default': False, + }, + { + 'name': 'username', + 'default': '', + }, + { + 'name': 'password', + 'default': '', + 'type': 'password', + }, + ], + }, + ], +}] diff --git a/couchpotato/core/providers/torrent/torrentleech/main.py b/couchpotato/core/providers/torrent/torrentleech/main.py new file mode 100644 index 00000000..daecc149 --- /dev/null +++ b/couchpotato/core/providers/torrent/torrentleech/main.py @@ -0,0 +1,133 @@ +from bs4 import BeautifulSoup +from couchpotato.core.event import fireEvent +from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.torrent.base import TorrentProvider +import StringIO +import gzip +import re +import traceback +import urllib +import urllib2 +import cookielib +from urllib import quote_plus +from urllib2 import URLError +import sys + + +log = CPLog(__name__) + + +class TorrentLeech(TorrentProvider): + + urls = { + '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', + } + + cat_ids = [ + ([13], ['720p', '1080p']), + ([8], ['cam']), + ([9], ['ts', 'tc']), + ([10], ['r5', 'scr']), + ([11], ['dvdrip']), + ([14], ['brrip']), + ([12], ['dvdr']), + ] + + http_time_between_calls = 1 #seconds + + def search(self, movie, quality): + + results = [] + if self.isDisabled(): + 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]) + data = self.getCache(cache_key, searchUrl) + + 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): + log.error('Failed to open %s.' % url) + return results + + html = BeautifulSoup(data) + + try: + 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/', '') + 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, + imdb_results = True, single_category = False, single = True) + + if is_correct_movie: + new['download'] = self.download + results.append(new) + self.found(new) + return results + + except: + log.info("No results found at TorrentLeech") + return [] + + def extra_score(self, nzb): + url = self.urls['detail'] % nzb['id'] + imdbId = nzb['imdbid'] + return self.imdbMatch(url, imdbId) + + def imdbMatch(self, url, imdbId): + try: + data = urllib2.urlopen(url).read() + pass + except IOError: + log.error('Failed to open %s.' % url) + 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 + + def download(self, url = '', nzb_id = ''): + torrent = self.urlopen(url) + return torrent + + From 286fce9afd76e00544f1c0ec52a40c55589768b2 Mon Sep 17 00:00:00 2001 From: bwq Date: Fri, 22 Jun 2012 01:36:47 +0200 Subject: [PATCH 8/8] 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)