Browse Source

Pass all the renamed files when adding new release

pull/992/merge
Ruud 13 years ago
parent
commit
ad0a1b1efe
  1. 6
      couchpotato/core/plugins/manage/main.py
  2. 4
      couchpotato/core/plugins/renamer/main.py
  3. 9
      couchpotato/core/plugins/scanner/main.py
  4. 2
      couchpotato/core/plugins/trailer/main.py
  5. 1
      couchpotato/core/providers/metadata/base.py

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

@ -2,7 +2,7 @@ from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent, addEvent, fireEventAsync
from couchpotato.core.helpers.encoding import ss
from couchpotato.core.helpers.request import jsonified, getParam
from couchpotato.core.helpers.variable import getTitle
from couchpotato.core.helpers.variable import getTitle, splitString
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
@ -26,7 +26,7 @@ class Manage(Plugin):
# Add files after renaming
def after_rename(message = None, group = {}):
return self.scanFilesToLibrary(folder = group['destination_dir'], files = group['renamed_files'])
addEvent('renamer.after', after_rename)
addEvent('renamer.after', after_rename, priority = 110)
addApiView('manage.update', self.updateLibraryView, docs = {
'desc': 'Update the library by scanning for new movies',
@ -176,7 +176,7 @@ class Manage(Plugin):
def directories(self):
try:
return [x.strip() for x in self.conf('library', default = '').split('::')]
return splitString(self.conf('library', default = ''), '::')
except:
return []

4
couchpotato/core/plugins/renamer/main.py

@ -50,7 +50,7 @@ class Renamer(Plugin):
return
if self.renaming_started is True:
log.info('Renamer is disabled to avoid infinite looping of the same error.')
log.info('Renamer is already running, if you see this often, check the logs above for errors.')
return
# Check to see if the "to" folder is inside the "from" folder.
@ -379,7 +379,7 @@ class Renamer(Plugin):
# Notify on download, search for trailers etc
download_message = 'Downloaded %s (%s)' % (movie_title, replacements['quality'])
fireEventAsync('renamer.after', message = download_message, group = group)
fireEvent('renamer.after', message = download_message, group = group, in_order = True)
# Break if CP wants to shut down
if self.shuttingDown():

9
couchpotato/core/plugins/scanner/main.py

@ -86,7 +86,7 @@ class Scanner(Plugin):
addEvent('scanner.name_year', self.getReleaseNameYear)
addEvent('scanner.partnumber', self.getPartNumber)
def scan(self, folder = None, files = [], simple = False, newer_than = 0, on_found = None):
def scan(self, folder = None, files = None, simple = False, newer_than = 0, on_found = None):
folder = ss(os.path.normpath(folder))
@ -99,7 +99,8 @@ class Scanner(Plugin):
leftovers = []
# Scan all files of the folder if no files are set
if len(files) == 0:
if not files:
check_file_date = True
try:
files = []
for root, dirs, walk_files in os.walk(folder):
@ -108,6 +109,7 @@ class Scanner(Plugin):
except:
log.error('Failed getting files from %s: %s', (folder, traceback.format_exc()))
else:
check_file_date = False
files = [ss(x) for x in files]
db = get_session()
@ -237,7 +239,6 @@ class Scanner(Plugin):
del path_identifiers[identifier]
del delete_identifiers
# Make sure we remove older / still extracting files
valid_files = {}
while True and not self.shuttingDown():
@ -261,7 +262,7 @@ class Scanner(Plugin):
if file_too_new:
break
if file_too_new:
if check_file_date and file_too_new:
try:
time_string = time.ctime(file_time[0])
except:

2
couchpotato/core/plugins/trailer/main.py

@ -28,6 +28,8 @@ class Trailer(Plugin):
else:
log.debug('Trailer already exists: %s', destination)
group['renamed_files'].append(destination)
# Download first and break
break

1
couchpotato/core/providers/metadata/base.py

@ -49,6 +49,7 @@ class MetaDataBase(Plugin):
shutil.copy2(content, name)
else:
self.createFile(name, content)
group['renamed_files'].append(name)
except:
log.error('Unable to create %s file: %s', (file_type, traceback.format_exc()))

Loading…
Cancel
Save