refactored Movie model to Media
This commit is contained in:
@@ -4,7 +4,7 @@ from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.logger import CPLog
|
||||
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__)
|
||||
|
||||
@@ -114,7 +114,7 @@ class CategoryPlugin(Plugin):
|
||||
def removeFromMovie(self, category_id):
|
||||
|
||||
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:
|
||||
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.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import Movie
|
||||
from couchpotato.core.settings.model import Media
|
||||
from sqlalchemy.orm import joinedload_all
|
||||
import random as rndm
|
||||
import time
|
||||
@@ -42,9 +42,9 @@ class Dashboard(Plugin):
|
||||
|
||||
# Get all active movies
|
||||
active_status, snatched_status, downloaded_status, available_status = fireEvent('status.get', ['active', 'snatched', 'downloaded', 'available'], single = True)
|
||||
subq = db.query(Movie).filter(Movie.status_id == active_status.get('id')).subquery()
|
||||
subq = db.query(Media).filter(Media.status_id == active_status.get('id')).subquery()
|
||||
|
||||
q = db.query(Movie).join((subq, subq.c.id == Movie.id)) \
|
||||
q = db.query(Media).join((subq, subq.c.id == Media.id)) \
|
||||
.options(joinedload_all('releases')) \
|
||||
.options(joinedload_all('profile')) \
|
||||
.options(joinedload_all('library.titles')) \
|
||||
|
||||
@@ -4,7 +4,7 @@ from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.logger import CPLog
|
||||
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
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -37,7 +37,7 @@ class ProfilePlugin(Plugin):
|
||||
active_status = fireEvent('status.get', 'active', single = True)
|
||||
|
||||
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:
|
||||
default_profile = self.default()
|
||||
|
||||
@@ -5,7 +5,7 @@ from couchpotato.core.helpers.encoding import ss
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
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.sql.expression import and_, or_
|
||||
import os
|
||||
|
||||
@@ -49,9 +49,9 @@ class Release(Plugin):
|
||||
done_status, snatched_status = fireEvent('status.get', ['done', 'snatched'], single = True)
|
||||
|
||||
# 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:
|
||||
movie = Movie(
|
||||
movie = Media(
|
||||
library_id = group['library'].get('id'),
|
||||
profile_id = 0,
|
||||
status_id = done_status.get('id')
|
||||
|
||||
@@ -166,7 +166,7 @@ class Renamer(Plugin):
|
||||
|
||||
# Overwrite destination when set in category
|
||||
destination = self.conf('to')
|
||||
for movie in library_ent.movies:
|
||||
for movie in library_ent.media:
|
||||
if movie.category and movie.category.destination and len(movie.category.destination) > 0:
|
||||
destination = movie.category.destination
|
||||
log.debug('Setting category destination for "%s": %s' % (movie_title, destination))
|
||||
@@ -330,13 +330,13 @@ class Renamer(Plugin):
|
||||
remove_leftovers = True
|
||||
|
||||
# Add it to the wanted list before we continue
|
||||
if len(library_ent.movies) == 0:
|
||||
if len(library_ent.media) == 0:
|
||||
profile = db.query(Profile).filter_by(core = True, label = group['meta_data']['quality']['label']).first()
|
||||
fireEvent('movie.add', params = {'identifier': group['library']['identifier'], 'profile_id': profile.id}, search_after = False)
|
||||
db.expire_all()
|
||||
library = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
||||
|
||||
for movie in library_ent.movies:
|
||||
for movie in library_ent.media:
|
||||
|
||||
# Mark movie "done" once it's found the quality with the finish check
|
||||
try:
|
||||
|
||||
@@ -4,7 +4,7 @@ from couchpotato.core.helpers.encoding import toUnicode, simplifyString, ss
|
||||
from couchpotato.core.helpers.variable import getExt, getImdb, tryInt
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import File, Movie
|
||||
from couchpotato.core.settings.model import File, Media
|
||||
from enzyme.exceptions import NoParserError, ParseError
|
||||
from guessit import guess_movie_info
|
||||
from subliminal.videos import Video
|
||||
@@ -404,7 +404,7 @@ class Scanner(Plugin):
|
||||
if not group['library']:
|
||||
log.error('Unable to determine movie: %s', group['identifiers'])
|
||||
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
|
||||
|
||||
processed_movies[identifier] = group
|
||||
|
||||
@@ -27,7 +27,7 @@ class Subtitle(Plugin):
|
||||
library = db.query(Library).all()
|
||||
done_status = fireEvent('status.get', 'done', single = True)
|
||||
|
||||
for movie in library.movies:
|
||||
for movie in library.media:
|
||||
|
||||
for release in movie.releases:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.helpers.encoding import ss
|
||||
from couchpotato.core.helpers.variable import splitString, md5
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import Movie
|
||||
from couchpotato.core.settings.model import Media
|
||||
from couchpotato.environment import Env
|
||||
from sqlalchemy.sql.expression import or_
|
||||
|
||||
@@ -23,8 +23,8 @@ class Suggestion(Plugin):
|
||||
|
||||
if not movies or len(movies) == 0:
|
||||
db = get_session()
|
||||
active_movies = db.query(Movie) \
|
||||
.filter(or_(*[Movie.status.has(identifier = s) for s in ['active', 'done']])).all()
|
||||
active_movies = db.query(Media) \
|
||||
.filter(or_(*[Media.status.has(identifier = s) for s in ['active', 'done']])).all()
|
||||
movies = [x.library.identifier for x in active_movies]
|
||||
|
||||
if not ignored or len(ignored) == 0:
|
||||
@@ -76,8 +76,8 @@ class Suggestion(Plugin):
|
||||
if len(new_suggestions) - 1 < limit:
|
||||
|
||||
db = get_session()
|
||||
active_movies = db.query(Movie) \
|
||||
.filter(or_(*[Movie.status.has(identifier = s) for s in ['active', 'done']])).all()
|
||||
active_movies = db.query(Media) \
|
||||
.filter(or_(*[Media.status.has(identifier = s) for s in ['active', 'done']])).all()
|
||||
movies = [x.library.identifier for x in active_movies]
|
||||
|
||||
ignored.extend([x.get('imdb') for x in cached_suggestion])
|
||||
|
||||
Reference in New Issue
Block a user