Movie result modifier
This commit is contained in:
1 parent
81d10c40c4
commit
4d721a9554
2 files changed
+40
No files matched your search
@@ -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
|
||||||
Reference in new issue
Block a user