From b595cf8ebc7f458b640eb411ad65b1f56d2012b2 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 4 Apr 2012 23:53:34 +0200 Subject: [PATCH] Don't allow empty titles in library --- couchpotato/core/plugins/library/main.py | 2 ++ couchpotato/core/plugins/searcher/main.py | 12 +++++++++--- couchpotato/core/providers/movie/imdbapi/main.py | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/plugins/library/main.py b/couchpotato/core/plugins/library/main.py index 4cc3bb26..9a4cde04 100644 --- a/couchpotato/core/plugins/library/main.py +++ b/couchpotato/core/plugins/library/main.py @@ -84,6 +84,8 @@ class LibraryPlugin(Plugin): titles = info.get('titles', []) log.debug('Adding titles: %s' % titles) for title in titles: + if not title: + continue t = LibraryTitle( title = toUnicode(title), simple_title = self.simplifyTitle(title), diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index 4b4ee339..f3dc28fa 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -33,13 +33,19 @@ class Searcher(Plugin): ).all() for movie in movies: - - self.single(movie.to_dict({ + movie_dict = movie.to_dict({ 'profile': {'types': {'quality': {}}}, 'releases': {'status': {}, 'quality': {}}, 'library': {'titles': {}, 'files':{}}, 'files': {} - })) + }) + + try: + self.single(movie_dict) + except IndexError: + fireEvent('library.update', movie_dict['library']['identifier'], force = True) + except: + log.error('Search failed for %s: %s' % (movie_dict['library']['identifier'], traceback.format_exc())) # Break if CP wants to shut down if self.shuttingDown(): diff --git a/couchpotato/core/providers/movie/imdbapi/main.py b/couchpotato/core/providers/movie/imdbapi/main.py index 158359b0..604b37c1 100644 --- a/couchpotato/core/providers/movie/imdbapi/main.py +++ b/couchpotato/core/providers/movie/imdbapi/main.py @@ -61,13 +61,16 @@ class IMDBAPI(MovieProvider): if isinstance(movie, (str, unicode)): movie = json.loads(movie) + if movie.get('Response') == 'Parse Error': + return movie_data + tmp_movie = movie.copy() for key in tmp_movie: if tmp_movie.get(key).lower() == 'n/a': del movie[key] movie_data = { - 'titles': [movie.get('Title', '')], + 'titles': [movie.get('Title')] if movie.get('Title') else [], 'original_title': movie.get('Title', ''), 'images': { 'poster': [movie.get('Poster', '')] if movie.get('Poster') and len(movie.get('Poster', '')) > 4 else [],