Merge branch 'refs/heads/develop' into tv
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.event import addEvent, fireEvent
|
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
|
||||||
@@ -11,8 +11,6 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class CategoryPlugin(Plugin):
|
class CategoryPlugin(Plugin):
|
||||||
|
|
||||||
to_dict = {'destination': {}}
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('category.all', self.all)
|
addEvent('category.all', self.all)
|
||||||
|
|
||||||
@@ -41,7 +39,7 @@ class CategoryPlugin(Plugin):
|
|||||||
|
|
||||||
temp = []
|
temp = []
|
||||||
for category in categories:
|
for category in categories:
|
||||||
temp.append(category.to_dict(self.to_dict))
|
temp.append(category.to_dict())
|
||||||
|
|
||||||
db.expire_all()
|
db.expire_all()
|
||||||
return temp
|
return temp
|
||||||
@@ -61,10 +59,11 @@ class CategoryPlugin(Plugin):
|
|||||||
c.ignored = toUnicode(kwargs.get('ignored'))
|
c.ignored = toUnicode(kwargs.get('ignored'))
|
||||||
c.preferred = toUnicode(kwargs.get('preferred'))
|
c.preferred = toUnicode(kwargs.get('preferred'))
|
||||||
c.required = toUnicode(kwargs.get('required'))
|
c.required = toUnicode(kwargs.get('required'))
|
||||||
|
c.destination = toUnicode(kwargs.get('destination'))
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
category_dict = c.to_dict(self.to_dict)
|
category_dict = c.to_dict()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'success': True,
|
'success': True,
|
||||||
|
|||||||
@@ -33,6 +33,28 @@ var CategoryListBase = new Class({
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Add categories in renamer
|
||||||
|
self.settings.addEvent('create', function(){
|
||||||
|
var renamer_group = self.settings.tabs.renamer.groups.renamer;
|
||||||
|
|
||||||
|
p(renamer_group.getElement('.renamer_to'))
|
||||||
|
self.categories.each(function(category){
|
||||||
|
|
||||||
|
var input = new Option.Directory('section_name', 'option.name', category.get('destination'), {
|
||||||
|
'name': category.get('label')
|
||||||
|
});
|
||||||
|
input.inject(renamer_group.getElement('.renamer_to'));
|
||||||
|
input.fireEvent('injected');
|
||||||
|
|
||||||
|
input.save = function(){
|
||||||
|
category.data.destination = input.getValue();
|
||||||
|
category.save();
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
createList: function(){
|
createList: function(){
|
||||||
@@ -229,7 +251,7 @@ var Category = new Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}).delay(delay, self)
|
}).delay(delay || 0, self)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -241,7 +263,8 @@ var Category = new Class({
|
|||||||
'label' : self.el.getElement('.category_label input').get('value'),
|
'label' : self.el.getElement('.category_label input').get('value'),
|
||||||
'required' : self.el.getElement('.category_required input').get('value'),
|
'required' : self.el.getElement('.category_required input').get('value'),
|
||||||
'preferred' : self.el.getElement('.category_preferred input').get('value'),
|
'preferred' : self.el.getElement('.category_preferred input').get('value'),
|
||||||
'ignored' : self.el.getElement('.category_ignored input').get('value')
|
'ignored' : self.el.getElement('.category_ignored input').get('value'),
|
||||||
|
'destination': self.data.destination
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ class MoviePlugin(Plugin):
|
|||||||
fireEvent('status.get', ['active', 'snatched', 'ignored', 'done', 'downloaded'], single = True)
|
fireEvent('status.get', ['active', 'snatched', 'ignored', 'done', 'downloaded'], single = True)
|
||||||
|
|
||||||
default_profile = fireEvent('profile.default', single = True)
|
default_profile = fireEvent('profile.default', single = True)
|
||||||
|
cat_id = params.get('category_id', None)
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
m = db.query(Movie).filter_by(library_id = library.get('id')).first()
|
m = db.query(Movie).filter_by(library_id = library.get('id')).first()
|
||||||
@@ -376,6 +377,7 @@ class MoviePlugin(Plugin):
|
|||||||
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'),
|
||||||
|
category_id = tryInt(cat_id) if cat_id is not None and tryInt(cat_id) > 0 else None,
|
||||||
)
|
)
|
||||||
db.add(m)
|
db.add(m)
|
||||||
db.commit()
|
db.commit()
|
||||||
@@ -397,6 +399,7 @@ class MoviePlugin(Plugin):
|
|||||||
fireEvent('release.delete', release.id, single = True)
|
fireEvent('release.delete', release.id, single = True)
|
||||||
|
|
||||||
m.profile_id = params.get('profile_id', default_profile.get('id'))
|
m.profile_id = params.get('profile_id', default_profile.get('id'))
|
||||||
|
m.category_id = tryInt(cat_id) if cat_id is not None and tryInt(cat_id) > 0 else None
|
||||||
else:
|
else:
|
||||||
log.debug('Movie already exists, not updating: %s', params)
|
log.debug('Movie already exists, not updating: %s', params)
|
||||||
added = False
|
added = False
|
||||||
|
|||||||
@@ -159,8 +159,9 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
.movie_result .options select[name=title] { width: 180px; }
|
.movie_result .options select[name=title] { width: 170px; }
|
||||||
.movie_result .options select[name=profile] { width: 90px; }
|
.movie_result .options select[name=profile] { width: 90px; }
|
||||||
|
.movie_result .options select[name=category] { width: 80px; }
|
||||||
|
|
||||||
@media all and (max-width: 480px) {
|
@media all and (max-width: 480px) {
|
||||||
|
|
||||||
|
|||||||
@@ -389,7 +389,6 @@ Block.Search.Item = new Class({
|
|||||||
|
|
||||||
self.options_el.addClass('set');
|
self.options_el.addClass('set');
|
||||||
|
|
||||||
p(self.info.in_wanted, self.info.in_wanted.profile, in_library);
|
|
||||||
if(categories.length == 0 && self.title_select.getElements('option').length == 1 && profiles.length == 1 &&
|
if(categories.length == 0 && self.title_select.getElements('option').length == 1 && profiles.length == 1 &&
|
||||||
!(self.info.in_wanted && self.info.in_wanted.profile || in_library))
|
!(self.info.in_wanted && self.info.in_wanted.profile || in_library))
|
||||||
self.add();
|
self.add();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ config = [{
|
|||||||
{
|
{
|
||||||
'name': 'to',
|
'name': 'to',
|
||||||
'type': 'directory',
|
'type': 'directory',
|
||||||
'description': 'Folder where the movies should be moved to.',
|
'description': 'Default folder where the movies are moved to.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'folder_name',
|
'name': 'folder_name',
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ class Renamer(Plugin):
|
|||||||
groups = fireEvent('scanner.scan', folder = folder if folder else self.conf('from'),
|
groups = fireEvent('scanner.scan', folder = folder if folder else self.conf('from'),
|
||||||
files = files, download_info = download_info, return_ignored = False, single = True)
|
files = files, download_info = download_info, return_ignored = False, single = True)
|
||||||
|
|
||||||
destination = self.conf('to')
|
|
||||||
folder_name = self.conf('folder_name')
|
folder_name = self.conf('folder_name')
|
||||||
file_name = self.conf('file_name')
|
file_name = self.conf('file_name')
|
||||||
trailer_name = self.conf('trailer_name')
|
trailer_name = self.conf('trailer_name')
|
||||||
@@ -148,10 +147,6 @@ class Renamer(Plugin):
|
|||||||
remove_releases = []
|
remove_releases = []
|
||||||
|
|
||||||
movie_title = getTitle(group['library'])
|
movie_title = getTitle(group['library'])
|
||||||
try:
|
|
||||||
destination = group['category']['path']
|
|
||||||
except:
|
|
||||||
destination = self.conf('to')
|
|
||||||
|
|
||||||
# Add _UNKNOWN_ if no library item is connected
|
# Add _UNKNOWN_ if no library item is connected
|
||||||
if not group['library'] or not movie_title:
|
if not group['library'] or not movie_title:
|
||||||
@@ -165,8 +160,21 @@ class Renamer(Plugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
library = group['library']
|
library = group['library']
|
||||||
|
library_ent = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
||||||
|
|
||||||
movie_title = getTitle(library)
|
movie_title = getTitle(library)
|
||||||
|
|
||||||
|
# Overwrite destination when set in category
|
||||||
|
destination = self.conf('to')
|
||||||
|
for movie in library_ent.movies:
|
||||||
|
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))
|
||||||
|
else:
|
||||||
|
log.debug('No category destination found for "%s"' % movie_title)
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
# Find subtitle for renaming
|
# Find subtitle for renaming
|
||||||
group['before_rename'] = []
|
group['before_rename'] = []
|
||||||
fireEvent('renamer.before', group)
|
fireEvent('renamer.before', group)
|
||||||
@@ -319,17 +327,16 @@ class Renamer(Plugin):
|
|||||||
cd += 1
|
cd += 1
|
||||||
|
|
||||||
# Before renaming, remove the lower quality files
|
# Before renaming, remove the lower quality files
|
||||||
library = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
|
||||||
remove_leftovers = True
|
remove_leftovers = True
|
||||||
|
|
||||||
# Add it to the wanted list before we continue
|
# Add it to the wanted list before we continue
|
||||||
if len(library.movies) == 0:
|
if len(library_ent.movies) == 0:
|
||||||
profile = db.query(Profile).filter_by(core = True, label = group['meta_data']['quality']['label']).first()
|
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)
|
fireEvent('movie.add', params = {'identifier': group['library']['identifier'], 'profile_id': profile.id}, search_after = False)
|
||||||
db.expire_all()
|
db.expire_all()
|
||||||
library = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
library = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
||||||
|
|
||||||
for movie in library.movies:
|
for movie in library_ent.movies:
|
||||||
|
|
||||||
# Mark movie "done" once it's found the quality with the finish check
|
# Mark movie "done" once it's found the quality with the finish check
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ config = [{
|
|||||||
'name': 'preferred_words',
|
'name': 'preferred_words',
|
||||||
'label': 'Preferred',
|
'label': 'Preferred',
|
||||||
'default': '',
|
'default': '',
|
||||||
|
'placeholder': 'Example: CtrlHD, Amiable, Wiki',
|
||||||
'description': 'Words that give the releases a higher score.'
|
'description': 'Words that give the releases a higher score.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -216,17 +216,9 @@ class Category(Entity):
|
|||||||
required = Field(Unicode(255))
|
required = Field(Unicode(255))
|
||||||
preferred = Field(Unicode(255))
|
preferred = Field(Unicode(255))
|
||||||
ignored = Field(Unicode(255))
|
ignored = Field(Unicode(255))
|
||||||
|
destination = Field(Unicode(255))
|
||||||
|
|
||||||
movie = OneToMany('Movie')
|
movie = OneToMany('Movie')
|
||||||
destination = ManyToOne('Destination')
|
|
||||||
|
|
||||||
|
|
||||||
class Destination(Entity):
|
|
||||||
""""""
|
|
||||||
|
|
||||||
path = Field(Unicode(255))
|
|
||||||
|
|
||||||
category = OneToMany('Category')
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileType(Entity):
|
class ProfileType(Entity):
|
||||||
|
|||||||
@@ -329,8 +329,8 @@ var OptionBase = new Class({
|
|||||||
* Create the element
|
* Create the element
|
||||||
*/
|
*/
|
||||||
createBase: function(){
|
createBase: function(){
|
||||||
var self = this
|
var self = this;
|
||||||
self.el = new Element('div.ctrlHolder')
|
self.el = new Element('div.ctrlHolder.'+self.section + '_' + self.name)
|
||||||
},
|
},
|
||||||
|
|
||||||
create: function(){},
|
create: function(){},
|
||||||
|
|||||||
Reference in New Issue
Block a user