4 changed files with 0 additions and 106 deletions
@ -1,7 +0,0 @@ |
|||||
from .main import ShowResultModifier |
|
||||
|
|
||||
def start(): |
|
||||
|
|
||||
return ShowResultModifier() |
|
||||
|
|
||||
config = [] |
|
@ -1,94 +0,0 @@ |
|||||
from couchpotato import get_session |
|
||||
from couchpotato.core.event import addEvent, fireEvent |
|
||||
from couchpotato.core.helpers.variable import mergeDicts, randomString |
|
||||
from couchpotato.core.logger import CPLog |
|
||||
from couchpotato.core.plugins.base import Plugin |
|
||||
from couchpotato.core.settings.model import Library |
|
||||
import copy |
|
||||
import traceback |
|
||||
|
|
||||
log = CPLog(__name__) |
|
||||
|
|
||||
|
|
||||
class ShowResultModifier(Plugin): |
|
||||
|
|
||||
default_info = { |
|
||||
'tmdb_id': 0, |
|
||||
'titles': [], |
|
||||
'original_title': '', |
|
||||
'year': 0, |
|
||||
'images': { |
|
||||
'poster': [], |
|
||||
'backdrop': [], |
|
||||
'poster_original': [], |
|
||||
'backdrop_original': [] |
|
||||
}, |
|
||||
'runtime': 0, |
|
||||
'plot': '', |
|
||||
'tagline': '', |
|
||||
'imdb': '', |
|
||||
'genres': [], |
|
||||
} |
|
||||
|
|
||||
def __init__(self): |
|
||||
addEvent('result.modify.show.search', self.combineOnIMDB) |
|
||||
addEvent('result.modify.show.info', self.checkLibrary) |
|
||||
|
|
||||
def combineOnIMDB(self, results): |
|
||||
|
|
||||
temp = {} |
|
||||
order = [] |
|
||||
|
|
||||
# Combine on imdb id |
|
||||
for item in results: |
|
||||
random_string = randomString() |
|
||||
imdb = item.get('imdb', random_string) |
|
||||
imdb = imdb if imdb else random_string |
|
||||
|
|
||||
if not temp.get(imdb): |
|
||||
temp[imdb] = self.getLibraryTags(imdb) |
|
||||
order.append(imdb) |
|
||||
|
|
||||
# Merge dicts |
|
||||
temp[imdb] = mergeDicts(temp[imdb], item) |
|
||||
|
|
||||
# Make it a list again |
|
||||
temp_list = [temp[x] for x in order] |
|
||||
|
|
||||
return temp_list |
|
||||
|
|
||||
def getLibraryTags(self, imdb): |
|
||||
|
|
||||
temp = { |
|
||||
'in_wanted': False, |
|
||||
'in_library': False, |
|
||||
} |
|
||||
|
|
||||
# Add release info from current library |
|
||||
db = get_session() |
|
||||
try: |
|
||||
l = db.query(Library).filter_by(identifier = imdb).first() |
|
||||
if l: |
|
||||
|
|
||||
# Statuses |
|
||||
active_status, done_status = fireEvent('status.get', ['active', 'done'], single = True) |
|
||||
|
|
||||
for movie in l.media: |
|
||||
if movie.status_id == active_status['id']: |
|
||||
temp['in_wanted'] = fireEvent('movie.get', movie.id, single = True) |
|
||||
|
|
||||
for release in movie.releases: |
|
||||
if release.status_id == done_status['id']: |
|
||||
temp['in_library'] = fireEvent('movie.get', movie.id, single = True) |
|
||||
except: |
|
||||
log.error('Tried getting more info on searched movies: %s', traceback.format_exc()) |
|
||||
|
|
||||
return temp |
|
||||
|
|
||||
def checkLibrary(self, result): |
|
||||
|
|
||||
result = mergeDicts(copy.deepcopy(self.default_info), copy.deepcopy(result)) |
|
||||
|
|
||||
if result and result.get('imdb'): |
|
||||
return mergeDicts(result, self.getLibraryTags(result['imdb'])) |
|
||||
return result |
|
@ -1,5 +0,0 @@ |
|||||
from couchpotato.core.providers.base import Provider |
|
||||
|
|
||||
|
|
||||
class ShowProvider(Provider): |
|
||||
type = 'show' |
|
Loading…
Reference in new issue