From 48db4c8b8efe585eff2de249cb1370e28a6a8cc2 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Sun, 29 Sep 2013 23:21:53 +1300 Subject: [PATCH 01/29] Updated rtorrent-python library --- libs/rtorrent/__init__.py | 6 ++---- libs/rtorrent/lib/torrentparser.py | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/rtorrent/__init__.py b/libs/rtorrent/__init__.py index d19c78b4..b6ff73a0 100755 --- a/libs/rtorrent/__init__.py +++ b/libs/rtorrent/__init__.py @@ -71,12 +71,10 @@ class RTorrent: def _verify_conn(self): # check for rpc methods that should be available - assert {"system.client_version", - "system.library_version"}.issubset(set(self._get_rpc_methods())),\ - "Required RPC methods not available." + assert "system.client_version" in self._get_rpc_methods(), "Required RPC method not available." + assert "system.library_version" in self._get_rpc_methods(), "Required RPC method not available." # minimum rTorrent version check - assert self._meets_version_requirement() is True,\ "Error: Minimum rTorrent version required is {0}".format( MIN_RTORRENT_VERSION_STR) diff --git a/libs/rtorrent/lib/torrentparser.py b/libs/rtorrent/lib/torrentparser.py index 19dd12aa..30170d32 100755 --- a/libs/rtorrent/lib/torrentparser.py +++ b/libs/rtorrent/lib/torrentparser.py @@ -90,9 +90,10 @@ class TorrentParser(): def _calc_info_hash(self): self.info_hash = None if "info" in self._torrent_decoded.keys(): - info_dict = self._torrent_decoded["info"] - self.info_hash = hashlib.sha1(bencode.encode( - info_dict)).hexdigest().upper() + info_encoded = bencode.encode(self._torrent_decoded["info"]) + + if info_encoded: + self.info_hash = hashlib.sha1(info_encoded).hexdigest().upper() return(self.info_hash) From 226835e3d0a8db3e5cd22183897cf41a3a092745 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Sun, 29 Sep 2013 23:32:03 +1300 Subject: [PATCH 02/29] Added a check to ensure a torrent has been loaded (and found). --- couchpotato/core/downloaders/rtorrent/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py index 161c671a..d655f5a6 100755 --- a/couchpotato/core/downloaders/rtorrent/main.py +++ b/couchpotato/core/downloaders/rtorrent/main.py @@ -116,6 +116,10 @@ class rTorrent(Downloader): # Send torrent to rTorrent torrent = self.rt.load_torrent(filedata) + if not torrent: + log.error('Unable to find the torrent, did it fail to load?') + return False + # Set label if self.conf('label'): torrent.set_custom(1, self.conf('label')) From 0b00f2d9e600109713038d9975e3322ef9d7ead3 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Mon, 30 Sep 2013 00:44:36 +1300 Subject: [PATCH 03/29] Fixed Plex notifications on latest PHT (protocol renamed to 'plex') --- couchpotato/core/notifications/plex/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/notifications/plex/main.py b/couchpotato/core/notifications/plex/main.py index 5558289d..19ca670d 100755 --- a/couchpotato/core/notifications/plex/main.py +++ b/couchpotato/core/notifications/plex/main.py @@ -52,7 +52,7 @@ class Plex(Notification): clients.remove(server.get('name').lower()) protocol = server.get('protocol', 'xbmchttp') - if protocol in ['xbmcjson', 'xbmchttp']: + if protocol in ['plex', 'xbmcjson', 'xbmchttp']: self.clients[server.get('name')] = { 'name': server.get('name'), 'address': server.get('address'), @@ -164,7 +164,7 @@ class Plex(Notification): } for name, client in self.clients.items(): - if client['protocol'] == 'xbmcjson': + if client['protocol'] in ['xbmcjson', 'plex']: total += 1 if self.sendJSON('GUI.ShowNotification', params, client): successful += 1 From cc4350b0f98736ebcf946f87ed1339948513ddac Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 29 Sep 2013 14:05:28 +0200 Subject: [PATCH 04/29] NZBGet missing in wizard. fix #2262 --- couchpotato/core/downloaders/nzbget/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/couchpotato/core/downloaders/nzbget/__init__.py b/couchpotato/core/downloaders/nzbget/__init__.py index 19483713..00763cfb 100644 --- a/couchpotato/core/downloaders/nzbget/__init__.py +++ b/couchpotato/core/downloaders/nzbget/__init__.py @@ -12,6 +12,7 @@ config = [{ 'name': 'nzbget', 'label': 'NZBGet', 'description': 'Use NZBGet to download NZBs.', + 'wizard': True, 'options': [ { 'name': 'enabled', From b128ef17c9a78c12756f05885649d5c9a076bf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Sun, 29 Sep 2013 15:32:23 +0200 Subject: [PATCH 05/29] Added directory option and an option to append label to directory path --- couchpotato/core/downloaders/rtorrent/__init__.py | 13 +++++++++++++ couchpotato/core/downloaders/rtorrent/main.py | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/downloaders/rtorrent/__init__.py b/couchpotato/core/downloaders/rtorrent/__init__.py index efc2234b..b04e6898 100755 --- a/couchpotato/core/downloaders/rtorrent/__init__.py +++ b/couchpotato/core/downloaders/rtorrent/__init__.py @@ -35,6 +35,11 @@ config = [{ 'name': 'label', 'description': 'Label to apply on added torrents.', }, + { + 'name': 'directory', + 'type': 'directory', + 'description': 'Directory where rtorrent should download the files too.', + }, { 'name': 'remove_complete', 'label': 'Remove torrent', @@ -43,6 +48,14 @@ config = [{ 'type': 'bool', 'description': 'Remove the torrent after it finishes seeding.', }, + { + 'name': 'append_label', + 'label': 'Append Label', + 'default': False, + 'advanced': True, + 'type': 'bool', + 'description': 'Append label to download location. Requires you to set the download location above.', + }, { 'name': 'delete_files', 'label': 'Remove files', diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py index 161c671a..c7cf03b9 100755 --- a/couchpotato/core/downloaders/rtorrent/main.py +++ b/couchpotato/core/downloaders/rtorrent/main.py @@ -7,7 +7,7 @@ from datetime import timedelta from hashlib import sha1 from rtorrent import RTorrent from rtorrent.err import MethodError -import shutil +import shutil, os log = CPLog(__name__) @@ -91,6 +91,7 @@ class rTorrent(Downloader): if self.conf('label'): torrent_params['label'] = self.conf('label') + if not filedata and data.get('protocol') == 'torrent': log.error('Failed sending torrent, no data') return False @@ -120,6 +121,11 @@ class rTorrent(Downloader): if self.conf('label'): torrent.set_custom(1, self.conf('label')) + if self.conf('directory') and self.conf('append_label'): + torrent.set_directory(os.path.join(self.conf('directory'), self.conf('label'))) + elif self.conf('directory') and not self.conf('append_label'): + torrent.set_directory(self.conf('directory')) + # Set Ratio Group torrent.set_visible(group_name) From 317a1f119b13ef47f3876e18314c6a78e6c149d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Sun, 29 Sep 2013 18:03:52 +0200 Subject: [PATCH 06/29] not needed --- couchpotato/core/downloaders/rtorrent/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py index c7cf03b9..ac11c7b4 100755 --- a/couchpotato/core/downloaders/rtorrent/main.py +++ b/couchpotato/core/downloaders/rtorrent/main.py @@ -123,7 +123,7 @@ class rTorrent(Downloader): if self.conf('directory') and self.conf('append_label'): torrent.set_directory(os.path.join(self.conf('directory'), self.conf('label'))) - elif self.conf('directory') and not self.conf('append_label'): + elif self.conf('directory'): torrent.set_directory(self.conf('directory')) # Set Ratio Group From f0f843f746feb3e7363cad8bcf3e16cb85c05ffc Mon Sep 17 00:00:00 2001 From: mano3m Date: Fri, 30 Aug 2013 12:15:28 +0200 Subject: [PATCH 07/29] Add release.update event Proof of concept commit. It updates the database and calls movie.update.id to refresh the entire movie in the frontend. It would be better to crease a static js file in the release folder and add release functionality there including updating one release only. --- .../media/movie/_base/static/movie.actions.js | 11 ----- couchpotato/core/plugins/release/main.py | 41 ++++++++++++++++--- couchpotato/core/plugins/renamer/main.py | 35 +++++----------- 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/couchpotato/core/media/movie/_base/static/movie.actions.js b/couchpotato/core/media/movie/_base/static/movie.actions.js index e9f6141f..542287fa 100644 --- a/couchpotato/core/media/movie/_base/static/movie.actions.js +++ b/couchpotato/core/media/movie/_base/static/movie.actions.js @@ -397,17 +397,6 @@ MA.Release = new Class({ 'data': { 'id': release.id }, - 'onComplete': function(){ - var el = release.el; - if(el && (el.hasClass('failed') || el.hasClass('ignored'))){ - el.removeClass('failed').removeClass('ignored'); - el.getElement('.release_status').set('text', 'available'); - } - else if(el) { - el.addClass('ignored'); - el.getElement('.release_status').set('text', 'ignored'); - } - } }) }, diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 46857adf..fe41d06e 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -10,12 +10,21 @@ from sqlalchemy.orm import joinedload_all from sqlalchemy.sql.expression import and_, or_ import os import traceback +import time log = CPLog(__name__) class Release(Plugin): + default_movie_dict = { + 'profile': {'types': {'quality': {}}}, + 'releases': {'status': {}, 'quality': {}, 'files':{}, 'info': {}}, + 'library': {'titles': {}, 'files':{}}, + 'files': {}, + 'status': {} + } + def __init__(self): addEvent('release.add', self.add) @@ -47,6 +56,7 @@ class Release(Plugin): addEvent('release.for_movie', self.forMovie) addEvent('release.delete', self.delete) addEvent('release.clean', self.clean) + addEvent('release.update', self.update_status) def add(self, group): @@ -159,8 +169,7 @@ class Release(Plugin): rel = db.query(Relea).filter_by(id = id).first() if rel: ignored_status, failed_status, available_status = fireEvent('status.get', ['ignored', 'failed', 'available'], single = True) - rel.status_id = available_status.get('id') if rel.status_id in [ignored_status.get('id'), failed_status.get('id')] else ignored_status.get('id') - db.commit() + self.update_status(id, available_status if rel.status_id in [ignored_status.get('id'), failed_status.get('id')] else ignored_status) return { 'success': True @@ -199,14 +208,12 @@ class Release(Plugin): if success: db.expunge_all() - rel = db.query(Relea).filter_by(id = id).first() # Get release again + rel = db.query(Relea).filter_by(id = id).first() # Get release again @RuudBurger why do we need to get it again?? if rel.status_id != done_status.get('id'): - rel.status_id = snatched_status.get('id') - db.commit() + fireEvent('release.update', id = id, status = snatched_status, single = True) fireEvent('notify.frontend', type = 'release.download', data = True, message = 'Successfully snatched "%s"' % item['name']) - return { 'success': success } @@ -241,3 +248,25 @@ class Release(Plugin): 'success': True } + def update_status(self, id = None, status = None): + + db = get_session() + + rel = db.query(Relea).filter_by(id = id).first() + if rel and status and rel.status_id != status.get('id'): + + item = {} + for info in rel.info: + item[info.identifier] = info.value + + #update status in Db + log.debug('Marking release %s as %s', (item['name'], status.get("label"))) + rel.status_id = status.get('id') + rel.last_edit = int(time.time()) + db.commit() + + #Notify frontend + fireEvent('notify.frontend', type = 'release.download', data = True, message = '"%s" updated to %s' % (item['name'], status.get("label"))) + + #Update all movie info as there is no release update function + fireEvent('notify.frontend', type = 'movie.update.%s' % rel.movie.id, data = rel.movie.to_dict(self.default_movie_dict)) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index ad7df1cf..6a070f01 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -395,14 +395,8 @@ class Renamer(Plugin): break elif release.status_id is snatched_status.get('id'): if release.quality.id is group['meta_data']['quality']['id']: - log.debug('Marking release as downloaded') - try: - release.status_id = downloaded_status.get('id') - release.last_edit = int(time.time()) - except Exception, e: - log.error('Failed marking release as finished: %s %s', (e, traceback.format_exc())) - - db.commit() + # Set the release to downloaded + fireEvent('release.update', id = release.id, status = downloaded_status, single = True) # Remove leftover files if not remove_leftovers: # Don't remove anything @@ -677,7 +671,6 @@ Remove it if you want it to be renamed (again, or at least let it try again) try: for rel in rels: rel_dict = rel.to_dict({'info': {}}) - movie_dict = fireEvent('movie.get', rel.movie_id, single = True) # check status @@ -712,26 +705,22 @@ Remove it if you want it to be renamed (again, or at least let it try again) # Remove the downloading tag self.untagDir(item['folder'], 'downloading') - rel.status_id = seeding_status.get('id') - rel.last_edit = int(time.time()) - db.commit() + # Set the release to seeding + fireEvent('release.update', id = rel.id, status = seeding_status, single = True) # Scan and set the torrent to paused if required item.update({'pause': True, 'scan': True, 'process_complete': False}) scan_items.append(item) else: - if rel.status_id != seeding_status.get('id'): - rel.status_id = seeding_status.get('id') - rel.last_edit = int(time.time()) - db.commit() + # Set the release to seeding + fireEvent('release.update', id = rel.id, status = seeding_status, single = True) #let it seed log.debug('%s is seeding with ratio: %s', (item['name'], item['seed_ratio'])) elif item['status'] == 'failed': fireEvent('download.remove_failed', item, single = True) - rel.status_id = failed_status.get('id') - rel.last_edit = int(time.time()) - db.commit() + # Set the release to failed + fireEvent('release.update', id = rel.id, status = failed_status, single = True) if self.conf('next_on_failed'): fireEvent('movie.searcher.try_next_release', movie_id = rel.movie_id) @@ -743,18 +732,14 @@ Remove it if you want it to be renamed (again, or at least let it try again) if rel.status_id == seeding_status.get('id'): if rel.movie.status_id == done_status.get('id'): # Set the release to done as the movie has already been renamed - rel.status_id = downloaded_status.get('id') - rel.last_edit = int(time.time()) - db.commit() + fireEvent('release.update', id = rel.id, status = downloaded_status, single = True) # Allow the downloader to clean-up item.update({'pause': False, 'scan': False, 'process_complete': True}) scan_items.append(item) else: # Set the release to snatched so that the renamer can process the release as if it was never seeding - rel.status_id = snatched_status.get('id') - rel.last_edit = int(time.time()) - db.commit() + fireEvent('release.update', id = rel.id, status = snatched_status, single = True) # Scan and Allow the downloader to clean-up item.update({'pause': False, 'scan': True, 'process_complete': True}) From 1bddadf3a4809ef72156517d6e645ce6cf0f09ea Mon Sep 17 00:00:00 2001 From: mano3m Date: Fri, 30 Aug 2013 13:16:15 +0200 Subject: [PATCH 08/29] clean-up searcher --- couchpotato/core/media/_base/searcher/main.py | 16 +++------------- couchpotato/core/plugins/release/main.py | 3 --- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/couchpotato/core/media/_base/searcher/main.py b/couchpotato/core/media/_base/searcher/main.py index f09be64b..662ed80f 100644 --- a/couchpotato/core/media/_base/searcher/main.py +++ b/couchpotato/core/media/_base/searcher/main.py @@ -60,7 +60,7 @@ class Searcher(SearcherBase): if downloader_enabled: - snatched_status = fireEvent('status.get', 'snatched', single = True) + snatched_status, done_status, active_status = fireEvent('status.get', ['snatched', 'done', 'active'], single = True) # Download movie to temp filedata = None @@ -79,9 +79,7 @@ class Searcher(SearcherBase): rls = db.query(Release).filter_by(identifier = md5(data['url'])).first() if rls: renamer_enabled = Env.setting('enabled', 'renamer') - - done_status = fireEvent('status.get', 'done', single = True) - rls.status_id = done_status.get('id') if not renamer_enabled else snatched_status.get('id') + fireEvent('release.update', id = rls.id, status = done_status if not renamer_enabled else snatched_status, single = True) # Save download-id info if returned if isinstance(download_result, dict): @@ -100,20 +98,12 @@ class Searcher(SearcherBase): # If renamer isn't used, mark movie done if not renamer_enabled: - active_status = fireEvent('status.get', 'active', single = True) - done_status = fireEvent('status.get', 'done', single = True) try: if movie['status_id'] == active_status.get('id'): for profile_type in movie['profile']['types']: if profile_type['quality_id'] == rls.quality.id and profile_type['finish']: - log.info('Renamer disabled, marking movie as finished: %s', log_movie) - - # Mark release done - rls.status_id = done_status.get('id') - rls.last_edit = int(time.time()) - db.commit() - # Mark movie done + log.info('Renamer disabled, marking movie as finished: %s', log_movie) mvie = db.query(Movie).filter_by(id = movie['id']).first() mvie.status_id = done_status.get('id') mvie.last_edit = int(time.time()) diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index fe41d06e..0466a19e 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -210,9 +210,6 @@ class Release(Plugin): db.expunge_all() rel = db.query(Relea).filter_by(id = id).first() # Get release again @RuudBurger why do we need to get it again?? - if rel.status_id != done_status.get('id'): - fireEvent('release.update', id = id, status = snatched_status, single = True) - fireEvent('notify.frontend', type = 'release.download', data = True, message = 'Successfully snatched "%s"' % item['name']) return { 'success': success From a2cb0ec8adbac5b7ae2802d51531c86d9064b960 Mon Sep 17 00:00:00 2001 From: mano3m Date: Sat, 31 Aug 2013 10:18:41 +0200 Subject: [PATCH 09/29] frontend release.update --- .../core/media/movie/_base/static/movie.actions.js | 10 +++++++++- couchpotato/core/plugins/release/main.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/media/movie/_base/static/movie.actions.js b/couchpotato/core/media/movie/_base/static/movie.actions.js index 542287fa..6dca1141 100644 --- a/couchpotato/core/media/movie/_base/static/movie.actions.js +++ b/couchpotato/core/media/movie/_base/static/movie.actions.js @@ -241,7 +241,6 @@ MA.Release = new Class({ } }) ).inject(self.release_container); - release['el'] = item; if(status.identifier == 'ignored' || status.identifier == 'failed' || status.identifier == 'snatched'){ @@ -251,6 +250,15 @@ MA.Release = new Class({ else if(!self.next_release && status.identifier == 'available'){ self.next_release = release; } + + App.addEvent('release.update.'+release.id, function(notification){ + var new_status=Status.get(notification.data); + release.el.className='item '+new_status.identifier; + var status_el=release.el.getElement('.release_status'); + status_el.className='release_status '+new_status.identifier; + status_el.set('text', new_status.identifier); + }); + }); if(self.last_release) diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 0466a19e..2c1e2f54 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -266,4 +266,4 @@ class Release(Plugin): fireEvent('notify.frontend', type = 'release.download', data = True, message = '"%s" updated to %s' % (item['name'], status.get("label"))) #Update all movie info as there is no release update function - fireEvent('notify.frontend', type = 'movie.update.%s' % rel.movie.id, data = rel.movie.to_dict(self.default_movie_dict)) + fireEvent('notify.frontend', type = 'release.update.%s' % rel.id, data = status.get('id')) From d11f9d26c007076443000162fc4235c14762123b Mon Sep 17 00:00:00 2001 From: mano3m Date: Sat, 31 Aug 2013 22:24:02 +0200 Subject: [PATCH 10/29] Add missing status --- .../core/media/movie/_base/static/movie.css | 1 + couchpotato/core/plugins/renamer/main.py | 26 ++++++++++++------- couchpotato/core/plugins/status/main.py | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/couchpotato/core/media/movie/_base/static/movie.css b/couchpotato/core/media/movie/_base/static/movie.css index 0200417c..0b3162e3 100644 --- a/couchpotato/core/media/movie/_base/static/movie.css +++ b/couchpotato/core/media/movie/_base/static/movie.css @@ -426,6 +426,7 @@ .movies .data .quality .available { background-color: #578bc3; } .movies .data .quality .failed { background-color: #a43d34; } + .movies .data .quality .missing { background-color: #a43d34; } .movies .data .quality .snatched { background-color: #a2a232; } .movies .data .quality .seeding { background-color: #0a6819; } .movies .data .quality .done { diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 6a070f01..344fe55f 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -650,12 +650,13 @@ Remove it if you want it to be renamed (again, or at least let it try again) self.checking_snatched = True - snatched_status, ignored_status, failed_status, done_status, seeding_status, downloaded_status = \ - fireEvent('status.get', ['snatched', 'ignored', 'failed', 'done', 'seeding', 'downloaded'], single = True) + snatched_status, ignored_status, failed_status, done_status, seeding_status, downloaded_status, missing_status = \ + fireEvent('status.get', ['snatched', 'ignored', 'failed', 'done', 'seeding', 'downloaded', 'missing'], single = True) db = get_session() rels = db.query(Release).filter_by(status_id = snatched_status.get('id')).all() rels.extend(db.query(Release).filter_by(status_id = seeding_status.get('id')).all()) + rels.extend(db.query(Release).filter_by(status_id = missing_status.get('id')).all()) scan_items = [] scan_required = False @@ -692,11 +693,16 @@ Remove it if you want it to be renamed (again, or at least let it try again) log.debug('Found %s: %s, time to go: %s', (item['name'], item['status'].upper(), timeleft)) if item['status'] == 'busy': + # Set the release to snatched if it was missing before + fireEvent('release.update', id = rel.id, status = snatched_status, single = True) + # Tag folder if it is in the 'from' folder and it will not be processed because it is still downloading if item['folder'] and self.conf('from') in item['folder']: self.tagDir(item['folder'], 'downloading') elif item['status'] == 'seeding': + # Set the release to seeding + fireEvent('release.update', id = rel.id, status = seeding_status, single = True) #If linking setting is enabled, process release if self.conf('file_action') != 'move' and not rel.movie.status_id == done_status.get('id') and self.statusInfoComplete(item): @@ -705,23 +711,19 @@ Remove it if you want it to be renamed (again, or at least let it try again) # Remove the downloading tag self.untagDir(item['folder'], 'downloading') - # Set the release to seeding - fireEvent('release.update', id = rel.id, status = seeding_status, single = True) - # Scan and set the torrent to paused if required item.update({'pause': True, 'scan': True, 'process_complete': False}) scan_items.append(item) else: - # Set the release to seeding - fireEvent('release.update', id = rel.id, status = seeding_status, single = True) - #let it seed log.debug('%s is seeding with ratio: %s', (item['name'], item['seed_ratio'])) + elif item['status'] == 'failed': - fireEvent('download.remove_failed', item, single = True) # Set the release to failed fireEvent('release.update', id = rel.id, status = failed_status, single = True) + fireEvent('download.remove_failed', item, single = True) + if self.conf('next_on_failed'): fireEvent('movie.searcher.try_next_release', movie_id = rel.movie_id) elif item['status'] == 'completed': @@ -746,6 +748,9 @@ Remove it if you want it to be renamed (again, or at least let it try again) scan_items.append(item) else: + # Set the release to snatched if it was missing before + fireEvent('release.update', id = rel.id, status = snatched_status, single = True) + # Remove the downloading tag self.untagDir(item['folder'], 'downloading') @@ -761,6 +766,9 @@ Remove it if you want it to be renamed (again, or at least let it try again) if not found: log.info('%s not found in downloaders', nzbname) + # Set the release to missing + fireEvent('release.update', id = rel.id, status = missing_status, single = True) + except: log.error('Failed checking for release in downloader: %s', traceback.format_exc()) diff --git a/couchpotato/core/plugins/status/main.py b/couchpotato/core/plugins/status/main.py index 7546c651..b3b37bdc 100644 --- a/couchpotato/core/plugins/status/main.py +++ b/couchpotato/core/plugins/status/main.py @@ -24,6 +24,7 @@ class StatusPlugin(Plugin): 'available': 'Available', 'suggest': 'Suggest', 'seeding': 'Seeding', + 'missing': 'Missing', } status_cached = {} From 0c6c172d6af56d083a52dc10d3c701cecda347fb Mon Sep 17 00:00:00 2001 From: mano3m Date: Sat, 31 Aug 2013 23:48:38 +0200 Subject: [PATCH 11/29] Update movie quality status colour and text It isnt perfect this way. I think we need to add a sepperate function to do this and call that from both when CPS is loading the page and when it updates a release (e.g. just rebuild the icons) --- .../core/media/movie/_base/static/movie.actions.js | 13 +++++++++++++ couchpotato/core/media/movie/_base/static/movie.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/media/movie/_base/static/movie.actions.js b/couchpotato/core/media/movie/_base/static/movie.actions.js index 6dca1141..2a979574 100644 --- a/couchpotato/core/media/movie/_base/static/movie.actions.js +++ b/couchpotato/core/media/movie/_base/static/movie.actions.js @@ -252,11 +252,24 @@ MA.Release = new Class({ } App.addEvent('release.update.'+release.id, function(notification){ + var q = self.movie.quality.getElement('.q_id'+ release.quality_id), + status = Status.get(release.status_id); + var new_status=Status.get(notification.data); + release.status_id = new_status.id release.el.className='item '+new_status.identifier; + var status_el=release.el.getElement('.release_status'); status_el.className='release_status '+new_status.identifier; status_el.set('text', new_status.identifier); + + if(!q && (new_status.identifier == 'snatched' || new_status.identifier == 'seeding' || new_status.identifier == 'done')) + var q = self.addQuality(release.quality_id); + + if (new_status && q && !q.hasClass(new_status.identifier)){ + q.removeClass(status.identifier).addClass(new_status.identifier); + q.set('title', q.get('title').replace(status.label, new_status.label)); + } }); }); diff --git a/couchpotato/core/media/movie/_base/static/movie.js b/couchpotato/core/media/movie/_base/static/movie.js index 6defc2ad..a865325b 100644 --- a/couchpotato/core/media/movie/_base/static/movie.js +++ b/couchpotato/core/media/movie/_base/static/movie.js @@ -185,7 +185,7 @@ var Movie = new Class({ var q = self.quality.getElement('.q_id'+ release.quality_id), status = Status.get(release.status_id); - if(!q && (status.identifier == 'snatched' || status.identifier == 'done')) + if(!q && (status.identifier == 'snatched' || status.identifier == 'seeding' || status.identifier == 'done')) var q = self.addQuality(release.quality_id) if (status && q && !q.hasClass(status.identifier)){ From 516447a1048470433e10efdb6ac657464f9d5f06 Mon Sep 17 00:00:00 2001 From: mano3m Date: Sun, 1 Sep 2013 00:30:11 +0200 Subject: [PATCH 12/29] Remove movie_dict --- couchpotato/core/plugins/release/main.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 2c1e2f54..97e350c5 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -17,14 +17,6 @@ log = CPLog(__name__) class Release(Plugin): - default_movie_dict = { - 'profile': {'types': {'quality': {}}}, - 'releases': {'status': {}, 'quality': {}, 'files':{}, 'info': {}}, - 'library': {'titles': {}, 'files':{}}, - 'files': {}, - 'status': {} - } - def __init__(self): addEvent('release.add', self.add) From 27fdbff619b6df5bee97544f8fed31bb389af1fd Mon Sep 17 00:00:00 2001 From: mano3m Date: Thu, 5 Sep 2013 18:49:19 +0200 Subject: [PATCH 13/29] Set missing to ignored after 1 week --- couchpotato/core/plugins/renamer/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 344fe55f..7e2fdbcc 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -766,8 +766,13 @@ Remove it if you want it to be renamed (again, or at least let it try again) if not found: log.info('%s not found in downloaders', nzbname) - # Set the release to missing - fireEvent('release.update', id = rel.id, status = missing_status, single = True) + #Check status if already missing and for how long, if > 1 week, set to ignored else to missing + if rel.status_id == missing_status.get('id'): + if rel.last_edit < int(time.time()) - 7*24*60*60: + fireEvent('release.update', id = rel.id, status = ignored_status, single = True) + else: + # Set the release to missing + fireEvent('release.update', id = rel.id, status = missing_status, single = True) except: log.error('Failed checking for release in downloader: %s', traceback.format_exc()) From 7c5616cc79ecb092a712eb8aa1d829013930b183 Mon Sep 17 00:00:00 2001 From: mano3m Date: Fri, 6 Sep 2013 23:03:12 +0200 Subject: [PATCH 14/29] fix colour order --- .../core/media/movie/_base/static/movie.css | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/couchpotato/core/media/movie/_base/static/movie.css b/couchpotato/core/media/movie/_base/static/movie.css index 0b3162e3..c72eb136 100644 --- a/couchpotato/core/media/movie/_base/static/movie.css +++ b/couchpotato/core/media/movie/_base/static/movie.css @@ -419,23 +419,25 @@ } .movies .data .quality .available, - .movies .data .quality .snatched { + .movies .data .quality .snatched, + .movies .data .quality .seeding { opacity: 1; cursor: pointer; } .movies .data .quality .available { background-color: #578bc3; } - .movies .data .quality .failed { background-color: #a43d34; } - .movies .data .quality .missing { background-color: #a43d34; } + .movies .data .quality .failed, + .movies .data .quality .missing, + .movies .data .quality .ignored { background-color: #a43d34; } .movies .data .quality .snatched { background-color: #a2a232; } - .movies .data .quality .seeding { background-color: #0a6819; } .movies .data .quality .done { background-color: #369545; opacity: 1; } + .movies .data .quality .seeding { background-color: #0a6819; } .movies .data .quality .finish { background-image: url('../images/sprite.png'); - background-repeat: no-repeat; + background-repeat: no-repeat; background-position: 0 2px; padding-left: 14px; background-size: 14px @@ -647,7 +649,7 @@ margin-top: 25px; } } - + .trailer_container.hide { height: 0 !important; } @@ -1030,7 +1032,7 @@ .movies .progress > div .folder { display: inline-block; padding: 5px 20px 5px 0; - white-space: nowrap; + white-space: nowrap; text-overflow: ellipsis; overflow: hidden; width: 85%; From 89daa836e75948f74e4725ea7e716dc243faaedd Mon Sep 17 00:00:00 2001 From: mano3m Date: Sun, 1 Sep 2013 01:05:53 +0200 Subject: [PATCH 15/29] Remove all empty folders Quite often there is a subfolder in the movie folder after extraction. This folder is deleted but the actual movie folder remains behind. This update fixes that in both cases: move_folder is known, or we work in the 'from' folder. --- couchpotato/core/plugins/renamer/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index ad7df1cf..be886d42 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -477,8 +477,15 @@ class Renamer(Plugin): if group['dirname'] and group['parentdir'] and not self.downloadIsTorrent(download_info): try: - log.info('Deleting folder: %s', group['parentdir']) - self.deleteEmptyFolder(group['parentdir']) + if movie_folder: + # Delete the movie folder + group_folder = movie_folder + else: + # Delete the first empty subfolder in the tree relative to the 'from' folder + group_folder = os.path.join(self.conf('from'), os.path.relpath(group['parentdir'], self.conf('from')).split(os.path.sep)[0]) + + log.info('Deleting folder: %s', group_folder) + self.deleteEmptyFolder(group_folder) except: log.error('Failed removing %s: %s', (group['parentdir'], traceback.format_exc())) From 6174f121c869a726fbaabd900aceb285b162f8bd Mon Sep 17 00:00:00 2001 From: mano3m Date: Mon, 30 Sep 2013 19:27:11 +0200 Subject: [PATCH 16/29] fix log message --- couchpotato/core/plugins/renamer/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index be886d42..ea7926eb 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -476,18 +476,18 @@ class Renamer(Plugin): log.error('Failed removing %s: %s', (release.identifier, traceback.format_exc())) if group['dirname'] and group['parentdir'] and not self.downloadIsTorrent(download_info): + if movie_folder: + # Delete the movie folder + group_folder = movie_folder + else: + # Delete the first empty subfolder in the tree relative to the 'from' folder + group_folder = os.path.join(self.conf('from'), os.path.relpath(group['parentdir'], self.conf('from')).split(os.path.sep)[0]) + try: - if movie_folder: - # Delete the movie folder - group_folder = movie_folder - else: - # Delete the first empty subfolder in the tree relative to the 'from' folder - group_folder = os.path.join(self.conf('from'), os.path.relpath(group['parentdir'], self.conf('from')).split(os.path.sep)[0]) - log.info('Deleting folder: %s', group_folder) self.deleteEmptyFolder(group_folder) except: - log.error('Failed removing %s: %s', (group['parentdir'], traceback.format_exc())) + log.error('Failed removing %s: %s', (group_folder, traceback.format_exc())) # Notify on download, search for trailers etc download_message = 'Downloaded %s (%s)' % (movie_title, replacements['quality']) From 6bda5f5b0373fb699db072630fd38bfa66782160 Mon Sep 17 00:00:00 2001 From: mano3m Date: Mon, 30 Sep 2013 19:33:53 +0200 Subject: [PATCH 17/29] Don't use movie done status to check seeding Fixes #2278 --- couchpotato/core/plugins/renamer/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index ad7df1cf..202bf439 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -706,7 +706,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) elif item['status'] == 'seeding': #If linking setting is enabled, process release - if self.conf('file_action') != 'move' and not rel.movie.status_id == done_status.get('id') and self.statusInfoComplete(item): + if self.conf('file_action') != 'move' and not rel.status_id == seeding_status.get('id') and self.statusInfoComplete(item): log.info('Download of %s completed! It is now being processed while leaving the original files alone for seeding. Current ratio: %s.', (item['name'], item['seed_ratio'])) # Remove the downloading tag From fd8e50b53383593c90a7be8b65ced038972a5019 Mon Sep 17 00:00:00 2001 From: mano3m Date: Sat, 28 Sep 2013 13:10:54 +0200 Subject: [PATCH 18/29] [SabNZBd] Consider encrypted as failed --- couchpotato/core/downloaders/sabnzbd/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py index 08ee409c..41f9f709 100644 --- a/couchpotato/core/downloaders/sabnzbd/main.py +++ b/couchpotato/core/downloaders/sabnzbd/main.py @@ -90,9 +90,14 @@ class Sabnzbd(Downloader): # Get busy releases for item in queue.get('slots', []): + status = 'busy' + if 'ENCRYPTED / ' in item['filename']: + status = 'failed' + statuses.append({ 'id': item['nzo_id'], 'name': item['filename'], + 'status': status, 'original_status': item['status'], 'timeleft': item['timeleft'] if not queue['paused'] else -1, }) @@ -122,6 +127,12 @@ class Sabnzbd(Downloader): log.info('%s failed downloading, deleting...', item['name']) try: + self.call({ + 'mode': 'queue', + 'name': 'delete', + 'del_files': '1', + 'value': item['id'] + }, use_json = False) self.call({ 'mode': 'history', 'name': 'delete', From 0876d1ff8e6f88e5eb40f656ba4e7b863d58b186 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 30 Sep 2013 20:52:04 +0200 Subject: [PATCH 19/29] Rename release.update to update_status --- couchpotato/core/media/_base/searcher/main.py | 2 +- .../media/movie/_base/static/movie.actions.js | 36 ++++++++++--------- couchpotato/core/plugins/release/main.py | 12 +++---- couchpotato/core/plugins/renamer/main.py | 20 +++++------ 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/couchpotato/core/media/_base/searcher/main.py b/couchpotato/core/media/_base/searcher/main.py index 662ed80f..934a1472 100644 --- a/couchpotato/core/media/_base/searcher/main.py +++ b/couchpotato/core/media/_base/searcher/main.py @@ -79,7 +79,7 @@ class Searcher(SearcherBase): rls = db.query(Release).filter_by(identifier = md5(data['url'])).first() if rls: renamer_enabled = Env.setting('enabled', 'renamer') - fireEvent('release.update', id = rls.id, status = done_status if not renamer_enabled else snatched_status, single = True) + fireEvent('release.update_status', rls.id, status = done_status if not renamer_enabled else snatched_status, single = True) # Save download-id info if returned if isinstance(download_result, dict): diff --git a/couchpotato/core/media/movie/_base/static/movie.actions.js b/couchpotato/core/media/movie/_base/static/movie.actions.js index 2a979574..9dd6bdfe 100644 --- a/couchpotato/core/media/movie/_base/static/movie.actions.js +++ b/couchpotato/core/media/movie/_base/static/movie.actions.js @@ -250,27 +250,29 @@ MA.Release = new Class({ else if(!self.next_release && status.identifier == 'available'){ self.next_release = release; } + + var update_handle = function(notification) { + var q = self.movie.quality.getElement('.q_id' + release.quality_id), + status = Status.get(release.status_id), + new_status = Status.get(notification.data); + + release.status_id = new_status.id + release.el.set('class', 'item ' + new_status.identifier); - App.addEvent('release.update.'+release.id, function(notification){ - var q = self.movie.quality.getElement('.q_id'+ release.quality_id), - status = Status.get(release.status_id); + var status_el = release.el.getElement('.release_status'); + status_el.set('class', 'release_status ' + new_status.identifier); + status_el.set('text', new_status.identifier); - var new_status=Status.get(notification.data); - release.status_id = new_status.id - release.el.className='item '+new_status.identifier; + if(!q && (new_status.identifier == 'snatched' || new_status.identifier == 'seeding' || new_status.identifier == 'done')) + var q = self.addQuality(release.quality_id); - var status_el=release.el.getElement('.release_status'); - status_el.className='release_status '+new_status.identifier; - status_el.set('text', new_status.identifier); + if(new_status && q && !q.hasClass(new_status.identifier)) { + q.removeClass(status.identifier).addClass(new_status.identifier); + q.set('title', q.get('title').replace(status.label, new_status.label)); + } + } - if(!q && (new_status.identifier == 'snatched' || new_status.identifier == 'seeding' || new_status.identifier == 'done')) - var q = self.addQuality(release.quality_id); - - if (new_status && q && !q.hasClass(new_status.identifier)){ - q.removeClass(status.identifier).addClass(new_status.identifier); - q.set('title', q.get('title').replace(status.label, new_status.label)); - } - }); + App.addEvent('release.update_status.' + release.id, update_handle); }); diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 97e350c5..e8d1815f 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -48,7 +48,7 @@ class Release(Plugin): addEvent('release.for_movie', self.forMovie) addEvent('release.delete', self.delete) addEvent('release.clean', self.clean) - addEvent('release.update', self.update_status) + addEvent('release.update_status', self.updateStatus) def add(self, group): @@ -161,7 +161,7 @@ class Release(Plugin): rel = db.query(Relea).filter_by(id = id).first() if rel: ignored_status, failed_status, available_status = fireEvent('status.get', ['ignored', 'failed', 'available'], single = True) - self.update_status(id, available_status if rel.status_id in [ignored_status.get('id'), failed_status.get('id')] else ignored_status) + self.updateStatus(id, available_status if rel.status_id in [ignored_status.get('id'), failed_status.get('id')] else ignored_status) return { 'success': True @@ -237,7 +237,8 @@ class Release(Plugin): 'success': True } - def update_status(self, id = None, status = None): + def updateStatus(self, id, status = None): + if not status: return db = get_session() @@ -254,8 +255,5 @@ class Release(Plugin): rel.last_edit = int(time.time()) db.commit() - #Notify frontend - fireEvent('notify.frontend', type = 'release.download', data = True, message = '"%s" updated to %s' % (item['name'], status.get("label"))) - #Update all movie info as there is no release update function - fireEvent('notify.frontend', type = 'release.update.%s' % rel.id, data = status.get('id')) + fireEvent('notify.frontend', type = 'release.update_status.%s' % rel.id, data = status.get('id')) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index b0df89dd..c2b71361 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -396,7 +396,7 @@ class Renamer(Plugin): elif release.status_id is snatched_status.get('id'): if release.quality.id is group['meta_data']['quality']['id']: # Set the release to downloaded - fireEvent('release.update', id = release.id, status = downloaded_status, single = True) + fireEvent('release.update_status', release.id, status = downloaded_status, single = True) # Remove leftover files if not remove_leftovers: # Don't remove anything @@ -701,7 +701,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) if item['status'] == 'busy': # Set the release to snatched if it was missing before - fireEvent('release.update', id = rel.id, status = snatched_status, single = True) + fireEvent('release.update_status', rel.id, status = snatched_status, single = True) # Tag folder if it is in the 'from' folder and it will not be processed because it is still downloading if item['folder'] and self.conf('from') in item['folder']: @@ -709,7 +709,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) elif item['status'] == 'seeding': # Set the release to seeding - fireEvent('release.update', id = rel.id, status = seeding_status, single = True) + fireEvent('release.update_status', rel.id, status = seeding_status, single = True) #If linking setting is enabled, process release if self.conf('file_action') != 'move' and not rel.status_id == seeding_status.get('id') and self.statusInfoComplete(item): @@ -727,7 +727,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) elif item['status'] == 'failed': # Set the release to failed - fireEvent('release.update', id = rel.id, status = failed_status, single = True) + fireEvent('release.update_status', rel.id, status = failed_status, single = True) fireEvent('download.remove_failed', item, single = True) @@ -741,14 +741,14 @@ Remove it if you want it to be renamed (again, or at least let it try again) if rel.status_id == seeding_status.get('id'): if rel.movie.status_id == done_status.get('id'): # Set the release to done as the movie has already been renamed - fireEvent('release.update', id = rel.id, status = downloaded_status, single = True) + fireEvent('release.update_status', rel.id, status = downloaded_status, single = True) # Allow the downloader to clean-up item.update({'pause': False, 'scan': False, 'process_complete': True}) scan_items.append(item) else: # Set the release to snatched so that the renamer can process the release as if it was never seeding - fireEvent('release.update', id = rel.id, status = snatched_status, single = True) + fireEvent('release.update_status', rel.id, status = snatched_status, single = True) # Scan and Allow the downloader to clean-up item.update({'pause': False, 'scan': True, 'process_complete': True}) @@ -756,7 +756,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) else: # Set the release to snatched if it was missing before - fireEvent('release.update', id = rel.id, status = snatched_status, single = True) + fireEvent('release.update_status', rel.id, status = snatched_status, single = True) # Remove the downloading tag self.untagDir(item['folder'], 'downloading') @@ -775,11 +775,11 @@ Remove it if you want it to be renamed (again, or at least let it try again) #Check status if already missing and for how long, if > 1 week, set to ignored else to missing if rel.status_id == missing_status.get('id'): - if rel.last_edit < int(time.time()) - 7*24*60*60: - fireEvent('release.update', id = rel.id, status = ignored_status, single = True) + if rel.last_edit < int(time.time()) - 7 * 24 * 60 * 60: + fireEvent('release.update_status', rel.id, status = ignored_status, single = True) else: # Set the release to missing - fireEvent('release.update', id = rel.id, status = missing_status, single = True) + fireEvent('release.update_status', rel.id, status = missing_status, single = True) except: log.error('Failed checking for release in downloader: %s', traceback.format_exc()) From f121db059e4dfc6cc074af5b2a4045f038963283 Mon Sep 17 00:00:00 2001 From: salfab Date: Sat, 28 Sep 2013 22:22:41 +0200 Subject: [PATCH 20/29] add new provider for ILT. --- .../torrent/ilovetorrents/__init__.py | 52 +++++++ .../providers/torrent/ilovetorrents/main.py | 147 ++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 couchpotato/core/providers/torrent/ilovetorrents/__init__.py create mode 100644 couchpotato/core/providers/torrent/ilovetorrents/main.py diff --git a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py new file mode 100644 index 00000000..8cd86d35 --- /dev/null +++ b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py @@ -0,0 +1,52 @@ +from main import ILoveTorrents + +def start(): + return ILoveTorrents() + +config = [{ + 'name': 'ilovetorrents', + 'groups': [ + { + 'tab': 'searcher', + 'list': 'torrent_providers', + 'name': 'ILoveTorrents', + 'description': 'Where the Love of Torrents is Born', + 'wizard': True, + 'options': [ + { + 'name': 'enabled', + 'type': 'enabler', + 'default': True + }, + { + 'name': 'domain', + 'advanced': True, + 'label': 'Proxy server', + 'description': 'Domain for requests, keep empty to let CouchPotato pick.', + }, + { + 'name': 'seed_ratio', + 'label': 'Seed ratio', + 'type': 'float', + 'default': 1, + 'description': 'Will not be (re)moved until this seed ratio is met.', + }, + { + 'name': 'seed_time', + 'label': 'Seed time', + 'type': 'int', + 'default': 40, + 'description': 'Will not be (re)moved until this seed time (in hours) is met.', + }, + { + 'name': 'extra_score', + 'advanced': True, + 'label': 'Extra Score', + 'type': 'int', + 'default': 0, + 'description': 'Starting score for each release found via this provider.', + } + ], + } + ] +}] diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py new file mode 100644 index 00000000..5659b6a8 --- /dev/null +++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py @@ -0,0 +1,147 @@ +from bs4 import BeautifulSoup +from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode +from couchpotato.core.helpers.variable import tryInt, cleanHost +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.torrent.base import TorrentMagnetProvider +from couchpotato.environment import Env +import re +import time +import traceback + +log = CPLog(__name__) + + +class ILoveTorrents(TorrentMagnetProvider): + + urls = { + 'detail': '%s/torrent/%s', + 'search': '%s/browse.php?search=%s&page=%s&cat=%s' + } + + cat_ids = [ + (["41"], ['720p', '1080p', 'brrip']), + (["19"], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']), + (["20"], ['dvdr']) + ] + + cat_backup_id = 200 + disable_provider = False + http_time_between_calls = 0 + + proxy_list = [ + 'http://www.ilovetorrents.me', + ] + + def __init__(self): + self.domain = self.conf('domain') + super(ILoveTorrents, self).__init__() + + def _searchOnTitle(self, title, movie, quality, results): + + page = 0 + total_pages = 1 + cats = self.getCatId(quality['identifier']) + + while page < total_pages: + + search_url = self.urls['search'] % (self.getDomain(), tryUrlencode('"%s" %s' % (title, movie['library']['year'])), page, cats[0])) + page += 1 + + data = self.getHTMLData(search_url) + + if data: + try: + soup = BeautifulSoup(data, "html5lib") + + results_table = soup.find('table', attrs = {'class': 'koptekst'}) + + if not results_table: + return + + try: + pagelinks = soup.findAll(href=re.compile("page")) + pageNumbers = [int(re.search('page=(?P.+'')', i["href"]).group('pageNumber')) for i in pagelinks] + total_pages = max(pageNumbers) + + except: + pass + + entries = results_table.find_all('tr') + + for result in entries[1:]: + link = result.find(href = re.compile('details.php'))['href'] + download = result.find('a', href = re.compile('download.php'))['href'] + + try: + matches = re.search('>(?P.+)
(?P.B)', unicode(result.select('td.rowhead')[5])) + size = matches.group('size') + " " + matches.group('unit') + + except: + continue + + if link and download: + + def extra_score(item): + trusted = (0, 10)[result.find('img', alt = re.compile('Trusted')) is not None] + vip = (0, 20)[result.find('img', alt = re.compile('VIP')) is not None] + confirmed = (0, 30)[result.find('img', alt = re.compile('Helpers')) is not None] + moderated = (0, 50)[result.find('img', alt = re.compile('Moderator')) is not None] + + return confirmed + trusted + vip + moderated + + results.append({ + 'id': re.search('/(?P\d+)/', link['href']).group('id'), + 'name': link.string, + 'url': download['href'], + 'detail_url': self.getDomain(link['href']), + 'size': self.parseSize(size), + 'seeders': tryInt(result.find_all('td')[2].string), + 'leechers': tryInt(result.find_all('td')[3].string), + 'extra_score': extra_score, + 'get_more_info': self.getMoreInfo + }) + + except: + log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) + + + def isEnabled(self): + return super(ILoveTorrents, self).isEnabled() and self.getDomain() + + def getDomain(self, url = ''): + + if not self.domain: + for proxy in self.proxy_list: + + prop_name = 'tpb_proxy.%s' % proxy + last_check = float(Env.prop(prop_name, default = 0)) + if last_check > time.time() - 1209600: + continue + + data = '' + try: + data = self.urlopen(proxy, timeout = 3, show_error = False) + except: + log.debug('Failed tpb proxy %s', proxy) + + if 'title="Pirate Search"' in data: + log.debug('Using proxy: %s', proxy) + self.domain = proxy + break + + Env.prop(prop_name, time.time()) + + if not self.domain: + log.error('No ILT proxies left, please add one in settings, or let us know which one to add on the forum.') + return None + + return cleanHost(self.domain).rstrip('/') + url + + def getMoreInfo(self, item): + full_description = self.getCache('tpb.%s' % item['id'], item['detail_url'], cache_timeout = 25920000) + html = BeautifulSoup(full_description) + nfo_pre = html.find('div', attrs = {'class':'nfo'}) + description = toUnicode(nfo_pre.text) if nfo_pre else '' + + item['description'] = description + return item From 87754047fa13ad2c103f568a7b17cdb0b8a9b4cf Mon Sep 17 00:00:00 2001 From: salfab Date: Sun, 29 Sep 2013 12:44:53 +0200 Subject: [PATCH 21/29] torrents are found and appended to the results argument --- .../torrent/ilovetorrents/__init__.py | 18 +++- .../providers/torrent/ilovetorrents/main.py | 100 ++++++++---------- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py index 8cd86d35..84776e72 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py @@ -18,11 +18,19 @@ config = [{ 'type': 'enabler', 'default': True }, - { - 'name': 'domain', - 'advanced': True, - 'label': 'Proxy server', - 'description': 'Domain for requests, keep empty to let CouchPotato pick.', + { + 'name': 'username', + 'label': 'Username', + 'type': 'string', + 'default': '', + 'description': 'The user name for your ILT account', + }, + { + 'name': 'password', + 'label': 'Password', + 'type': 'password', + 'default': '', + 'description': 'The password for your ILT account.', }, { 'name': 'seed_ratio', diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py index 5659b6a8..755af526 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/main.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py @@ -14,8 +14,13 @@ log = CPLog(__name__) class ILoveTorrents(TorrentMagnetProvider): urls = { - 'detail': '%s/torrent/%s', - 'search': '%s/browse.php?search=%s&page=%s&cat=%s' + 'domain': 'www.ilovetorrents.me', + 'download': 'http://www.ilovetorrents.me/%s', + 'detail': '%s/torrent/%s', + 'search': '%s/browse.php?search=%s&page=%s&cat=%s', + 'test' : 'http://www.ilovetorrents.me/', + 'login' : 'http://www.ilovetorrents.me/takelogin.php', + 'login_check' : 'http://www.ilovetorrents.me' } cat_ids = [ @@ -28,12 +33,8 @@ class ILoveTorrents(TorrentMagnetProvider): disable_provider = False http_time_between_calls = 0 - proxy_list = [ - 'http://www.ilovetorrents.me', - ] - def __init__(self): - self.domain = self.conf('domain') + self.domain = self.urls['domain'] super(ILoveTorrents, self).__init__() def _searchOnTitle(self, title, movie, quality, results): @@ -43,31 +44,30 @@ class ILoveTorrents(TorrentMagnetProvider): cats = self.getCatId(quality['identifier']) while page < total_pages: - - search_url = self.urls['search'] % (self.getDomain(), tryUrlencode('"%s" %s' % (title, movie['library']['year'])), page, cats[0])) + + movieTitle = tryUrlencode('"%s" %s' % (title, movie['library']['year'])) + search_url = self.urls['search'] % (self.getDomain(), movieTitle, page, cats[0]) page += 1 - - data = self.getHTMLData(search_url) - + + data = self.getHTMLData(search_url, opener = self.login_opener) if data: try: soup = BeautifulSoup(data, "html5lib") results_table = soup.find('table', attrs = {'class': 'koptekst'}) - if not results_table: return - + try: - pagelinks = soup.findAll(href=re.compile("page")) + pagelinks = soup.findAll(href=re.compile("page")) pageNumbers = [int(re.search('page=(?P.+'')', i["href"]).group('pageNumber')) for i in pagelinks] total_pages = max(pageNumbers) - + except: pass entries = results_table.find_all('tr') - + for result in entries[1:]: link = result.find(href = re.compile('details.php'))['href'] download = result.find('a', href = re.compile('download.php'))['href'] @@ -80,68 +80,58 @@ class ILoveTorrents(TorrentMagnetProvider): continue if link and download: - def extra_score(item): trusted = (0, 10)[result.find('img', alt = re.compile('Trusted')) is not None] vip = (0, 20)[result.find('img', alt = re.compile('VIP')) is not None] confirmed = (0, 30)[result.find('img', alt = re.compile('Helpers')) is not None] moderated = (0, 50)[result.find('img', alt = re.compile('Moderator')) is not None] - return confirmed + trusted + vip + moderated - + return confirmed + trusted + vip + moderated + id = re.search('id=(?P\d+)&', link).group('id') + url = self.urls['download'] % (download) + + detail_url = self.getDomain("/"+link) + fileSize = self.parseSize(size) results.append({ - 'id': re.search('/(?P\d+)/', link['href']).group('id'), - 'name': link.string, - 'url': download['href'], - 'detail_url': self.getDomain(link['href']), - 'size': self.parseSize(size), + 'id': id, + 'name': link, + 'url': url, + 'detail_url': detail_url, + 'size': fileSize, 'seeders': tryInt(result.find_all('td')[2].string), 'leechers': tryInt(result.find_all('td')[3].string), - 'extra_score': extra_score, - 'get_more_info': self.getMoreInfo + 'extra_score': extra_score, + 'get_more_info': self.getMoreInfo }) + log.info(results) except: log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) + def getLoginParams(self): + return tryUrlencode({ + 'username': self.conf('username'), + 'password': self.conf('password'), + 'submit': 'Welcome to ILT', + }) def isEnabled(self): return super(ILoveTorrents, self).isEnabled() and self.getDomain() - def getDomain(self, url = ''): - - if not self.domain: - for proxy in self.proxy_list: - - prop_name = 'tpb_proxy.%s' % proxy - last_check = float(Env.prop(prop_name, default = 0)) - if last_check > time.time() - 1209600: - continue - - data = '' - try: - data = self.urlopen(proxy, timeout = 3, show_error = False) - except: - log.debug('Failed tpb proxy %s', proxy) - - if 'title="Pirate Search"' in data: - log.debug('Using proxy: %s', proxy) - self.domain = proxy - break - - Env.prop(prop_name, time.time()) - - if not self.domain: - log.error('No ILT proxies left, please add one in settings, or let us know which one to add on the forum.') - return None - + def getDomain(self, url = ''): return cleanHost(self.domain).rstrip('/') + url def getMoreInfo(self, item): - full_description = self.getCache('tpb.%s' % item['id'], item['detail_url'], cache_timeout = 25920000) + log.info('Getting more info') + full_description = self.getCache('ilt.%s' % item['id'], item['detail_url'], cache_timeout = 25920000) html = BeautifulSoup(full_description) nfo_pre = html.find('div', attrs = {'class':'nfo'}) description = toUnicode(nfo_pre.text) if nfo_pre else '' item['description'] = description return item + + def loginSuccess(self, output): + return 'logout.php' in output.lower() + + loginCheckSuccess = loginSuccess From 75360f734c85afbc0b9f0d18cc502482a8fd5ad3 Mon Sep 17 00:00:00 2001 From: salfab Date: Sun, 29 Sep 2013 14:12:52 +0200 Subject: [PATCH 22/29] use a proper name, instead of the link --- couchpotato/core/providers/torrent/ilovetorrents/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py index 755af526..558277b9 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/main.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py @@ -69,7 +69,10 @@ class ILoveTorrents(TorrentMagnetProvider): entries = results_table.find_all('tr') for result in entries[1:]: - link = result.find(href = re.compile('details.php'))['href'] + prelink = result.find(href = re.compile('details.php')) + contents = prelink.find('b').contents + name = str(contents[0]) + link = prelink['href'] download = result.find('a', href = re.compile('download.php'))['href'] try: @@ -94,7 +97,7 @@ class ILoveTorrents(TorrentMagnetProvider): fileSize = self.parseSize(size) results.append({ 'id': id, - 'name': link, + 'name': name, 'url': url, 'detail_url': detail_url, 'size': fileSize, From 83051b2576bdf38e310a63e656af6b3ec2fb4878 Mon Sep 17 00:00:00 2001 From: salfab Date: Sun, 29 Sep 2013 15:56:32 +0200 Subject: [PATCH 23/29] support getting more info. --- .../providers/torrent/ilovetorrents/main.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py index 558277b9..5f011e1e 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/main.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py @@ -124,12 +124,22 @@ class ILoveTorrents(TorrentMagnetProvider): def getDomain(self, url = ''): return cleanHost(self.domain).rstrip('/') + url - def getMoreInfo(self, item): - log.info('Getting more info') - full_description = self.getCache('ilt.%s' % item['id'], item['detail_url'], cache_timeout = 25920000) - html = BeautifulSoup(full_description) - nfo_pre = html.find('div', attrs = {'class':'nfo'}) - description = toUnicode(nfo_pre.text) if nfo_pre else '' + def getMoreInfo(self, item): + cache_key = 'ilt.%s' % item['id'] + description = self.getCache(cache_key) + + if not description: + + try: + full_description = self.getHTMLData(item['detail_url'], opener = self.login_opener) + html = BeautifulSoup(full_description, "html5lib") + nfo_pre = html.find('td', attrs = {'class':'main'}).findAll('table')[1].findAll('td')[5] + description = toUnicode(nfo_pre.text) if nfo_pre else '' + except: + log.error('Failed getting more info for %s', item['name']) + description = '' + + self.setCache(cache_key, description, timeout = 25920000) item['description'] = description return item From c37bf12c8a5eaa5a98ba45c179e1dbb64c02c6cd Mon Sep 17 00:00:00 2001 From: salfab Date: Sun, 29 Sep 2013 17:25:30 +0200 Subject: [PATCH 24/29] improve resilience to retrieve description in get_more_info --- couchpotato/core/providers/torrent/ilovetorrents/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py index 5f011e1e..7ddce50f 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/main.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py @@ -133,7 +133,7 @@ class ILoveTorrents(TorrentMagnetProvider): try: full_description = self.getHTMLData(item['detail_url'], opener = self.login_opener) html = BeautifulSoup(full_description, "html5lib") - nfo_pre = html.find('td', attrs = {'class':'main'}).findAll('table')[1].findAll('td')[5] + nfo_pre = html.find('td', attrs = {'class':'main'}).findAll('table')[1] description = toUnicode(nfo_pre.text) if nfo_pre else '' except: log.error('Failed getting more info for %s', item['name']) From 8df0ecc2231c5a087e0c92b2ca1cd5b3ab6d1cda Mon Sep 17 00:00:00 2001 From: salfab Date: Sun, 29 Sep 2013 17:40:35 +0200 Subject: [PATCH 25/29] disabled by default --- couchpotato/core/providers/torrent/thepiratebay/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/providers/torrent/thepiratebay/__init__.py b/couchpotato/core/providers/torrent/thepiratebay/__init__.py index 83de7a94..8cf9f86c 100644 --- a/couchpotato/core/providers/torrent/thepiratebay/__init__.py +++ b/couchpotato/core/providers/torrent/thepiratebay/__init__.py @@ -16,7 +16,7 @@ config = [{ { 'name': 'enabled', 'type': 'enabler', - 'default': True + 'default': False }, { 'name': 'domain', From bbf42da87514ba9e973564e2f19f47d4aa9a4f8f Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 30 Sep 2013 22:18:36 +0200 Subject: [PATCH 26/29] ILoveTorrents cleanup --- .../torrent/ilovetorrents/__init__.py | 2 +- .../providers/torrent/ilovetorrents/main.py | 96 +++++++------------ 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py index 84776e72..c6702d7f 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py @@ -16,7 +16,7 @@ config = [{ { 'name': 'enabled', 'type': 'enabler', - 'default': True + 'default': False }, { 'name': 'username', diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py index 7ddce50f..8c060ec3 100644 --- a/couchpotato/core/providers/torrent/ilovetorrents/main.py +++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py @@ -1,41 +1,34 @@ from bs4 import BeautifulSoup from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode -from couchpotato.core.helpers.variable import tryInt, cleanHost +from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog -from couchpotato.core.providers.torrent.base import TorrentMagnetProvider -from couchpotato.environment import Env +from couchpotato.core.providers.torrent.base import TorrentProvider import re -import time import traceback log = CPLog(__name__) -class ILoveTorrents(TorrentMagnetProvider): +class ILoveTorrents(TorrentProvider): urls = { - 'domain': 'www.ilovetorrents.me', 'download': 'http://www.ilovetorrents.me/%s', - 'detail': '%s/torrent/%s', - 'search': '%s/browse.php?search=%s&page=%s&cat=%s', + 'detail': 'http://www.ilovetorrents.me/%s', + 'search': 'http://www.ilovetorrents.me/browse.php?search=%s&page=%s&cat=%s', 'test' : 'http://www.ilovetorrents.me/', 'login' : 'http://www.ilovetorrents.me/takelogin.php', 'login_check' : 'http://www.ilovetorrents.me' } cat_ids = [ - (["41"], ['720p', '1080p', 'brrip']), - (["19"], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']), - (["20"], ['dvdr']) + (['41'], ['720p', '1080p', 'brrip']), + (['19'], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']), + (['20'], ['dvdr']) ] cat_backup_id = 200 disable_provider = False - http_time_between_calls = 0 - - def __init__(self): - self.domain = self.urls['domain'] - super(ILoveTorrents, self).__init__() + http_time_between_calls = 1 def _searchOnTitle(self, title, movie, quality, results): @@ -44,69 +37,60 @@ class ILoveTorrents(TorrentMagnetProvider): cats = self.getCatId(quality['identifier']) while page < total_pages: - + movieTitle = tryUrlencode('"%s" %s' % (title, movie['library']['year'])) - search_url = self.urls['search'] % (self.getDomain(), movieTitle, page, cats[0]) + search_url = self.urls['search'] % (movieTitle, page, cats[0]) page += 1 - - data = self.getHTMLData(search_url, opener = self.login_opener) + + data = self.getHTMLData(search_url, opener = self.login_opener) if data: try: - soup = BeautifulSoup(data, "html5lib") - + soup = BeautifulSoup(data) + results_table = soup.find('table', attrs = {'class': 'koptekst'}) if not results_table: return - + try: - pagelinks = soup.findAll(href=re.compile("page")) - pageNumbers = [int(re.search('page=(?P.+'')', i["href"]).group('pageNumber')) for i in pagelinks] + pagelinks = soup.findAll(href = re.compile('page')) + pageNumbers = [int(re.search('page=(?P.+'')', i['href']).group('pageNumber')) for i in pagelinks] total_pages = max(pageNumbers) - + except: pass entries = results_table.find_all('tr') - + for result in entries[1:]: prelink = result.find(href = re.compile('details.php')) - contents = prelink.find('b').contents - name = str(contents[0]) link = prelink['href'] - download = result.find('a', href = re.compile('download.php'))['href'] - - try: - matches = re.search('>(?P.+)
(?P.B)', unicode(result.select('td.rowhead')[5])) - size = matches.group('size') + " " + matches.group('unit') - - except: - continue + download = result.find('a', href = re.compile('download.php'))['href'] if link and download: + def extra_score(item): trusted = (0, 10)[result.find('img', alt = re.compile('Trusted')) is not None] vip = (0, 20)[result.find('img', alt = re.compile('VIP')) is not None] confirmed = (0, 30)[result.find('img', alt = re.compile('Helpers')) is not None] moderated = (0, 50)[result.find('img', alt = re.compile('Moderator')) is not None] - return confirmed + trusted + vip + moderated + return confirmed + trusted + vip + moderated + id = re.search('id=(?P\d+)&', link).group('id') url = self.urls['download'] % (download) - - detail_url = self.getDomain("/"+link) - fileSize = self.parseSize(size) + + fileSize = self.parseSize(result.select('td.rowhead')[5].text) results.append({ 'id': id, - 'name': name, + 'name': toUnicode(prelink.find('b').text), 'url': url, - 'detail_url': detail_url, + 'detail_url': self.urls['detail'] % link, 'size': fileSize, 'seeders': tryInt(result.find_all('td')[2].string), 'leechers': tryInt(result.find_all('td')[3].string), - 'extra_score': extra_score, - 'get_more_info': self.getMoreInfo + 'extra_score': extra_score, + 'get_more_info': self.getMoreInfo }) - log.info(results) except: log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) @@ -118,21 +102,15 @@ class ILoveTorrents(TorrentMagnetProvider): 'submit': 'Welcome to ILT', }) - def isEnabled(self): - return super(ILoveTorrents, self).isEnabled() and self.getDomain() - - def getDomain(self, url = ''): - return cleanHost(self.domain).rstrip('/') + url - - def getMoreInfo(self, item): + def getMoreInfo(self, item): cache_key = 'ilt.%s' % item['id'] description = self.getCache(cache_key) if not description: try: - full_description = self.getHTMLData(item['detail_url'], opener = self.login_opener) - html = BeautifulSoup(full_description, "html5lib") + full_description = self.getHTMLData(item['detail_url'], opener = self.login_opener) + html = BeautifulSoup(full_description) nfo_pre = html.find('td', attrs = {'class':'main'}).findAll('table')[1] description = toUnicode(nfo_pre.text) if nfo_pre else '' except: @@ -143,8 +121,8 @@ class ILoveTorrents(TorrentMagnetProvider): item['description'] = description return item - - def loginSuccess(self, output): - return 'logout.php' in output.lower() - loginCheckSuccess = loginSuccess + def loginSuccess(self, output): + return 'logout.php' in output.lower() + + loginCheckSuccess = loginSuccess From 38ce63795c3d5afe265470b28fab167c68b891b4 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 3 Oct 2013 08:26:02 +0200 Subject: [PATCH 27/29] Check snatched with single query --- couchpotato/core/plugins/renamer/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index c2b71361..fe28a2d8 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -661,9 +661,9 @@ Remove it if you want it to be renamed (again, or at least let it try again) fireEvent('status.get', ['snatched', 'ignored', 'failed', 'done', 'seeding', 'downloaded', 'missing'], single = True) db = get_session() - rels = db.query(Release).filter_by(status_id = snatched_status.get('id')).all() - rels.extend(db.query(Release).filter_by(status_id = seeding_status.get('id')).all()) - rels.extend(db.query(Release).filter_by(status_id = missing_status.get('id')).all()) + rels = db.query(Release).filter( + Release.status_id.in_(snatched_status.get('id'), seeding_status.get('id'), missing_status.get('id')) + ).all() scan_items = [] scan_required = False From b6f850dc2702def0ed11c985c7dde1138a7818f3 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 3 Oct 2013 08:30:13 +0200 Subject: [PATCH 28/29] in_ needs list.. --- couchpotato/core/plugins/renamer/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index fe28a2d8..28d5eef7 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -662,7 +662,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) db = get_session() rels = db.query(Release).filter( - Release.status_id.in_(snatched_status.get('id'), seeding_status.get('id'), missing_status.get('id')) + Release.status_id.in_([snatched_status.get('id'), seeding_status.get('id'), missing_status.get('id')]) ).all() scan_items = [] From 95d0dacd28b1905b8c452c079ddfc407d08cee50 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 7 Oct 2013 09:20:01 +0200 Subject: [PATCH 29/29] TorrentBytes login url change. fix #2317 --- couchpotato/core/providers/torrent/torrentbytes/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/providers/torrent/torrentbytes/main.py b/couchpotato/core/providers/torrent/torrentbytes/main.py index a5849a91..02b86abb 100644 --- a/couchpotato/core/providers/torrent/torrentbytes/main.py +++ b/couchpotato/core/providers/torrent/torrentbytes/main.py @@ -12,7 +12,7 @@ class TorrentBytes(TorrentProvider): urls = { 'test' : 'https://www.torrentbytes.net/', - 'login' : 'https://www.torrentbytes.net/takelogin.php', + 'login' : 'https://www.torrentbytes.net/login.php', 'login_check' : 'https://www.torrentbytes.net/inbox.php', 'detail' : 'https://www.torrentbytes.net/details.php?id=%s', 'search' : 'https://www.torrentbytes.net/browse.php?search=%s&cat=%d',