Use Media for all Movie db actions
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie
|
from couchpotato.core.settings.model import Media
|
||||||
|
|
||||||
|
|
||||||
class MediaBase(Plugin):
|
class MediaBase(Plugin):
|
||||||
@@ -27,7 +27,7 @@ class MediaBase(Plugin):
|
|||||||
|
|
||||||
def onComplete():
|
def onComplete():
|
||||||
db = get_session()
|
db = get_session()
|
||||||
media = db.query(Movie).filter_by(id = id).first()
|
media = db.query(Media).filter_by(id = id).first()
|
||||||
fireEventAsync('%s.searcher.single' % media.type, media.to_dict(self.default_dict), on_complete = self.createNotifyFront(id))
|
fireEventAsync('%s.searcher.single' % media.type, media.to_dict(self.default_dict), on_complete = self.createNotifyFront(id))
|
||||||
db.expire_all()
|
db.expire_all()
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ class MediaBase(Plugin):
|
|||||||
|
|
||||||
def notifyFront():
|
def notifyFront():
|
||||||
db = get_session()
|
db = get_session()
|
||||||
media = db.query(Movie).filter_by(id = media_id).first()
|
media = db.query(Media).filter_by(id = media_id).first()
|
||||||
fireEvent('notify.frontend', type = '%s.update.%s' % (media.type, media.id), data = media.to_dict(self.default_dict))
|
fireEvent('notify.frontend', type = '%s.update.%s' % (media.type, media.id), data = media.to_dict(self.default_dict))
|
||||||
db.expire_all()
|
db.expire_all()
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
|||||||
from couchpotato.core.helpers.variable import splitString
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.media import MediaBase
|
from couchpotato.core.media import MediaBase
|
||||||
from couchpotato.core.settings.model import Movie
|
from couchpotato.core.settings.model import Media
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ class MediaPlugin(MediaBase):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
for x in splitString(id):
|
for x in splitString(id):
|
||||||
media = db.query(Movie).filter_by(id = x).first()
|
media = db.query(Media).filter_by(id = x).first()
|
||||||
|
|
||||||
if media:
|
if media:
|
||||||
# Get current selected title
|
# Get current selected title
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from couchpotato.core.helpers.encoding import simplifyString, toUnicode
|
|||||||
from couchpotato.core.helpers.variable import md5, getTitle
|
from couchpotato.core.helpers.variable import md5, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.media._base.searcher.base import SearcherBase
|
from couchpotato.core.media._base.searcher.base import SearcherBase
|
||||||
from couchpotato.core.settings.model import Movie, Release, ReleaseInfo
|
from couchpotato.core.settings.model import Media, Release, ReleaseInfo
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from inspect import ismethod, isfunction
|
from inspect import ismethod, isfunction
|
||||||
import datetime
|
import datetime
|
||||||
@@ -104,7 +104,7 @@ class Searcher(SearcherBase):
|
|||||||
if profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
|
if profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
|
||||||
# Mark movie done
|
# Mark movie done
|
||||||
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
|
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
|
||||||
mvie = db.query(Movie).filter_by(id = movie['id']).first()
|
mvie = db.query(Media).filter_by(id = movie['id']).first()
|
||||||
mvie.status_id = done_status.get('id')
|
mvie.status_id = done_status.get('id')
|
||||||
mvie.last_edit = int(time.time())
|
mvie.last_edit = int(time.time())
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from couchpotato.core.helpers.variable import getImdb, splitString, tryInt, \
|
|||||||
mergeDicts
|
mergeDicts
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.media.movie import MovieTypeBase
|
from couchpotato.core.media.movie import MovieTypeBase
|
||||||
from couchpotato.core.settings.model import Library, LibraryTitle, Movie, \
|
from couchpotato.core.settings.model import Library, LibraryTitle, Media, \
|
||||||
Release
|
Release
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
@@ -96,8 +96,8 @@ class MovieBase(MovieTypeBase):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
# get movies last_edit more than a week ago
|
# get movies last_edit more than a week ago
|
||||||
movies = db.query(Movie) \
|
movies = db.query(Media) \
|
||||||
.filter(Movie.status_id == done_status.get('id'), Movie.last_edit < (now - week)) \
|
.filter(Media.status_id == done_status.get('id'), Media.last_edit < (now - week)) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
@@ -123,9 +123,9 @@ class MovieBase(MovieTypeBase):
|
|||||||
imdb_id = getImdb(str(movie_id))
|
imdb_id = getImdb(str(movie_id))
|
||||||
|
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
m = db.query(Movie).filter(Movie.library.has(identifier = imdb_id)).first()
|
m = db.query(Media).filter(Media.library.has(identifier = imdb_id)).first()
|
||||||
else:
|
else:
|
||||||
m = db.query(Movie).filter_by(id = movie_id).first()
|
m = db.query(Media).filter_by(id = movie_id).first()
|
||||||
|
|
||||||
results = None
|
results = None
|
||||||
if m:
|
if m:
|
||||||
@@ -145,20 +145,20 @@ class MovieBase(MovieTypeBase):
|
|||||||
release_status = [release_status]
|
release_status = [release_status]
|
||||||
|
|
||||||
# query movie ids
|
# query movie ids
|
||||||
q = db.query(Movie) \
|
q = db.query(Media) \
|
||||||
.with_entities(Movie.id) \
|
.with_entities(Media.id) \
|
||||||
.group_by(Movie.id)
|
.group_by(Media.id)
|
||||||
|
|
||||||
# Filter on movie status
|
# Filter on movie status
|
||||||
if status and len(status) > 0:
|
if status and len(status) > 0:
|
||||||
statuses = fireEvent('status.get', status, single = len(status) > 1)
|
statuses = fireEvent('status.get', status, single = len(status) > 1)
|
||||||
statuses = [s.get('id') for s in statuses]
|
statuses = [s.get('id') for s in statuses]
|
||||||
|
|
||||||
q = q.filter(Movie.status_id.in_(statuses))
|
q = q.filter(Media.status_id.in_(statuses))
|
||||||
|
|
||||||
# Filter on release status
|
# Filter on release status
|
||||||
if release_status and len(release_status) > 0:
|
if release_status and len(release_status) > 0:
|
||||||
q = q.join(Movie.releases)
|
q = q.join(Media.releases)
|
||||||
|
|
||||||
statuses = fireEvent('status.get', release_status, single = len(release_status) > 1)
|
statuses = fireEvent('status.get', release_status, single = len(release_status) > 1)
|
||||||
statuses = [s.get('id') for s in statuses]
|
statuses = [s.get('id') for s in statuses]
|
||||||
@@ -167,7 +167,7 @@ class MovieBase(MovieTypeBase):
|
|||||||
|
|
||||||
# Only join when searching / ordering
|
# Only join when searching / ordering
|
||||||
if starts_with or search or order != 'release_order':
|
if starts_with or search or order != 'release_order':
|
||||||
q = q.join(Movie.library, Library.titles) \
|
q = q.join(Media.library, Library.titles) \
|
||||||
.filter(LibraryTitle.default == True)
|
.filter(LibraryTitle.default == True)
|
||||||
|
|
||||||
# Add search filters
|
# Add search filters
|
||||||
@@ -218,13 +218,13 @@ class MovieBase(MovieTypeBase):
|
|||||||
releases_count[release.movie_id] += 1
|
releases_count[release.movie_id] += 1
|
||||||
|
|
||||||
# Get main movie data
|
# Get main movie data
|
||||||
q2 = db.query(Movie) \
|
q2 = db.query(Media) \
|
||||||
.options(joinedload_all('library.titles')) \
|
.options(joinedload_all('library.titles')) \
|
||||||
.options(joinedload_all('library.files')) \
|
.options(joinedload_all('library.files')) \
|
||||||
.options(joinedload_all('status')) \
|
.options(joinedload_all('status')) \
|
||||||
.options(joinedload_all('files'))
|
.options(joinedload_all('files'))
|
||||||
|
|
||||||
q2 = q2.filter(Movie.id.in_(movie_ids))
|
q2 = q2.filter(Media.id.in_(movie_ids))
|
||||||
|
|
||||||
results = q2.all()
|
results = q2.all()
|
||||||
|
|
||||||
@@ -267,14 +267,14 @@ class MovieBase(MovieTypeBase):
|
|||||||
if release_status and not isinstance(release_status, (list, tuple)):
|
if release_status and not isinstance(release_status, (list, tuple)):
|
||||||
release_status = [release_status]
|
release_status = [release_status]
|
||||||
|
|
||||||
q = db.query(Movie)
|
q = db.query(Media)
|
||||||
|
|
||||||
# Filter on movie status
|
# Filter on movie status
|
||||||
if status and len(status) > 0:
|
if status and len(status) > 0:
|
||||||
statuses = fireEvent('status.get', status, single = len(release_status) > 1)
|
statuses = fireEvent('status.get', status, single = len(release_status) > 1)
|
||||||
statuses = [s.get('id') for s in statuses]
|
statuses = [s.get('id') for s in statuses]
|
||||||
|
|
||||||
q = q.filter(Movie.status_id.in_(statuses))
|
q = q.filter(Media.status_id.in_(statuses))
|
||||||
|
|
||||||
# Filter on release status
|
# Filter on release status
|
||||||
if release_status and len(release_status) > 0:
|
if release_status and len(release_status) > 0:
|
||||||
@@ -282,7 +282,7 @@ class MovieBase(MovieTypeBase):
|
|||||||
statuses = fireEvent('status.get', release_status, single = len(release_status) > 1)
|
statuses = fireEvent('status.get', release_status, single = len(release_status) > 1)
|
||||||
statuses = [s.get('id') for s in statuses]
|
statuses = [s.get('id') for s in statuses]
|
||||||
|
|
||||||
q = q.join(Movie.releases) \
|
q = q.join(Media.releases) \
|
||||||
.filter(Release.status_id.in_(statuses))
|
.filter(Release.status_id.in_(statuses))
|
||||||
|
|
||||||
q = q.join(Library, LibraryTitle) \
|
q = q.join(Library, LibraryTitle) \
|
||||||
@@ -392,12 +392,12 @@ class MovieBase(MovieTypeBase):
|
|||||||
cat_id = params.get('category_id')
|
cat_id = params.get('category_id')
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
m = db.query(Movie).filter_by(library_id = library.get('id')).first()
|
m = db.query(Media).filter_by(library_id = library.get('id')).first()
|
||||||
added = True
|
added = True
|
||||||
do_search = False
|
do_search = False
|
||||||
search_after = search_after and self.conf('search_on_add', section = 'moviesearcher')
|
search_after = search_after and self.conf('search_on_add', section = 'moviesearcher')
|
||||||
if not m:
|
if not m:
|
||||||
m = Movie(
|
m = Media(
|
||||||
library_id = library.get('id'),
|
library_id = library.get('id'),
|
||||||
profile_id = params.get('profile_id', default_profile.get('id')),
|
profile_id = params.get('profile_id', default_profile.get('id')),
|
||||||
status_id = status_id if status_id else status_active.get('id'),
|
status_id = status_id if status_id else status_active.get('id'),
|
||||||
@@ -471,7 +471,7 @@ class MovieBase(MovieTypeBase):
|
|||||||
ids = splitString(id)
|
ids = splitString(id)
|
||||||
for movie_id in ids:
|
for movie_id in ids:
|
||||||
|
|
||||||
m = db.query(Movie).filter_by(id = movie_id).first()
|
m = db.query(Media).filter_by(id = movie_id).first()
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -518,7 +518,7 @@ class MovieBase(MovieTypeBase):
|
|||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
movie = db.query(Movie).filter_by(id = movie_id).first()
|
movie = db.query(Media).filter_by(id = movie_id).first()
|
||||||
if movie:
|
if movie:
|
||||||
deleted = False
|
deleted = False
|
||||||
if delete_from == 'all':
|
if delete_from == 'all':
|
||||||
@@ -568,7 +568,7 @@ class MovieBase(MovieTypeBase):
|
|||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
m = db.query(Movie).filter_by(id = movie_id).first()
|
m = db.query(Media).filter_by(id = movie_id).first()
|
||||||
if not m or len(m.library.titles) == 0:
|
if not m or len(m.library.titles) == 0:
|
||||||
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from couchpotato.core.helpers.variable import md5, getTitle, splitString, \
|
|||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.media._base.searcher.base import SearcherBase
|
from couchpotato.core.media._base.searcher.base import SearcherBase
|
||||||
from couchpotato.core.media.movie import MovieTypeBase
|
from couchpotato.core.media.movie import MovieTypeBase
|
||||||
from couchpotato.core.settings.model import Movie, Release, ReleaseInfo
|
from couchpotato.core.settings.model import Media, Release, ReleaseInfo
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from sqlalchemy.exc import InterfaceError
|
from sqlalchemy.exc import InterfaceError
|
||||||
@@ -74,8 +74,8 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
movies = db.query(Movie).filter(
|
movies = db.query(Media).filter(
|
||||||
Movie.status.has(identifier = 'active')
|
Media.status.has(identifier = 'active')
|
||||||
).all()
|
).all()
|
||||||
random.shuffle(movies)
|
random.shuffle(movies)
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
sorted_results = sorted(sorted_results, key = lambda k: k['protocol'][:3], reverse = (download_preference == 'torrent'))
|
sorted_results = sorted(sorted_results, key = lambda k: k['protocol'][:3], reverse = (download_preference == 'torrent'))
|
||||||
|
|
||||||
# Check if movie isn't deleted while searching
|
# Check if movie isn't deleted while searching
|
||||||
if not db.query(Movie).filter_by(id = movie.get('id')).first():
|
if not db.query(Media).filter_by(id = movie.get('id')).first():
|
||||||
break
|
break
|
||||||
|
|
||||||
# Add them to this movie releases list
|
# Add them to this movie releases list
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.api import addApiView
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.variable import splitString
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie, Library
|
from couchpotato.core.settings.model import Media, Library
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
from sqlalchemy.sql.expression import or_
|
from sqlalchemy.sql.expression import or_
|
||||||
@@ -29,9 +29,9 @@ class Suggestion(Plugin):
|
|||||||
|
|
||||||
if not movies or len(movies) == 0:
|
if not movies or len(movies) == 0:
|
||||||
db = get_session()
|
db = get_session()
|
||||||
active_movies = db.query(Movie) \
|
active_movies = db.query(Media) \
|
||||||
.options(joinedload_all('library')) \
|
.options(joinedload_all('library')) \
|
||||||
.filter(or_(*[Movie.status.has(identifier = s) for s in ['active', 'done']])).all()
|
.filter(or_(*[Media.status.has(identifier = s) for s in ['active', 'done']])).all()
|
||||||
movies = [x.library.identifier for x in active_movies]
|
movies = [x.library.identifier for x in active_movies]
|
||||||
|
|
||||||
if not ignored or len(ignored) == 0:
|
if not ignored or len(ignored) == 0:
|
||||||
@@ -89,10 +89,10 @@ class Suggestion(Plugin):
|
|||||||
active_status, done_status = fireEvent('status.get', ['active', 'done'], single = True)
|
active_status, done_status = fireEvent('status.get', ['active', 'done'], single = True)
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
active_movies = db.query(Movie) \
|
active_movies = db.query(Media) \
|
||||||
.join(Library) \
|
.join(Library) \
|
||||||
.with_entities(Library.identifier) \
|
.with_entities(Library.identifier) \
|
||||||
.filter(Movie.status_id.in_([active_status.get('id'), done_status.get('id')])).all()
|
.filter(Media.status_id.in_([active_status.get('id'), done_status.get('id')])).all()
|
||||||
movies = [x[0] for x in active_movies]
|
movies = [x[0] for x in active_movies]
|
||||||
movies.extend(seen)
|
movies.extend(seen)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from couchpotato.core.event import addEvent
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie, Category
|
from couchpotato.core.settings.model import Media, Category
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ class CategoryPlugin(Plugin):
|
|||||||
def removeFromMovie(self, category_id):
|
def removeFromMovie(self, category_id):
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
movies = db.query(Movie).filter(Movie.category_id == category_id).all()
|
movies = db.query(Media).filter(Media.category_id == category_id).all()
|
||||||
|
|
||||||
if len(movies) > 0:
|
if len(movies) > 0:
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from couchpotato.core.event import fireEvent
|
|||||||
from couchpotato.core.helpers.variable import splitString, tryInt
|
from couchpotato.core.helpers.variable import splitString, tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie, Library, LibraryTitle, \
|
from couchpotato.core.settings.model import Media, Library, LibraryTitle, \
|
||||||
Release
|
Release
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
from sqlalchemy.sql.expression import asc, or_
|
from sqlalchemy.sql.expression import asc, or_
|
||||||
@@ -50,12 +50,12 @@ class Dashboard(Plugin):
|
|||||||
|
|
||||||
# Get all active movies
|
# Get all active movies
|
||||||
active_status, ignored_status = fireEvent('status.get', ['active', 'ignored'], single = True)
|
active_status, ignored_status = fireEvent('status.get', ['active', 'ignored'], single = True)
|
||||||
q = db.query(Movie) \
|
q = db.query(Media) \
|
||||||
.join(Library) \
|
.join(Library) \
|
||||||
.outerjoin(Movie.releases) \
|
.outerjoin(Media.releases) \
|
||||||
.filter(Movie.status_id == active_status.get('id')) \
|
.filter(Media.status_id == active_status.get('id')) \
|
||||||
.with_entities(Movie.id, Movie.profile_id, Library.info, Library.year) \
|
.with_entities(Media.id, Media.profile_id, Library.info, Library.year) \
|
||||||
.group_by(Movie.id) \
|
.group_by(Media.id) \
|
||||||
.filter(or_(Release.id == None, Release.status_id == ignored_status.get('id')))
|
.filter(or_(Release.id == None, Release.status_id == ignored_status.get('id')))
|
||||||
|
|
||||||
if not random:
|
if not random:
|
||||||
@@ -101,11 +101,11 @@ class Dashboard(Plugin):
|
|||||||
if len(movie_ids) > 0:
|
if len(movie_ids) > 0:
|
||||||
|
|
||||||
# Get all movie information
|
# Get all movie information
|
||||||
movies_raw = db.query(Movie) \
|
movies_raw = db.query(Media) \
|
||||||
.options(joinedload_all('library.titles')) \
|
.options(joinedload_all('library.titles')) \
|
||||||
.options(joinedload_all('library.files')) \
|
.options(joinedload_all('library.files')) \
|
||||||
.options(joinedload_all('files')) \
|
.options(joinedload_all('files')) \
|
||||||
.filter(Movie.id.in_(movie_ids)) \
|
.filter(Media.id.in_(movie_ids)) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
# Create dict by movie id
|
# Create dict by movie id
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from couchpotato.core.event import addEvent, fireEvent
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Profile, ProfileType, Movie
|
from couchpotato.core.settings.model import Profile, ProfileType, Media
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
@@ -38,7 +38,7 @@ class ProfilePlugin(Plugin):
|
|||||||
active_status = fireEvent('status.get', 'active', single = True)
|
active_status = fireEvent('status.get', 'active', single = True)
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
movies = db.query(Movie).filter(Movie.status_id == active_status.get('id'), Movie.profile == None).all()
|
movies = db.query(Media).filter(Media.status_id == active_status.get('id'), Media.profile == None).all()
|
||||||
|
|
||||||
if len(movies) > 0:
|
if len(movies) > 0:
|
||||||
default_profile = self.default()
|
default_profile = self.default()
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ from couchpotato.core.helpers.encoding import ss
|
|||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.plugins.scanner.main import Scanner
|
from couchpotato.core.plugins.scanner.main import Scanner
|
||||||
from couchpotato.core.settings.model import File, Release as Relea, Movie
|
from couchpotato.core.settings.model import File, Release as Relea, Media
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
from sqlalchemy.sql.expression import and_, or_
|
from sqlalchemy.sql.expression import and_, or_
|
||||||
import os
|
import os
|
||||||
import traceback
|
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -60,9 +60,9 @@ class Release(Plugin):
|
|||||||
done_status, snatched_status = fireEvent('status.get', ['done', 'snatched'], single = True)
|
done_status, snatched_status = fireEvent('status.get', ['done', 'snatched'], single = True)
|
||||||
|
|
||||||
# Add movie
|
# Add movie
|
||||||
movie = db.query(Movie).filter_by(library_id = group['library'].get('id')).first()
|
movie = db.query(Media).filter_by(library_id = group['library'].get('id')).first()
|
||||||
if not movie:
|
if not movie:
|
||||||
movie = Movie(
|
movie = Media(
|
||||||
library_id = group['library'].get('id'),
|
library_id = group['library'].get('id'),
|
||||||
profile_id = 0,
|
profile_id = 0,
|
||||||
status_id = done_status.get('id')
|
status_id = done_status.get('id')
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class Scanner(Plugin):
|
|||||||
if not group['library']:
|
if not group['library']:
|
||||||
log.error('Unable to determine movie: %s', group['identifiers'])
|
log.error('Unable to determine movie: %s', group['identifiers'])
|
||||||
else:
|
else:
|
||||||
movie = db.query(Movie).filter_by(library_id = group['library']['id']).first()
|
movie = db.query(Media).filter_by(library_id = group['library']['id']).first()
|
||||||
group['movie_id'] = None if not movie else movie.id
|
group['movie_id'] = None if not movie else movie.id
|
||||||
|
|
||||||
processed_movies[identifier] = group
|
processed_movies[identifier] = group
|
||||||
|
|||||||
Reference in New Issue
Block a user