Movie result modifier

This commit is contained in:
Ruud
2011-09-26 20:04:28 +02:00
parent 81d10c40c4
commit 4d721a9554
2 changed files with 40 additions and 0 deletions
@@ -0,0 +1,7 @@
from .main import MovieResultModifier
def start():
return MovieResultModifier()
config = []
@@ -0,0 +1,33 @@
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.variable import mergeDicts
from couchpotato.core.plugins.base import Plugin
class MovieResultModifier(Plugin):
def __init__(self):
addEvent('result.modify.movie.search', self.combineOnIMDB)
def combineOnIMDB(self, results):
temp = {}
unique = 1
# Combine on imdb id
for item in results:
imdb = item.get('imdb')
if imdb:
if not temp.get(imdb):
temp[imdb] = {}
# Merge dicts
temp[imdb] = mergeDicts(temp[imdb], item)
else:
temp[unique] = item
unique += 1
# Make it a list again
temp_list = [temp[x] for x in temp]
return temp_list