From 71123d826b485903909d472be6a484f10d0a4be6 Mon Sep 17 00:00:00 2001 From: Toliver182 Date: Wed, 14 Feb 2018 16:51:24 +0000 Subject: [PATCH 01/35] Update settings.scss Amend the margin to ensure that button always show. --- couchpotato/static/style/settings.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/static/style/settings.scss b/couchpotato/static/style/settings.scss index 0724ada..ad19dcd 100644 --- a/couchpotato/static/style/settings.scss +++ b/couchpotato/static/style/settings.scss @@ -704,7 +704,7 @@ z-index: 2; position: absolute; width: 450px; - margin: 28px 0 20px 0; + margin: 75px 0 20px 0; @include theme(background, primary); box-shadow: 0 0 15px 2px rgba(0,0,0,.15); border-radius: $border_radius $border_radius 0 0; From 97d9c51cc3f0239e778b2de64e5d4dc9bad37e7b Mon Sep 17 00:00:00 2001 From: swordfish5975 Date: Sat, 10 Mar 2018 02:44:51 +1000 Subject: [PATCH 02/35] fix iptorrents.py --- .../media/_base/providers/torrent/iptorrents.py | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index e3331ef..980576c 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -25,6 +25,14 @@ class Base(TorrentProvider): login_fail_msg = 'Invalid username and password combination' cat_backup_id = None + def loginDownload(self, url = '', nzb_id = ''): + try: + if not self.login(): + log.error('Failed downloading from %s', self.getName()) + return self.urlopen(url, headers=self.getRequestHeaders()) + except: + log.error('Failed downloading from %s: %s', (self.getName(), traceback.format_exc())) + def buildUrl(self, title, media, quality): return self._buildUrl(title.replace(':', ''), quality) @@ -37,7 +45,7 @@ class Base(TorrentProvider): return None query = query.replace('"', '') - + return self.urls['search'] % ("&".join(("%d=" % x) for x in cat_ids), tryUrlencode(query).replace('%', '%%')) def _searchOnTitle(self, title, media, quality, results): @@ -50,7 +58,7 @@ class Base(TorrentProvider): pages = 1 current_page = 1 while current_page <= pages and not self.shuttingDown(): - data = self.getHTMLData(base_url % (freeleech, current_page)) + data = self.getHTMLData(base_url % (freeleech, current_page), headers = self.getRequestHeaders()) if data: html = BeautifulSoup(data) @@ -102,6 +110,11 @@ class Base(TorrentProvider): current_page += 1 + def getRequestHeaders(self): + return { + 'Cookie': self.conf('cookiesetting') or '' + } + def getLoginParams(self): return { 'username': self.conf('username'), @@ -161,6 +174,12 @@ config = [{ 'default': 40, 'description': 'Will not be (re)moved until this seed time (in hours) is met.', }, + { + 'name': 'cookiesetting', + 'label': 'Cookies', + 'default': 'uid=1234;pass=567845439634987', + 'description': 'Use DevTools or Firebug to get these values after logging in on your browser', + }, { 'name': 'extra_score', 'advanced': True, @@ -173,3 +192,4 @@ config = [{ }, ], }] + From 3ff0e7ebdd163b73d673f7d2f55df02114adcce0 Mon Sep 17 00:00:00 2001 From: Lee Hilton Date: Sat, 2 Jun 2018 13:14:40 -0700 Subject: [PATCH 03/35] Added HTTPS and Port support to Plex notifications --- couchpotato/core/notifications/plex/__init__.py | 13 +++++++++++++ couchpotato/core/notifications/plex/server.py | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/notifications/plex/__init__.py b/couchpotato/core/notifications/plex/__init__.py index 957369b..4e2a4fd 100755 --- a/couchpotato/core/notifications/plex/__init__.py +++ b/couchpotato/core/notifications/plex/__init__.py @@ -24,6 +24,19 @@ config = [{ 'description': 'Hostname/IP, default localhost' }, { + 'name': 'media_server_port', + 'label': 'Port', + 'default': '32400', + 'description': 'Connection tot he Media Server should use this port' + }, + { + 'name': 'use_https', + 'label': 'Use HTTPS', + 'default': '0', + 'type': 'bool', + 'description': 'Connection to the Media Server should use HTTPS instead of HTTP' + }, + { 'name': 'username', 'label': 'Username', 'default': '', diff --git a/couchpotato/core/notifications/plex/server.py b/couchpotato/core/notifications/plex/server.py index 9c8df76..9c52e6d 100644 --- a/couchpotato/core/notifications/plex/server.py +++ b/couchpotato/core/notifications/plex/server.py @@ -38,7 +38,7 @@ class PlexServer(object): #Maintain support for older Plex installations without myPlex if not self.plex.conf('auth_token') and not self.plex.conf('username') and not self.plex.conf('password'): data = self.plex.urlopen('%s/%s' % ( - self.createHost(self.plex.conf('media_server'), port = 32400), + self.createHost(self.plex.conf('media_server'), port = self.plex.conf('media_server_port'), use_https = self.plex.conf('use_https')), path )) else: @@ -71,7 +71,7 @@ class PlexServer(object): #Add X-Plex-Token header for myPlex support workaround data = self.plex.urlopen('%s/%s?X-Plex-Token=%s' % ( - self.createHost(self.plex.conf('media_server'), port = 32400), + self.createHost(self.plex.conf('media_server'), port = self.plex.conf('media_server_port'), use_https = self.plex.conf('use_https')), path, self.plex.conf('auth_token') )) @@ -139,9 +139,9 @@ class PlexServer(object): return True - def createHost(self, host, port = None): + def createHost(self, host, port = None, use_https = False): - h = cleanHost(host) + h = cleanHost(host, True, use_https) p = urlparse(h) h = h.rstrip('/') From 051312d70e366e2afbe38d1888b4aa6c0d41ecd3 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 14:54:12 +1000 Subject: [PATCH 04/35] just cookie no login --- .../media/_base/providers/torrent/iptorrents.py | 35 +++++----------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 980576c..3cdb7b3 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -16,22 +16,13 @@ class Base(TorrentProvider): urls = { 'test': 'https://iptorrents.com/', 'base_url': 'https://iptorrents.com', - 'login': 'https://iptorrents.com/take_login.php', - 'login_check': 'https://iptorrents.com/oldinbox.php', 'search': 'https://iptorrents.com/t?%s%%s&q=%s&qf=ti#torrents&p=%%d', } http_time_between_calls = 1 # Seconds - login_fail_msg = 'Invalid username and password combination' + login_fail_msg = 'Invalid username and cookie combination' cat_backup_id = None - def loginDownload(self, url = '', nzb_id = ''): - try: - if not self.login(): - log.error('Failed downloading from %s', self.getName()) - return self.urlopen(url, headers=self.getRequestHeaders()) - except: - log.error('Failed downloading from %s: %s', (self.getName(), traceback.format_exc())) def buildUrl(self, title, media, quality): return self._buildUrl(title.replace(':', ''), quality) @@ -114,19 +105,14 @@ class Base(TorrentProvider): return { 'Cookie': self.conf('cookiesetting') or '' } + + def download(self, url = '', nzb_id = ''): + try: + return self.urlopen(url, headers=self.getRequestHeaders()) + except: + log.error('Failed getting release from %s: %s', (self.getName(), traceback.format_exc())) - def getLoginParams(self): - return { - 'username': self.conf('username'), - 'password': self.conf('password'), - 'login': 'submit', - } - - def loginSuccess(self, output): - return 'don\'t have an account' not in output.lower() - - def loginCheckSuccess(self, output): - return '/logout.php' in output.lower() + return 'try_next' config = [{ @@ -150,11 +136,6 @@ config = [{ 'default': '', }, { - 'name': 'password', - 'default': '', - 'type': 'password', - }, - { 'name': 'freeleech', 'default': 0, 'type': 'bool', From ba74ef5e3d6fced168a649e9ce5751771e64bb59 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 14:58:22 +1000 Subject: [PATCH 05/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 3cdb7b3..ee014c2 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -106,7 +106,7 @@ class Base(TorrentProvider): 'Cookie': self.conf('cookiesetting') or '' } - def download(self, url = '', nzb_id = ''): + def download(self, url = '', nzb_id = ''): try: return self.urlopen(url, headers=self.getRequestHeaders()) except: From 5155bcd06e70eb523cb5c8f86b237ff038c1a7c9 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:12:47 +1000 Subject: [PATCH 06/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index ee014c2..85185e6 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -16,7 +16,7 @@ class Base(TorrentProvider): urls = { 'test': 'https://iptorrents.com/', 'base_url': 'https://iptorrents.com', - 'search': 'https://iptorrents.com/t?%s%%s&q=%s&qf=ti#torrents&p=%%d', + 'search': 'https://iptorrents.com/t?q=%s&qf=ti#torrents&p=%%d', } http_time_between_calls = 1 # Seconds From 79ed0aa1d351a7744fb48b4146c1c0a7d60e9161 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:18:01 +1000 Subject: [PATCH 07/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 85185e6..ee014c2 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -16,7 +16,7 @@ class Base(TorrentProvider): urls = { 'test': 'https://iptorrents.com/', 'base_url': 'https://iptorrents.com', - 'search': 'https://iptorrents.com/t?q=%s&qf=ti#torrents&p=%%d', + 'search': 'https://iptorrents.com/t?%s%%s&q=%s&qf=ti#torrents&p=%%d', } http_time_between_calls = 1 # Seconds From 6b6b3d7f4b05ad4118a9e6613e0721d61d684350 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:22:13 +1000 Subject: [PATCH 08/35] Update iptorrents.py --- couchpotato/core/media/movie/providers/torrent/iptorrents.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/media/movie/providers/torrent/iptorrents.py b/couchpotato/core/media/movie/providers/torrent/iptorrents.py index 699d5b9..72d96bd 100644 --- a/couchpotato/core/media/movie/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/movie/providers/torrent/iptorrents.py @@ -11,9 +11,9 @@ class IPTorrents(MovieProvider, Base): cat_ids = [ ([87], ['3d']), - ([89], ['bd50']), - ([48], ['720p', '1080p']), - ([101], ['2160p']), + ([89, 90], ['bd50']), + ([48, 20, 62], ['720p', '1080p']), + ([100, 101], ['2160p']), ([48, 20], ['brrip']), ([7, 77], ['dvdrip']), ([6], ['dvdr']), From 0f0ac0eda1b542990169ecb1214dbb367de1c36f Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:32:31 +1000 Subject: [PATCH 09/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index ee014c2..d349b8f 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -62,7 +62,7 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.find('table', attrs={'id': 'torrents'}) + result_table = html.find('table', attrs={'id': 'torrents','class' : 't1'}) if not result_table or 'nothing found!' in data.lower(): return From b713b7c06761ecba1290b22e08599092811cfb77 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:34:49 +1000 Subject: [PATCH 10/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index d349b8f..deb06f1 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -50,10 +50,10 @@ class Base(TorrentProvider): current_page = 1 while current_page <= pages and not self.shuttingDown(): data = self.getHTMLData(base_url % (freeleech, current_page), headers = self.getRequestHeaders()) - + log.Debug('data: %s', data) if data: html = BeautifulSoup(data) - + try: page_nav = html.find('span', attrs = {'class': 'page_nav'}) if page_nav: From 6b7869b458fa358d967e88c716ebab63830ceb82 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:36:22 +1000 Subject: [PATCH 11/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index deb06f1..8bdecf9 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -50,7 +50,7 @@ class Base(TorrentProvider): current_page = 1 while current_page <= pages and not self.shuttingDown(): data = self.getHTMLData(base_url % (freeleech, current_page), headers = self.getRequestHeaders()) - log.Debug('data: %s', data) + log.debug('data: %s', data) if data: html = BeautifulSoup(data) From da28c494ace0edf8fce2cc4876e03b37be4dcf90 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:40:17 +1000 Subject: [PATCH 12/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 8bdecf9..e18b28b 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -50,7 +50,7 @@ class Base(TorrentProvider): current_page = 1 while current_page <= pages and not self.shuttingDown(): data = self.getHTMLData(base_url % (freeleech, current_page), headers = self.getRequestHeaders()) - log.debug('data: %s', data) + if data: html = BeautifulSoup(data) @@ -62,8 +62,8 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.find('table', attrs={'id': 'torrents','class' : 't1'}) - + result_table = html.find('table', attrs={'id': 'torrents'}) + log.debug('result_table: %s', result_table) if not result_table or 'nothing found!' in data.lower(): return From e99de9f6b277a487dcd11835efee2bb02cce0cd2 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:42:41 +1000 Subject: [PATCH 13/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index e18b28b..7e9068b 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -53,7 +53,7 @@ class Base(TorrentProvider): if data: html = BeautifulSoup(data) - + log.debug('html: %s', html) try: page_nav = html.find('span', attrs = {'class': 'page_nav'}) if page_nav: From 3d324b921ac0cbf02136bfa87d12c4472799afa3 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:48:21 +1000 Subject: [PATCH 14/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 7e9068b..18109d1 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -62,7 +62,7 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.find('table', attrs={'id': 'torrents'}) + result_table = html.find('table', attrs={'align': 'center', 'class':'t1', 'id': 'torrents'}) log.debug('result_table: %s', result_table) if not result_table or 'nothing found!' in data.lower(): return From 9542a24f191529cdb688175be3d9d92fdbb6b3ad Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:54:31 +1000 Subject: [PATCH 15/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 18109d1..c3f3552 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -53,7 +53,7 @@ class Base(TorrentProvider): if data: html = BeautifulSoup(data) - log.debug('html: %s', html) + try: page_nav = html.find('span', attrs = {'class': 'page_nav'}) if page_nav: @@ -62,7 +62,7 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.find('table', attrs={'align': 'center', 'class':'t1', 'id': 'torrents'}) + result_table = html.find(id="torrents") log.debug('result_table: %s', result_table) if not result_table or 'nothing found!' in data.lower(): return From 62e8c91e4a0bf215ee5635e37ec9fc8f787adaf7 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 15:59:32 +1000 Subject: [PATCH 16/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index c3f3552..b7a6631 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -62,9 +62,10 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.find(id="torrents") + result_table = html.select('table#torrents') log.debug('result_table: %s', result_table) - if not result_table or 'nothing found!' in data.lower(): + result_table = result_table[0] + if not result_table or 'nothing found!' in data.lower(): return entries = result_table.find_all('tr') From 18012c5fffd35e1e906ef4ce0cbad1ba4e1fc5da Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 16:01:16 +1000 Subject: [PATCH 17/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index b7a6631..c02270a 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -65,7 +65,7 @@ class Base(TorrentProvider): result_table = html.select('table#torrents') log.debug('result_table: %s', result_table) result_table = result_table[0] - if not result_table or 'nothing found!' in data.lower(): + if not result_table or 'nothing found!' in data.lower(): return entries = result_table.find_all('tr') From a291ae0c8f1d60976fb0cff59cf972dc9fdf6a59 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 16:04:24 +1000 Subject: [PATCH 18/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index c02270a..d4e2acd 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -62,7 +62,7 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.select('table#torrents') + result_table = html.find_all('table', id="torrents") log.debug('result_table: %s', result_table) result_table = result_table[0] if not result_table or 'nothing found!' in data.lower(): From 8fc37fd9bbf13cf6b148ce3127089c5ce7dcebc2 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 16:06:59 +1000 Subject: [PATCH 19/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index d4e2acd..188f93d 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -52,7 +52,7 @@ class Base(TorrentProvider): data = self.getHTMLData(base_url % (freeleech, current_page), headers = self.getRequestHeaders()) if data: - html = BeautifulSoup(data) + html = BeautifulSoup(data, parser="html.parser") try: page_nav = html.find('span', attrs = {'class': 'page_nav'}) @@ -62,7 +62,7 @@ class Base(TorrentProvider): final_page_link = next_link.previous_sibling.previous_sibling pages = int(final_page_link.string) - result_table = html.find_all('table', id="torrents") + result_table = html.find('table', id="torrents") log.debug('result_table: %s', result_table) result_table = result_table[0] if not result_table or 'nothing found!' in data.lower(): From 109c999186492b8f51cfeb91a4e7ba610350f641 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 16:26:03 +1000 Subject: [PATCH 20/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 188f93d..10ef564 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -52,7 +52,7 @@ class Base(TorrentProvider): data = self.getHTMLData(base_url % (freeleech, current_page), headers = self.getRequestHeaders()) if data: - html = BeautifulSoup(data, parser="html.parser") + html = BeautifulSoup(data) try: page_nav = html.find('span', attrs = {'class': 'page_nav'}) From 4cd81d3e1cf48f2560494c540d69fb47f425afb8 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 16:28:03 +1000 Subject: [PATCH 21/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 1 - 1 file changed, 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index 10ef564..f01b900 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -64,7 +64,6 @@ class Base(TorrentProvider): result_table = html.find('table', id="torrents") log.debug('result_table: %s', result_table) - result_table = result_table[0] if not result_table or 'nothing found!' in data.lower(): return From 3c9a28cf1a6ea4985bd3d3d38428cf9c5fa0e3af Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Sun, 10 Feb 2019 16:35:20 +1000 Subject: [PATCH 22/35] Update iptorrents.py --- couchpotato/core/media/_base/providers/torrent/iptorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/iptorrents.py b/couchpotato/core/media/_base/providers/torrent/iptorrents.py index f01b900..c25d686 100644 --- a/couchpotato/core/media/_base/providers/torrent/iptorrents.py +++ b/couchpotato/core/media/_base/providers/torrent/iptorrents.py @@ -63,7 +63,7 @@ class Base(TorrentProvider): pages = int(final_page_link.string) result_table = html.find('table', id="torrents") - log.debug('result_table: %s', result_table) + if not result_table or 'nothing found!' in data.lower(): return From ab25630f8e2cb4f0868ad808297e58142a9e6f5a Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 1 Apr 2019 16:07:44 +0200 Subject: [PATCH 23/35] Use python2 Since CouchPotato is not Python 3 compatible, this makes sure the correct Python version is used. Even when /usr/bin/python is Python 3. --- CouchPotato.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CouchPotato.py b/CouchPotato.py index b4a6421..d3492cf 100755 --- a/CouchPotato.py +++ b/CouchPotato.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 from __future__ import print_function from logging import handlers from os.path import dirname From 11acbfaaf6f180b959e3bd06bf8616eb7e0258ae Mon Sep 17 00:00:00 2001 From: gacopl Date: Sat, 1 Jun 2019 15:44:47 +0200 Subject: [PATCH 24/35] Fix updates/restarts when using systemd --- init/couchpotato.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init/couchpotato.service b/init/couchpotato.service index c9a0c47..c767c97 100644 --- a/init/couchpotato.service +++ b/init/couchpotato.service @@ -7,6 +7,8 @@ ExecStart=/var/lib/CouchPotatoServer/CouchPotato.py Type=simple User=couchpotato Group=couchpotato +Restart=always +RestartSec=2s [Install] WantedBy=multi-user.target From decab5518019903194cab2e2b097c85a5aece498 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Mon, 12 Aug 2019 13:51:44 +1000 Subject: [PATCH 25/35] Update transfer.py TLSv1_2 --- libs/synchronousdeluge/transfer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/synchronousdeluge/transfer.py b/libs/synchronousdeluge/transfer.py index 472bb12..a0024c6 100644 --- a/libs/synchronousdeluge/transfer.py +++ b/libs/synchronousdeluge/transfer.py @@ -19,7 +19,7 @@ class DelugeTransfer(object): self.disconnect() self.sock = socket.create_connection(hostport) - self.conn = ssl.wrap_socket(self.sock, None, None, False, ssl.CERT_NONE, ssl.PROTOCOL_TLSv1) + self.conn = ssl.wrap_socket(self.sock, None, None, False, ssl.CERT_NONE, ssl.PROTOCOL_TLSv1_2) self.connected = True def disconnect(self): From 609267149ff5d2c67ac883f9543a0740cebdd255 Mon Sep 17 00:00:00 2001 From: swordfish6975 Date: Mon, 12 Aug 2019 14:04:29 +1000 Subject: [PATCH 26/35] Update deluge.py these checks dont play nice with docker --- couchpotato/core/downloaders/deluge.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/downloaders/deluge.py b/couchpotato/core/downloaders/deluge.py index aaca40e..788891b 100644 --- a/couchpotato/core/downloaders/deluge.py +++ b/couchpotato/core/downloaders/deluge.py @@ -80,17 +80,17 @@ class Deluge(DownloaderBase): } if self.conf('directory'): - if os.path.isdir(self.conf('directory')): + #if os.path.isdir(self.conf('directory')): options['download_location'] = self.conf('directory') - else: - log.error('Download directory from Deluge settings: %s doesn\'t exist', self.conf('directory')) + #else: + # log.error('Download directory from Deluge settings: %s doesn\'t exist', self.conf('directory')) if self.conf('completed_directory'): - if os.path.isdir(self.conf('completed_directory')): + #if os.path.isdir(self.conf('completed_directory')): options['move_completed'] = 1 options['move_completed_path'] = self.conf('completed_directory') - else: - log.error('Download directory from Deluge settings: %s doesn\'t exist', self.conf('directory')) + #else: + # log.error('Download directory from Deluge settings: %s doesn\'t exist', self.conf('directory')) if data.get('seed_ratio'): options['stop_at_ratio'] = 1 From 7767d686011645bec593c42178a239282b490ae5 Mon Sep 17 00:00:00 2001 From: Marijn Date: Mon, 13 Jan 2020 17:58:06 +0000 Subject: [PATCH 27/35] delugev2 support --- couchpotato/core/downloaders/deluge.py | 9 +- libs/deluge_client/client.py | 275 +++++++++++++++++++ libs/deluge_client/rencode.py | 474 +++++++++++++++++++++++++++++++++ libs/deluge_client/tests.py | 65 +++++ 4 files changed, 819 insertions(+), 4 deletions(-) create mode 100644 libs/deluge_client/client.py create mode 100644 libs/deluge_client/rencode.py create mode 100644 libs/deluge_client/tests.py diff --git a/couchpotato/core/downloaders/deluge.py b/couchpotato/core/downloaders/deluge.py index 788891b..54500ea 100644 --- a/couchpotato/core/downloaders/deluge.py +++ b/couchpotato/core/downloaders/deluge.py @@ -10,8 +10,7 @@ from couchpotato.core._base.downloader.main import DownloaderBase, ReleaseDownlo from couchpotato.core.helpers.encoding import isInt, sp from couchpotato.core.helpers.variable import tryFloat, cleanHost from couchpotato.core.logger import CPLog -from synchronousdeluge import DelugeClient - +from deluge_client.client import DelugeRPCClient log = CPLog(__name__) @@ -221,8 +220,10 @@ class DelugeRPC(object): self.password = password def connect(self): - self.client = DelugeClient() - self.client.connect(self.host, int(self.port), self.username, self.password) + #self.client = DelugeClient() + #self.client.connect(self.host, int(self.port), self.username, self.password) + self.client = DelugeRPCClient(self.host, int(self.port), self.username, self.password) + self.client.connect() def test(self): try: diff --git a/libs/deluge_client/client.py b/libs/deluge_client/client.py new file mode 100644 index 0000000..827fcd7 --- /dev/null +++ b/libs/deluge_client/client.py @@ -0,0 +1,275 @@ +import logging +import socket +import ssl +import struct +import warnings +import zlib + +from .rencode import dumps, loads + +RPC_RESPONSE = 1 +RPC_ERROR = 2 +RPC_EVENT = 3 + +MESSAGE_HEADER_SIZE = 5 +READ_SIZE = 10 + +logger = logging.getLogger(__name__) + + +class DelugeClientException(Exception): + """Base exception for all deluge client exceptions""" + + +class ConnectionLostException(DelugeClientException): + pass + + +class CallTimeoutException(DelugeClientException): + pass + + +class InvalidHeaderException(DelugeClientException): + pass + + +class FailedToReconnectException(DelugeClientException): + pass + + +class RemoteException(DelugeClientException): + pass + + +class DelugeRPCClient(object): + timeout = 20 + + def __init__(self, host, port, username, password, decode_utf8=False, automatic_reconnect=True): + self.host = host + self.port = port + self.username = username + self.password = password + self.deluge_version = None + # This is only applicable if deluge_version is 2 + self.deluge_protocol_version = None + + self.decode_utf8 = decode_utf8 + if not self.decode_utf8: + warnings.warn('Using `decode_utf8=False` is deprecated, please set it to True.' + 'The argument will be removed in a future release where it will be always True', DeprecationWarning) + + self.automatic_reconnect = automatic_reconnect + + self.request_id = 1 + self.connected = False + self._create_socket() + + def _create_socket(self, ssl_version=None): + if ssl_version is not None: + self._socket = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM), ssl_version=ssl_version) + else: + self._socket = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) + self._socket.settimeout(self.timeout) + + def connect(self): + """ + Connects to the Deluge instance + """ + self._connect() + logger.debug('Connected to Deluge, detecting daemon version') + self._detect_deluge_version() + logger.debug('Daemon version {} detected, logging in'.format(self.deluge_version)) + if self.deluge_version == 2: + result = self.call('daemon.login', self.username, self.password, client_version='deluge-client') + else: + result = self.call('daemon.login', self.username, self.password) + logger.debug('Logged in with value %r' % result) + self.connected = True + + def _connect(self): + logger.info('Connecting to %s:%s' % (self.host, self.port)) + try: + self._socket.connect((self.host, self.port)) + except ssl.SSLError as e: + # Note: have not verified that we actually get errno 258 for this error + if (hasattr(ssl, 'PROTOCOL_SSLv3') and + (getattr(e, 'reason', None) == 'UNSUPPORTED_PROTOCOL' or e.errno == 258)): + logger.warning('Was unable to ssl handshake, trying to force SSLv3 (insecure)') + self._create_socket(ssl_version=ssl.PROTOCOL_SSLv3) + self._socket.connect((self.host, self.port)) + else: + raise + + def disconnect(self): + """ + Disconnect from deluge + """ + if self.connected: + self._socket.close() + self._socket = None + self.connected = False + + def _detect_deluge_version(self): + if self.deluge_version is not None: + return + + self._send_call(1, None, 'daemon.info') + self._send_call(2, None, 'daemon.info') + self._send_call(2, 1, 'daemon.info') + result = self._socket.recv(1) + if result[:1] == b'D': + # This is a protocol deluge 2.0 was using before release + self.deluge_version = 2 + self.deluge_protocol_version = None + # If we need the specific version of deluge 2, this is it. + daemon_version = self._receive_response(2, None, partial_data=result) + elif ord(result[:1]) == 1: + self.deluge_version = 2 + self.deluge_protocol_version = 1 + # If we need the specific version of deluge 2, this is it. + daemon_version = self._receive_response(2, 1, partial_data=result) + else: + self.deluge_version = 1 + # Deluge 1 doesn't recover well from the bad request. Re-connect the socket. + self._socket.close() + self._create_socket() + self._connect() + + def _send_call(self, deluge_version, protocol_version, method, *args, **kwargs): + self.request_id += 1 + if method == 'daemon.login': + debug_args = list(args) + if len(debug_args) >= 2: + debug_args[1] = '