diff --git a/couchpotato/core/_base/_core.py b/couchpotato/core/_base/_core.py index ca45ceb0..91cb97e9 100644 --- a/couchpotato/core/_base/_core.py +++ b/couchpotato/core/_base/_core.py @@ -77,7 +77,8 @@ class Core(Plugin): return True def cleanUpFolders(self): - self.deleteEmptyFolder(Env.get('app_dir'), show_error = False) + only_clean = ['couchpotato', 'libs', 'init'] + self.deleteEmptyFolder(Env.get('app_dir'), show_error = False, only_clean = only_clean) def available(self, **kwargs): return { diff --git a/couchpotato/core/media/_base/media/main.py b/couchpotato/core/media/_base/media/main.py index beb9dd02..6da14565 100644 --- a/couchpotato/core/media/_base/media/main.py +++ b/couchpotato/core/media/_base/media/main.py @@ -387,7 +387,7 @@ class MediaPlugin(MediaBase): db.delete(release) total_deleted += 1 - if (total_releases == total_deleted and media['status'] != 'active') or (delete_from == 'wanted' and media['status'] == 'active'): + if (total_releases == total_deleted and media['status'] != 'active') or (delete_from == 'wanted' and media['status'] == 'active') or (not new_media_status and delete_from == 'late'): db.delete(media) deleted = True elif new_media_status: diff --git a/couchpotato/core/media/_base/providers/torrent/torrentleech.py b/couchpotato/core/media/_base/providers/torrent/torrentleech.py index fe427985..a5916272 100644 --- a/couchpotato/core/media/_base/providers/torrent/torrentleech.py +++ b/couchpotato/core/media/_base/providers/torrent/torrentleech.py @@ -24,9 +24,9 @@ class Base(TorrentProvider): http_time_between_calls = 1 # Seconds cat_backup_id = None - def _search(self, media, quality, results): + def _searchOnTitle(self, title, media, quality, results): - url = self.urls['search'] % self.buildUrl(media, quality) + url = self.urls['search'] % self.buildUrl(title, media, quality) data = self.getHTMLData(url) diff --git a/couchpotato/core/media/movie/providers/torrent/torrentleech.py b/couchpotato/core/media/movie/providers/torrent/torrentleech.py index 9ab1580e..191ceba8 100644 --- a/couchpotato/core/media/movie/providers/torrent/torrentleech.py +++ b/couchpotato/core/media/movie/providers/torrent/torrentleech.py @@ -1,4 +1,3 @@ -from couchpotato import fireEvent from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.logger import CPLog from couchpotato.core.media._base.providers.torrent.torrentleech import Base @@ -21,8 +20,8 @@ class TorrentLeech(MovieProvider, Base): ([12], ['dvdr']), ] - def buildUrl(self, media, quality): + def buildUrl(self, title, media, quality): return ( - tryUrlencode(fireEvent('library.query', media, single = True)), + tryUrlencode(title.replace(':', '')), self.getCatId(quality)[0] ) diff --git a/couchpotato/core/notifications/xmpp_.py b/couchpotato/core/notifications/xmpp_.py index 9cee8c5a..f9916cd0 100644 --- a/couchpotato/core/notifications/xmpp_.py +++ b/couchpotato/core/notifications/xmpp_.py @@ -5,8 +5,6 @@ from couchpotato.core.logger import CPLog from couchpotato.core.notifications.base import Notification import xmpp -print xmpp - log = CPLog(__name__) diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index dae522f4..af314bfd 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -140,13 +140,31 @@ class Plugin(object): return False - def deleteEmptyFolder(self, folder, show_error = True): + def deleteEmptyFolder(self, folder, show_error = True, only_clean = None): folder = sp(folder) + allowed_dirs = [] + if only_clean: + for item in os.listdir(folder): + full_path = os.path.join(folder, item) + if item in only_clean and os.path.isdir(full_path): + allowed_dirs.append(full_path) + for root, dirs, files in os.walk(folder): for dir_name in dirs: full_path = os.path.join(root, dir_name) + + if only_clean: + allow = False + for allowed_dir in allowed_dirs: + if allowed_dir in full_path: + allow = True + break + + if not allow: + continue + if len(os.listdir(full_path)) == 0: try: os.rmdir(full_path)