Notify when adding movie already in wanted or library
This commit is contained in:
@@ -126,6 +126,11 @@
|
||||
}
|
||||
|
||||
.movie_result:last-child .data { border-bottom: 0; }
|
||||
|
||||
.movie_result .in_wanted, .movie_result .in_library {
|
||||
position: absolute;
|
||||
margin-top: 105px;
|
||||
}
|
||||
|
||||
.movie_result .thumbnail {
|
||||
width: 17%;
|
||||
|
||||
@@ -291,6 +291,12 @@ Block.Search.Item = new Class({
|
||||
self.info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
||||
'src': self.info.images.poster[0]
|
||||
}) : null,
|
||||
self.info.in_wanted ? new Element('span.in_wanted', {
|
||||
'text': 'Already in wanted list: ' + self.info.in_wanted.label
|
||||
}) : null,
|
||||
self.info.in_library ? new Element('span.in_library', {
|
||||
'text': 'Already in library: ' + self.info.in_library.label
|
||||
}) : null,
|
||||
self.title_select = new Element('select', {
|
||||
'name': 'title'
|
||||
}),
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato import get_session
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.helpers.variable import mergeDicts
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import Library
|
||||
import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class MovieResultModifier(Plugin):
|
||||
@@ -8,12 +14,15 @@ class MovieResultModifier(Plugin):
|
||||
def __init__(self):
|
||||
addEvent('result.modify.movie.search', self.combineOnIMDB)
|
||||
|
||||
|
||||
def combineOnIMDB(self, results):
|
||||
|
||||
temp = {}
|
||||
unique = 1
|
||||
|
||||
# Statuses
|
||||
active_status = fireEvent('status.get', 'active', single = True)
|
||||
done_status = fireEvent('status.get', 'done', single = True)
|
||||
|
||||
# Combine on imdb id
|
||||
for item in results:
|
||||
imdb = item.get('imdb')
|
||||
@@ -21,6 +30,24 @@ class MovieResultModifier(Plugin):
|
||||
if not temp.get(imdb):
|
||||
temp[imdb] = {}
|
||||
|
||||
temp[imdb]['in_wanted'] = False
|
||||
temp[imdb]['in_library'] = False
|
||||
|
||||
# Add release info from current library
|
||||
try:
|
||||
db = get_session()
|
||||
l = db.query(Library).filter_by(identifier = imdb).first()
|
||||
if l:
|
||||
for movie in l.movies:
|
||||
if movie.status_id == active_status['id']:
|
||||
temp[imdb]['in_wanted'] = movie.profile.to_dict()
|
||||
|
||||
for release in movie.releases:
|
||||
if release.status_id == done_status['id']:
|
||||
temp[imdb]['in_library'] = release.quality.to_dict()
|
||||
except:
|
||||
log.error('Tried getting more info on searched movies: %s' % traceback.format_exc())
|
||||
|
||||
# Merge dicts
|
||||
temp[imdb] = mergeDicts(temp[imdb], item)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user