diff --git a/couchpotato/core/event.py b/couchpotato/core/event.py index c64e35f..5ec80dc 100644 --- a/couchpotato/core/event.py +++ b/couchpotato/core/event.py @@ -12,7 +12,7 @@ def runHandler(name, handler, *args, **kwargs): return handler(*args, **kwargs) except: from couchpotato.environment import Env - log.error('Error in event "%s", that wasn\'t caught: %s%s', (name, traceback.format_exc(), Env.all())) + log.error('Error in event "%s", that wasn\'t caught: %s%s', (name, traceback.format_exc(), Env.all() if not Env.get('dev') else '')) def addEvent(name, handler, priority = 100): diff --git a/couchpotato/core/helpers/encoding.py b/couchpotato/core/helpers/encoding.py index b4f4b70..a11dd88 100644 --- a/couchpotato/core/helpers/encoding.py +++ b/couchpotato/core/helpers/encoding.py @@ -68,7 +68,7 @@ def tryUrlencode(s): return new[1:] else: - for letter in toUnicode(s): + for letter in ss(s): try: new += quote_plus(letter) except: diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 28cbc88..1ecb35b 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -1,3 +1,4 @@ +from couchpotato.core.helpers.encoding import simplifyString, toSafeString from couchpotato.core.logger import CPLog import hashlib import os.path @@ -153,6 +154,16 @@ def getTitle(library_dict): log.error('Could not get title for library item: %s', library_dict) return None +def possibleTitles(raw_title): + + titles = [] + + titles.append(toSafeString(raw_title).lower()) + titles.append(raw_title.lower()) + titles.append(simplifyString(raw_title)) + + return list(set(titles)) + def randomString(size = 8, chars = string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for x in range(size)) diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index fc2bfdb..2392f25 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -1,9 +1,8 @@ from StringIO import StringIO from couchpotato import addView from couchpotato.core.event import fireEvent, addEvent -from couchpotato.core.helpers.encoding import tryUrlencode, simplifyString, ss, \ - toSafeString -from couchpotato.core.helpers.variable import getExt +from couchpotato.core.helpers.encoding import tryUrlencode, ss, toSafeString +from couchpotato.core.helpers.variable import getExt, md5 from couchpotato.core.logger import CPLog from couchpotato.environment import Env from flask.templating import render_template_string @@ -222,7 +221,7 @@ class Plugin(object): def getCache(self, cache_key, url = None, **kwargs): - cache_key = simplifyString(cache_key) + cache_key = md5(ss(cache_key)) cache = Env.get('cache').get(cache_key) if cache: if not Env.get('dev'): log.debug('Getting cache %s', cache_key) @@ -242,9 +241,11 @@ class Plugin(object): self.setCache(cache_key, data, timeout = cache_timeout) return data except: - if not kwargs.get('show_error'): + if not kwargs.get('show_error', True): raise + return '' + def setCache(self, cache_key, value, timeout = 300): log.debug('Setting cache %s', cache_key) Env.get('cache').set(cache_key, value, timeout) diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index 5c40df0..a9eab33 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -66,10 +66,12 @@ class FileManager(Plugin): time.sleep(3) log.debug('Cleaning up unused files') + python_cache = Env.get('cache')._path try: db = get_session() for root, dirs, walk_files in os.walk(Env.get('cache_dir')): for filename in walk_files: + if root == python_cache: continue file_path = os.path.join(root, filename) f = db.query(File).filter(File.path == toUnicode(file_path)).first() if not f: diff --git a/couchpotato/core/plugins/manage/main.py b/couchpotato/core/plugins/manage/main.py index f09a127..40336e5 100644 --- a/couchpotato/core/plugins/manage/main.py +++ b/couchpotato/core/plugins/manage/main.py @@ -115,12 +115,35 @@ class Manage(Plugin): if done_movie['library']['identifier'] not in added_identifiers: fireEvent('movie.delete', movie_id = done_movie['id'], delete_from = 'all') else: + for release in done_movie.get('releases', []): - for release_file in release.get('files', []): - # Remove release not available anymore - if not os.path.isfile(ss(release_file['path'])): - fireEvent('release.clean', release['id']) - break + if len(release.get('files', [])) == 0: + fireEvent('release.delete', release['id']) + else: + for release_file in release.get('files', []): + # Remove release not available anymore + if not os.path.isfile(ss(release_file['path'])): + fireEvent('release.clean', release['id']) + break + + # Check if there are duplicate releases (different quality) use the last one, delete the rest + if len(done_movie.get('releases', [])) > 1: + used_files = {} + for release in done_movie.get('releases', []): + + for release_file in release.get('files', []): + already_used = used_files.get(release_file['path']) + + if already_used: + print already_used, release['id'] + if already_used < release['id']: + fireEvent('release.delete', release['id'], single = True) # delete this one + else: + fireEvent('release.delete', already_used, single = True) # delete previous one + break + else: + used_files[release_file['path']] = release.get('id') + del used_files Env.prop('manage.last_update', time.time()) except: @@ -153,7 +176,7 @@ class Manage(Plugin): 'to_go': total_found, } - if group['library']: + if group['library'] and group['library'].get('identifier'): identifier = group['library'].get('identifier') added_identifiers.append(identifier) @@ -187,5 +210,5 @@ class Manage(Plugin): groups = fireEvent('scanner.scan', folder = folder, files = files, single = True) for group in groups.itervalues(): - if group['library']: + if group['library'] and group['library'].get('identifier'): fireEvent('release.add', group = group) diff --git a/couchpotato/core/plugins/quality/main.py b/couchpotato/core/plugins/quality/main.py index 6282b75..aeb74e5 100644 --- a/couchpotato/core/plugins/quality/main.py +++ b/couchpotato/core/plugins/quality/main.py @@ -7,6 +7,7 @@ from couchpotato.core.helpers.variable import mergeDicts, md5, getExt from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import Quality, Profile, ProfileType +from sqlalchemy.sql.expression import or_ import os.path import re import time @@ -18,8 +19,8 @@ class QualityPlugin(Plugin): qualities = [ {'identifier': 'bd50', 'hd': True, 'size': (15000, 60000), 'label': 'BR-Disk', 'alternative': ['bd25'], 'allow': ['1080p'], 'ext':[], 'tags': ['bdmv', 'certificate', ('complete', 'bluray')]}, - {'identifier': '1080p', 'hd': True, 'size': (5000, 20000), 'label': '1080P', 'width': 1920, 'alternative': [], 'allow': [], 'ext':['mkv', 'm2ts'], 'tags': ['m2ts']}, - {'identifier': '720p', 'hd': True, 'size': (3500, 10000), 'label': '720P', 'width': 1280, 'alternative': [], 'allow': [], 'ext':['mkv', 'ts']}, + {'identifier': '1080p', 'hd': True, 'size': (5000, 20000), 'label': '1080P', 'width': 1920, 'height': 1080, 'alternative': [], 'allow': [], 'ext':['mkv', 'm2ts'], 'tags': ['m2ts']}, + {'identifier': '720p', 'hd': True, 'size': (3500, 10000), 'label': '720P', 'width': 1280, 'height': 720, 'alternative': [], 'allow': [], 'ext':['mkv', 'ts']}, {'identifier': 'brrip', 'hd': True, 'size': (700, 7000), 'label': 'BR-Rip', 'alternative': ['bdrip'], 'allow': ['720p'], 'ext':['avi']}, {'identifier': 'dvdr', 'size': (3000, 10000), 'label': 'DVD-R', 'alternative': [], 'allow': [], 'ext':['iso', 'img'], 'tags': ['pal', 'ntsc', 'video_ts', 'audio_ts']}, {'identifier': 'dvdrip', 'size': (600, 2400), 'label': 'DVD-Rip', 'width': 720, 'alternative': ['dvdrip'], 'allow': [], 'ext':['avi', 'mpg', 'mpeg'], 'tags': [('dvd', 'rip'), ('dvd', 'xvid'), ('dvd', 'divx')]}, @@ -76,7 +77,7 @@ class QualityPlugin(Plugin): db = get_session() quality_dict = {} - quality = db.query(Quality).filter_by(identifier = identifier).first() + quality = db.query(Quality).filter(or_(Quality.identifier == identifier, Quality.id == identifier)).first() if quality: quality_dict = dict(self.getQuality(quality.identifier), **quality.to_dict()) @@ -198,9 +199,14 @@ class QualityPlugin(Plugin): for quality in self.all(): - # Last check on resolution only - if quality.get('width', 480) == extra.get('resolution_width', 0): - log.debug('Found %s via resolution_width: %s == %s', (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0))) + # Check width resolution, range 20 + if (quality.get('width', 720) - 20) <= extra.get('resolution_width', 0) <= (quality.get('width', 720) + 20): + log.debug('Found %s via resolution_width: %s == %s', (quality['identifier'], quality.get('width', 720), extra.get('resolution_width', 0))) + return self.setCache(hash, quality) + + # Check height resolution, range 20 + if (quality.get('height', 480) - 20) <= extra.get('resolution_height', 0) <= (quality.get('height', 480) + 20): + log.debug('Found %s via resolution_height: %s == %s', (quality['identifier'], quality.get('height', 480), extra.get('resolution_height', 0))) return self.setCache(hash, quality) if 480 <= extra.get('resolution_width', 0) <= 720: diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 8f40854..02843f8 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -133,6 +133,9 @@ class Release(Plugin): db.delete(release_file) db.commit() + if len(rel.files) == 0: + self.delete(id) + return True return False diff --git a/couchpotato/core/plugins/renamer/__init__.py b/couchpotato/core/plugins/renamer/__init__.py index e2c65ed..8898969 100644 --- a/couchpotato/core/plugins/renamer/__init__.py +++ b/couchpotato/core/plugins/renamer/__init__.py @@ -133,13 +133,6 @@ config = [{ 'type': 'choice', 'options': rename_options }, - { - 'name': 'trailer_name', - 'label': 'Trailer naming', - 'default': '-trailer.', - 'type': 'choice', - 'options': rename_options - }, ], }, ], diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 1adf659..75982ba 100644 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -340,6 +340,7 @@ class Renamer(Plugin): log.info('Removing "%s"', src) try: + src = ss(src) if os.path.isfile(src): os.remove(src) @@ -497,6 +498,7 @@ class Renamer(Plugin): return string.replace(' ', ' ').replace(' .', '.') def deleteEmptyFolder(self, folder, show_error = True): + folder = ss(folder) loge = log.error if show_error else log.debug for root, dirs, files in os.walk(folder): diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index 78feca8..2a1d307 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -421,7 +421,7 @@ class Scanner(Plugin): if not data['quality']: data['quality'] = fireEvent('quality.single', 'dvdr' if group['is_dvd'] else 'dvdrip', single = True) - data['quality_type'] = 'HD' if data.get('resolution_width', 0) >= 1280 else 'SD' + data['quality_type'] = 'HD' if data.get('resolution_width', 0) >= 1280 or data['quality'].get('hd') else 'SD' filename = re.sub('(.cp\(tt[0-9{7}]+\))', '', files[0]) data['group'] = self.getGroup(filename[len(folder):]) @@ -775,7 +775,7 @@ class Scanner(Plugin): return None def findYear(self, text): - matches = re.search('(?P[12]{1}[0-9]{3})', text) + matches = re.search('(?P19[0-9]{2}|20[0-9]{2})', text) if matches: return matches.group('year') diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index c8188ac..4fe5edd 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -3,7 +3,8 @@ from couchpotato.api import addApiView from couchpotato.core.event import addEvent, fireEvent, fireEventAsync from couchpotato.core.helpers.encoding import simplifyString, toUnicode from couchpotato.core.helpers.request import jsonified, getParam -from couchpotato.core.helpers.variable import md5, getTitle, splitString +from couchpotato.core.helpers.variable import md5, getTitle, splitString, \ + possibleTitles from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import Movie, Release, ReleaseInfo @@ -365,17 +366,18 @@ class Searcher(Plugin): if self.checkIMDB([nzb['description']], movie['library']['identifier']): return True - for movie_title in movie['library']['titles']: - movie_words = re.split('\W+', simplifyString(movie_title['title'])) + for raw_title in movie['library']['titles']: + for movie_title in possibleTitles(raw_title['title']): + movie_words = re.split('\W+', simplifyString(movie_title)) - if self.correctName(nzb['name'], movie_title['title']): - # if no IMDB link, at least check year range 1 - if len(movie_words) > 2 and self.correctYear([nzb['name']], movie['library']['year'], 1): - return True + if self.correctName(nzb['name'], movie_title): + # if no IMDB link, at least check year range 1 + if len(movie_words) > 2 and self.correctYear([nzb['name']], movie['library']['year'], 1): + return True - # if no IMDB link, at least check year - if len(movie_words) <= 2 and self.correctYear([nzb['name']], movie['library']['year'], 0): - return True + # if no IMDB link, at least check year + if len(movie_words) <= 2 and self.correctYear([nzb['name']], movie['library']['year'], 0): + return True log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'" % (nzb['name'], movie_name, movie['library']['year'])) return False @@ -444,12 +446,16 @@ class Searcher(Plugin): def correctName(self, check_name, movie_name): check_names = [check_name] - try: - check_names.append(re.search(r'([\'"])[^\1]*\1', check_name).group(0)) - except: - pass - for check_name in check_names: + # Match names between " + try: check_names.append(re.search(r'([\'"])[^\1]*\1', check_name).group(0)) + except: pass + + # Match longest name between [] + try: check_names.append(max(check_name.split('['), key = len)) + except: pass + + for check_name in list(set(check_names)): check_movie = fireEvent('scanner.name_year', check_name, single = True) try: diff --git a/couchpotato/core/plugins/trailer/__init__.py b/couchpotato/core/plugins/trailer/__init__.py index f3aa59d..282b348 100644 --- a/couchpotato/core/plugins/trailer/__init__.py +++ b/couchpotato/core/plugins/trailer/__init__.py @@ -24,6 +24,13 @@ config = [{ 'type': 'dropdown', 'values': [('1080P', '1080p'), ('720P', '720p'), ('480P', '480p')], }, + { + 'name': 'name', + 'label': 'Naming', + 'default': '-trailer', + 'advanced': True, + 'description': 'Use to use above settings.' + }, ], }, ], diff --git a/couchpotato/core/plugins/trailer/main.py b/couchpotato/core/plugins/trailer/main.py index 9a32265..4ab51e7 100644 --- a/couchpotato/core/plugins/trailer/main.py +++ b/couchpotato/core/plugins/trailer/main.py @@ -19,10 +19,11 @@ class Trailer(Plugin): trailers = fireEvent('trailer.search', group = group, merge = True) if not trailers or trailers == []: log.info('No trailers found for: %s', getTitle(group['library'])) - return + return False for trailer in trailers.get(self.conf('quality'), []): - destination = '%s-trailer.%s' % (self.getRootName(group), getExt(trailer)) + filename = self.conf('name').replace('', group['filename']) + ('.%s' % getExt(trailer)) + destination = os.path.join(group['destination_dir'], filename) if not os.path.isfile(destination): fireEvent('file.download', url = trailer, dest = destination, urlopen_kwargs = {'headers': {'User-Agent': 'Quicktime'}}, single = True) else: @@ -33,5 +34,5 @@ class Trailer(Plugin): # Download first and break break - def getRootName(self, data = {}): - return os.path.join(data['destination_dir'], data['filename']) + return True + diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py index c218724..9cbbdb5 100644 --- a/couchpotato/core/providers/base.py +++ b/couchpotato/core/providers/base.py @@ -1,5 +1,6 @@ from couchpotato.core.event import addEvent -from couchpotato.core.helpers.variable import tryFloat +from couchpotato.core.helpers.encoding import simplifyString +from couchpotato.core.helpers.variable import tryFloat, getTitle from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.environment import Env @@ -155,3 +156,15 @@ class YarrProvider(Provider): new['provider_extra'] = ', %s' % new['provider_extra'] log.info('Found: score(%(score)s) on %(provider)s%(provider_extra)s: %(name)s', new) + + def removeDuplicateResults(self, results): + + result_ids = [] + new_results = [] + + for result in results: + if result['id'] not in result_ids: + new_results.append(result) + result_ids.append(result['id']) + + return new_results diff --git a/couchpotato/core/providers/movie/themoviedb/main.py b/couchpotato/core/providers/movie/themoviedb/main.py index 8b15a5c..0554a90 100644 --- a/couchpotato/core/providers/movie/themoviedb/main.py +++ b/couchpotato/core/providers/movie/themoviedb/main.py @@ -3,6 +3,7 @@ from couchpotato.core.helpers.encoding import simplifyString, toUnicode from couchpotato.core.logger import CPLog from couchpotato.core.providers.movie.base import MovieProvider from libs.themoviedb import tmdb +import traceback log = CPLog(__name__) @@ -61,7 +62,12 @@ class TheMovieDb(MovieProvider): if not results: log.debug('Searching for movie: %s', q) - raw = tmdb.search(search_string) + + raw = None + try: + raw = tmdb.search(search_string) + except: + log.error('Failed searching TMDB for "%s": %s', (search_string, traceback.format_exc())) results = [] if raw: diff --git a/couchpotato/core/providers/nzb/ftdworld/main.py b/couchpotato/core/providers/nzb/ftdworld/main.py index 5748671..e684e21 100644 --- a/couchpotato/core/providers/nzb/ftdworld/main.py +++ b/couchpotato/core/providers/nzb/ftdworld/main.py @@ -1,8 +1,7 @@ from bs4 import BeautifulSoup from couchpotato.core.event import fireEvent -from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ - simplifyString -from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode +from couchpotato.core.helpers.variable import tryInt, possibleTitles, getTitle from couchpotato.core.logger import CPLog from couchpotato.core.providers.nzb.base import NZBProvider from couchpotato.environment import Env @@ -22,7 +21,7 @@ class FTDWorld(NZBProvider): 'login': 'http://ftdworld.net/index.php', } - http_time_between_calls = 1 #seconds + http_time_between_calls = 3 #seconds cat_ids = [ ([4, 11], ['dvdr']), @@ -33,11 +32,19 @@ class FTDWorld(NZBProvider): def search(self, movie, quality): - results = [] if self.isDisabled(): - return results + return [] + + results = [] + for title in possibleTitles(getTitle(movie['library'])): + results.extend(self._search(title, movie, quality)) + + return self.removeDuplicateResults(results) + + def _search(self, title, movie, quality): + results = [] - q = '%s %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year']) + q = '"%s" %s' % (title, movie['library']['year']) params = { 'ctitle': q, @@ -81,7 +88,7 @@ class FTDWorld(NZBProvider): 'download': self.loginDownload, 'detail_url': self.urls['detail'] % nzb_id, 'description': '', - 'score': (tryInt(up.attrs['title'].split(' ')[0]) * 3) - (tryInt(down.attrs['title'].split(' ')[0]) * 3), + 'score': (tryInt(up.attrs['title'].split(' ')[0]) * 3) - (tryInt(down.attrs['title'].split(' ')[0]) * 3) if up else 0, } is_correct_movie = fireEvent('searcher.correct_movie', diff --git a/couchpotato/core/providers/nzb/nzbclub/main.py b/couchpotato/core/providers/nzb/nzbclub/main.py index 9f85348..487b9a6 100644 --- a/couchpotato/core/providers/nzb/nzbclub/main.py +++ b/couchpotato/core/providers/nzb/nzbclub/main.py @@ -1,12 +1,10 @@ from bs4 import BeautifulSoup from couchpotato.core.event import fireEvent -from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ - simplifyString +from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode from couchpotato.core.helpers.rss import RSS -from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.helpers.variable import tryInt, getTitle, possibleTitles from couchpotato.core.logger import CPLog from couchpotato.core.providers.nzb.base import NZBProvider -from couchpotato.environment import Env from dateutil.parser import parse import time import xml.etree.ElementTree as XMLTree @@ -24,11 +22,19 @@ class NZBClub(NZBProvider, RSS): def search(self, movie, quality): - results = [] if self.isDisabled(): - return results + return [] + + results = [] + for title in possibleTitles(getTitle(movie['library'])): + results.extend(self._search(title, movie, quality)) + + return self.removeDuplicateResults(results) + + def _search(self, title, movie, quality): + results = [] - q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier')) + q = '"%s %s" %s' % (title, movie['library']['year'], quality.get('identifier')) params = { 'q': q, diff --git a/couchpotato/core/providers/nzb/nzbindex/main.py b/couchpotato/core/providers/nzb/nzbindex/main.py index 109792e..f4f1d6b 100644 --- a/couchpotato/core/providers/nzb/nzbindex/main.py +++ b/couchpotato/core/providers/nzb/nzbindex/main.py @@ -1,9 +1,8 @@ from bs4 import BeautifulSoup from couchpotato.core.event import fireEvent -from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ - simplifyString +from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode from couchpotato.core.helpers.rss import RSS -from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.helpers.variable import tryInt, getTitle, possibleTitles from couchpotato.core.logger import CPLog from couchpotato.core.providers.nzb.base import NZBProvider from couchpotato.environment import Env @@ -27,11 +26,19 @@ class NzbIndex(NZBProvider, RSS): def search(self, movie, quality): - results = [] if self.isDisabled(): - return results + return [] + + results = [] + for title in possibleTitles(getTitle(movie['library'])): + results.extend(self._search(title, movie, quality)) + + return self.removeDuplicateResults(results) - q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier')) + def _search(self, title, movie, quality): + results = [] + + q = '"%s" %s %s' % (title, movie['library']['year'], quality.get('identifier')) arguments = tryUrlencode({ 'q': q, 'age': Env.setting('retention', 'nzb'), @@ -45,9 +52,9 @@ class NzbIndex(NZBProvider, RSS): }) url = "%s?%s" % (self.urls['api'], arguments) - cache_key = 'nzbindex.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) - + cache_key = 'nzbindex.%s.%s' % (movie['library']['identifier'], q) data = self.getCache(cache_key, url) + if data: try: try: diff --git a/couchpotato/core/providers/nzb/nzbsrus/main.py b/couchpotato/core/providers/nzb/nzbsrus/main.py index b92d677..ee2b223 100644 --- a/couchpotato/core/providers/nzb/nzbsrus/main.py +++ b/couchpotato/core/providers/nzb/nzbsrus/main.py @@ -46,8 +46,7 @@ class Nzbsrus(NZBProvider, RSS): url = "%s&%s&%s" % (self.urls['search'], arguments , cat_id_string) - cache_key = 'nzbsrus_1.%s.%s' % (movie['library'].get('identifier'), cat_id_string) - single_cat = True + cache_key = 'nzbsrus.%s.%s' % (movie['library'].get('identifier'), cat_id_string) data = self.getCache(cache_key, url, cache_timeout = 1800, headers = {'User-Agent': Env.getIdentifier()}) if data: diff --git a/couchpotato/core/providers/nzb/omgwtfnzbs/main.py b/couchpotato/core/providers/nzb/omgwtfnzbs/main.py index a6ea831..533190b 100644 --- a/couchpotato/core/providers/nzb/omgwtfnzbs/main.py +++ b/couchpotato/core/providers/nzb/omgwtfnzbs/main.py @@ -1,9 +1,8 @@ from bs4 import BeautifulSoup from couchpotato.core.event import fireEvent -from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ - simplifyString +from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode from couchpotato.core.helpers.rss import RSS -from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.helpers.variable import tryInt, getTitle, possibleTitles from couchpotato.core.logger import CPLog from couchpotato.core.providers.nzb.base import NZBProvider from dateutil.parser import parse @@ -33,12 +32,19 @@ class OMGWTFNZBs(NZBProvider, RSS): def search(self, movie, quality): pre_releases = fireEvent('quality.pre_releases', single = True) + if self.isDisabled() or quality['identifier'] in pre_releases: + return [] results = [] - if self.isDisabled() or quality['identifier'] in pre_releases: - return results + for title in possibleTitles(getTitle(movie['library'])): + results.extend(self._search(title, movie, quality)) + + return self.removeDuplicateResults(results) + + def _search(self, title, movie, quality): + results = [] - q = '%s %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year']) + q = '%s %s' % (title, movie['library']['year']) params = { 'search': q, diff --git a/couchpotato/core/providers/torrent/publichd/__init__.py b/couchpotato/core/providers/torrent/publichd/__init__.py index 49a9d96..b0d3b70 100644 --- a/couchpotato/core/providers/torrent/publichd/__init__.py +++ b/couchpotato/core/providers/torrent/publichd/__init__.py @@ -10,7 +10,7 @@ config = [{ 'tab': 'searcher', 'subtab': 'torrent_providers', 'name': 'PublicHD', - 'description': 'Public Torrent site with only HD content. See PublicHD', + 'description': 'Public Torrent site with only HD content. See PublicHD', 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/providers/torrent/publichd/main.py b/couchpotato/core/providers/torrent/publichd/main.py index c43d1ab..6631cd0 100644 --- a/couchpotato/core/providers/torrent/publichd/main.py +++ b/couchpotato/core/providers/torrent/publichd/main.py @@ -14,9 +14,9 @@ log = CPLog(__name__) class PublicHD(TorrentProvider): urls = { - 'test': 'https://publichd.eu', - 'detail': 'https://publichd.eu/index.php?page=torrent-details&id=%s', - 'search': 'https://publichd.eu/index.php', + 'test': 'https://publichd.se', + 'detail': 'https://publichd.se/index.php?page=torrent-details&id=%s', + 'search': 'https://publichd.se/index.php', } http_time_between_calls = 0 diff --git a/couchpotato/core/providers/torrent/torrentleech/main.py b/couchpotato/core/providers/torrent/torrentleech/main.py index 0cfc7ce..0f83827 100644 --- a/couchpotato/core/providers/torrent/torrentleech/main.py +++ b/couchpotato/core/providers/torrent/torrentleech/main.py @@ -32,6 +32,7 @@ class TorrentLeech(TorrentProvider): ] http_time_between_calls = 1 #seconds + cat_backup_id = None def search(self, movie, quality): @@ -61,6 +62,7 @@ class TorrentLeech(TorrentProvider): link = result.find('td', attrs = {'class' : 'name'}).find('a') url = result.find('td', attrs = {'class' : 'quickdownload'}).find('a') + details = result.find('td', attrs = {'class' : 'name'}).find('a') new = { 'id': link['href'].replace('/torrent/', ''), @@ -70,6 +72,7 @@ class TorrentLeech(TorrentProvider): 'description': '', 'provider': self.getName(), 'url': self.urls['download'] % url['href'], + 'detail_url': self.urls['download'] % details['href'], 'download': self.loginDownload, 'size': self.parseSize(result.find_all('td')[4].string), 'seeders': tryInt(result.find('td', attrs = {'class' : 'seeders'}).string), diff --git a/couchpotato/core/settings/model.py b/couchpotato/core/settings/model.py index 2ecb48a..64117fb 100644 --- a/couchpotato/core/settings/model.py +++ b/couchpotato/core/settings/model.py @@ -100,7 +100,7 @@ class Release(Entity): movie = ManyToOne('Movie') status = ManyToOne('Status') quality = ManyToOne('Quality') - files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) + files = ManyToMany('File') info = OneToMany('ReleaseInfo', cascade = 'all, delete-orphan') def to_dict(self, deep = {}, exclude = []):