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

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

@ -50,7 +50,7 @@ class Renamer(Plugin):
return return
if self.renaming_started is True: 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 return
# Check to see if the "to" folder is inside the "from" folder. # 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 # Notify on download, search for trailers etc
download_message = 'Downloaded %s (%s)' % (movie_title, replacements['quality']) 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 # Break if CP wants to shut down
if self.shuttingDown(): 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.name_year', self.getReleaseNameYear)
addEvent('scanner.partnumber', self.getPartNumber) 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)) folder = ss(os.path.normpath(folder))
@ -99,7 +99,8 @@ class Scanner(Plugin):
leftovers = [] leftovers = []
# Scan all files of the folder if no files are set # Scan all files of the folder if no files are set
if len(files) == 0: if not files:
check_file_date = True
try: try:
files = [] files = []
for root, dirs, walk_files in os.walk(folder): for root, dirs, walk_files in os.walk(folder):
@ -108,6 +109,7 @@ class Scanner(Plugin):
except: except:
log.error('Failed getting files from %s: %s', (folder, traceback.format_exc())) log.error('Failed getting files from %s: %s', (folder, traceback.format_exc()))
else: else:
check_file_date = False
files = [ss(x) for x in files] files = [ss(x) for x in files]
db = get_session() db = get_session()
@ -237,7 +239,6 @@ class Scanner(Plugin):
del path_identifiers[identifier] del path_identifiers[identifier]
del delete_identifiers del delete_identifiers
# Make sure we remove older / still extracting files # Make sure we remove older / still extracting files
valid_files = {} valid_files = {}
while True and not self.shuttingDown(): while True and not self.shuttingDown():
@ -261,7 +262,7 @@ class Scanner(Plugin):
if file_too_new: if file_too_new:
break break
if file_too_new: if check_file_date and file_too_new:
try: try:
time_string = time.ctime(file_time[0]) time_string = time.ctime(file_time[0])
except: except:

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

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

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

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

Loading…
Cancel
Save