Better movie merge on imdbid

This commit is contained in:
Ruud committed 2012-02-05 15:37:26 +01:00
1 parent db73447b1a
commit d085976090
2 files changed
+12 -12

No files matched your search

@@ -4,6 +4,7 @@ from couchpotato.core.helpers.variable import mergeDicts
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from couchpotato.core.settings.model import Library from couchpotato.core.settings.model import Library
import time
import traceback import traceback
log = CPLog(__name__) log = CPLog(__name__)
@@ -18,23 +19,20 @@ class MovieResultModifier(Plugin):
def combineOnIMDB(self, results): def combineOnIMDB(self, results):
temp = {} temp = {}
unique = 1 order = []
# Combine on imdb id # Combine on imdb id
for item in results: for item in results:
imdb = item.get('imdb') imdb = item.get('imdb', 'random-%s' % time.time())
if imdb: if not temp.get(imdb):
if not temp.get(imdb): temp[imdb] = self.getLibraryTags(imdb)
temp[imdb] = self.getLibraryTags(imdb) order.append(imdb)
# Merge dicts # Merge dicts
temp[imdb] = mergeDicts(temp[imdb], item) temp[imdb] = mergeDicts(temp[imdb], item)
else:
temp[unique] = item
unique += 1
# Make it a list again # Make it a list again
temp_list = [temp[x] for x in temp] temp_list = [temp[x] for x in order]
return temp_list return temp_list
@@ -16,6 +16,8 @@ class IMDBAPI(MovieProvider):
'info': 'http://www.imdbapi.com/?i=%s&tomatoes=true', 'info': 'http://www.imdbapi.com/?i=%s&tomatoes=true',
} }
http_time_between_calls = 0
def __init__(self): def __init__(self):
addEvent('movie.search', self.search) addEvent('movie.search', self.search)
addEvent('movie.info', self.getInfo) addEvent('movie.info', self.getInfo)
@@ -60,7 +62,7 @@ class IMDBAPI(MovieProvider):
'imdb': (tryFloat(movie.get('Rating', 0)), tryInt(movie.get('Votes', ''))), 'imdb': (tryFloat(movie.get('Rating', 0)), tryInt(movie.get('Votes', ''))),
'rotten': (tryFloat(movie.get('tomatoRating', 0)), tryInt(movie.get('tomatoReviews', 0))), 'rotten': (tryFloat(movie.get('tomatoRating', 0)), tryInt(movie.get('tomatoReviews', 0))),
}, },
'imdb': movie.get('ID', ''), 'imdb': str(movie.get('ID', '')),
'runtime': movie.get('Runtime', ''), 'runtime': movie.get('Runtime', ''),
'released': movie.get('Released', ''), 'released': movie.get('Released', ''),
'year': movie.get('Year', ''), 'year': movie.get('Year', ''),