Fill in profiles & qualities when they are empty. fix #3396
This commit is contained in:
1 parent
17ba9ee96b
commit
7788669de1
2 files changed
+36
-18
No files matched your search
@@ -38,9 +38,18 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
def forceDefaults(self):
|
def forceDefaults(self):
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
|
# Fill qualities and profiles if they are empty somehow..
|
||||||
|
if db.count(db.all, 'profile') == 0:
|
||||||
|
|
||||||
|
if db.count(db.all, 'quality') == 0:
|
||||||
|
fireEvent('quality.fill', single = True)
|
||||||
|
|
||||||
|
self.fill()
|
||||||
|
|
||||||
# Get all active movies without profile
|
# Get all active movies without profile
|
||||||
try:
|
try:
|
||||||
db = get_db()
|
|
||||||
medias = fireEvent('media.with_status', 'active', single = True)
|
medias = fireEvent('media.with_status', 'active', single = True)
|
||||||
|
|
||||||
profile_ids = [x.get('_id') for x in self.all()]
|
profile_ids = [x.get('_id') for x in self.all()]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import traceback
|
import traceback
|
||||||
import re
|
import re
|
||||||
|
from CodernityDB.database import RecordNotFound
|
||||||
|
|
||||||
from couchpotato import get_db
|
from couchpotato import get_db
|
||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
@@ -51,6 +52,7 @@ class QualityPlugin(Plugin):
|
|||||||
addEvent('quality.order', self.getOrder)
|
addEvent('quality.order', self.getOrder)
|
||||||
addEvent('quality.ishigher', self.isHigher)
|
addEvent('quality.ishigher', self.isHigher)
|
||||||
addEvent('quality.isfinish', self.isFinish)
|
addEvent('quality.isfinish', self.isFinish)
|
||||||
|
addEvent('quality.fill', self.fill)
|
||||||
|
|
||||||
addApiView('quality.size.save', self.saveSize)
|
addApiView('quality.size.save', self.saveSize)
|
||||||
addApiView('quality.list', self.allView, docs = {
|
addApiView('quality.list', self.allView, docs = {
|
||||||
@@ -152,24 +154,31 @@ class QualityPlugin(Plugin):
|
|||||||
order = 0
|
order = 0
|
||||||
for q in self.qualities:
|
for q in self.qualities:
|
||||||
|
|
||||||
db.insert({
|
existing = None
|
||||||
'_t': 'quality',
|
try:
|
||||||
'order': order,
|
existing = db.get('quality', q.get('identifier'))
|
||||||
'identifier': q.get('identifier'),
|
except RecordNotFound:
|
||||||
'size_min': tryInt(q.get('size')[0]),
|
pass
|
||||||
'size_max': tryInt(q.get('size')[1]),
|
|
||||||
})
|
|
||||||
|
|
||||||
log.info('Creating profile: %s', q.get('label'))
|
if not existing:
|
||||||
db.insert({
|
db.insert({
|
||||||
'_t': 'profile',
|
'_t': 'quality',
|
||||||
'order': order + 20, # Make sure it goes behind other profiles
|
'order': order,
|
||||||
'core': True,
|
'identifier': q.get('identifier'),
|
||||||
'qualities': [q.get('identifier')],
|
'size_min': tryInt(q.get('size')[0]),
|
||||||
'label': toUnicode(q.get('label')),
|
'size_max': tryInt(q.get('size')[1]),
|
||||||
'finish': [True],
|
})
|
||||||
'wait_for': [0],
|
|
||||||
})
|
log.info('Creating profile: %s', q.get('label'))
|
||||||
|
db.insert({
|
||||||
|
'_t': 'profile',
|
||||||
|
'order': order + 20, # Make sure it goes behind other profiles
|
||||||
|
'core': True,
|
||||||
|
'qualities': [q.get('identifier')],
|
||||||
|
'label': toUnicode(q.get('label')),
|
||||||
|
'finish': [True],
|
||||||
|
'wait_for': [0],
|
||||||
|
})
|
||||||
|
|
||||||
order += 1
|
order += 1
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user