|
|
@ -1,8 +1,9 @@ |
|
|
|
from couchpotato import get_session |
|
|
|
from couchpotato.api import addApiView |
|
|
|
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent |
|
|
|
from couchpotato.core.helpers.encoding import toUnicode |
|
|
|
from couchpotato.core.helpers.request import getParams, jsonified |
|
|
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ |
|
|
|
simplifyString |
|
|
|
from couchpotato.core.helpers.request import getParams, jsonified, getParam |
|
|
|
from couchpotato.core.logger import CPLog |
|
|
|
from couchpotato.core.plugins.base import Plugin |
|
|
|
from couchpotato.core.settings.model import Movie, Library, LibraryTitle |
|
|
@ -10,7 +11,6 @@ from couchpotato.environment import Env |
|
|
|
from sqlalchemy.orm import joinedload_all |
|
|
|
from sqlalchemy.sql.expression import or_, asc, not_ |
|
|
|
from string import ascii_lowercase |
|
|
|
from urllib import urlencode |
|
|
|
|
|
|
|
log = CPLog(__name__) |
|
|
|
|
|
|
@ -225,7 +225,6 @@ class MoviePlugin(Plugin): |
|
|
|
if title.default: default_title = title.title |
|
|
|
|
|
|
|
if movie: |
|
|
|
#addEvent('library.update.after', ) |
|
|
|
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True) |
|
|
|
fireEventAsync('searcher.single', movie.to_dict(self.default_dict)) |
|
|
|
|
|
|
@ -235,12 +234,12 @@ class MoviePlugin(Plugin): |
|
|
|
|
|
|
|
def search(self): |
|
|
|
|
|
|
|
params = getParams() |
|
|
|
cache_key = '%s/%s' % (__name__, urlencode(params)) |
|
|
|
q = getParam('q') |
|
|
|
cache_key = u'%s/%s' % (__name__, simplifyString(q)) |
|
|
|
movies = Env.get('cache').get(cache_key) |
|
|
|
|
|
|
|
if not movies: |
|
|
|
movies = fireEvent('movie.search', q = params.get('q'), merge = True) |
|
|
|
movies = fireEvent('movie.search', q = q, merge = True) |
|
|
|
Env.get('cache').set(cache_key, movies) |
|
|
|
|
|
|
|
return jsonified({ |
|
|
@ -335,7 +334,7 @@ class MoviePlugin(Plugin): |
|
|
|
# Default title |
|
|
|
if params.get('default_title'): |
|
|
|
for title in m.library.titles: |
|
|
|
title.default = params.get('default_title').lower() == title.title.lower() |
|
|
|
title.default = toUnicode(params.get('default_title', '')).lower() == toUnicode(title.title).lower() |
|
|
|
|
|
|
|
db.commit() |
|
|
|
|
|
|
|