Browse Source

Rename scanned files for done media properly

pull/3341/head
mano3m 11 years ago
parent
commit
f01449f14c
  1. 6
      couchpotato/core/plugins/quality/main.py
  2. 29
      couchpotato/core/plugins/renamer.py

6
couchpotato/core/plugins/quality/main.py

@ -381,7 +381,7 @@ class QualityPlugin(Plugin):
def isFinish(self, quality, profile, release_age = 0): def isFinish(self, quality, profile, release_age = 0):
if not isinstance(profile, dict) or not profile.get('qualities'): if not isinstance(profile, dict) or not profile.get('qualities'):
return False profile = fireEvent('profile.default', single = True)
try: try:
index = [i for i, identifier in enumerate(profile['qualities']) if identifier == quality['identifier'] and bool(profile['3d'][i] if profile.get('3d') else False) == bool(quality.get('is_3d', False))][0] index = [i for i, identifier in enumerate(profile['qualities']) if identifier == quality['identifier'] and bool(profile['3d'][i] if profile.get('3d') else False) == bool(quality.get('is_3d', False))][0]
@ -395,14 +395,14 @@ class QualityPlugin(Plugin):
def isHigher(self, quality, compare_with, profile = None): def isHigher(self, quality, compare_with, profile = None):
if not isinstance(profile, dict) or not profile.get('qualities'): if not isinstance(profile, dict) or not profile.get('qualities'):
profile = {'qualities': self.order} profile = fireEvent('profile.default', single = True)
# Try to find quality in profile, if not found: a quality we do not want is lower than anything else # Try to find quality in profile, if not found: a quality we do not want is lower than anything else
try: try:
quality_order = [i for i, identifier in enumerate(profile['qualities']) if identifier == quality['identifier'] and bool(profile['3d'][i] if profile.get('3d') else 0) == bool(quality.get('is_3d', 0))][0] quality_order = [i for i, identifier in enumerate(profile['qualities']) if identifier == quality['identifier'] and bool(profile['3d'][i] if profile.get('3d') else 0) == bool(quality.get('is_3d', 0))][0]
except: except:
log.debug('Quality %s not found in profile identifiers %s', (quality['identifier'] + (' 3D' if quality.get('is_3d', 0) else ''), \ log.debug('Quality %s not found in profile identifiers %s', (quality['identifier'] + (' 3D' if quality.get('is_3d', 0) else ''), \
[identifier + ('3D' if (profile['3d'][i] if profile.get('3d') else 0) else '') for i, identifier in enumerate(profile['qualities'])])) [identifier + (' 3D' if (profile['3d'][i] if profile.get('3d') else 0) else '') for i, identifier in enumerate(profile['qualities'])]))
return 'lower' return 'lower'
# Try to find compare quality in profile, if not found: anything is higher than a not wanted quality # Try to find compare quality in profile, if not found: anything is higher than a not wanted quality

29
couchpotato/core/plugins/renamer.py

@ -446,22 +446,23 @@ class Renamer(Plugin):
# Before renaming, remove the lower quality files # Before renaming, remove the lower quality files
remove_leftovers = True remove_leftovers = True
# Mark movie "done" once it's found the quality with the finish check # Get media quality profile
profile = None profile = None
try: if media.get('profile_id'):
if media.get('status') == 'active' and media.get('profile_id'): profile = db.get('id', media['profile_id'])
profile = db.get('id', media['profile_id']) else:
if fireEvent('quality.isfinish', group['meta_data']['quality'], profile, single = True): log.debug('Media has no quality profile: %s', media_title)
mdia = db.get('id', media['_id'])
mdia['status'] = 'done'
mdia['last_edit'] = int(time.time())
db.update(mdia)
# List movie on dashboard # Mark movie "done" once it's found the quality with the finish check
fireEvent('media.tag', media['_id'], 'recent', single = True) if media.get('status') == 'active':
if fireEvent('quality.isfinish', group['meta_data']['quality'], profile, single = True):
mdia = db.get('id', media['_id'])
mdia['status'] = 'done'
mdia['last_edit'] = int(time.time())
db.update(mdia)
except: # List movie on dashboard
log.error('Failed marking movie finished: %s', (traceback.format_exc())) fireEvent('media.tag', media['_id'], 'recent', single = True)
# Mark media for dashboard # Mark media for dashboard
mark_as_recent = False mark_as_recent = False
@ -474,7 +475,7 @@ class Renamer(Plugin):
# This is where CP removes older, lesser quality releases or releases that are not wanted anymore # This is where CP removes older, lesser quality releases or releases that are not wanted anymore
is_higher = fireEvent('quality.ishigher', \ is_higher = fireEvent('quality.ishigher', \
group['meta_data']['quality'], {'identifier': release['quality'], 'is_3d': release.get('is_3d', 0)}, profile, single = True) group['meta_data']['quality'], {'identifier': release['quality'], 'is_3d': release.get('is_3d', False)}, profile, single = True)
if is_higher == 'higher': if is_higher == 'higher':
log.info('Removing lesser or not wanted quality %s for %s.', (media_title, release.get('quality'))) log.info('Removing lesser or not wanted quality %s for %s.', (media_title, release.get('quality')))

Loading…
Cancel
Save