diff --git a/couchpotato/core/plugins/manage/main.py b/couchpotato/core/plugins/manage/main.py index ce5edd1..33a6a5c 100644 --- a/couchpotato/core/plugins/manage/main.py +++ b/couchpotato/core/plugins/manage/main.py @@ -1,6 +1,6 @@ from couchpotato.api import addApiView from couchpotato.core.event import fireEvent, addEvent, fireEventAsync -from couchpotato.core.helpers.request import jsonified, getParams +from couchpotato.core.helpers.request import jsonified, getParam from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.environment import Env @@ -25,13 +25,14 @@ class Manage(Plugin): }) if not Env.get('dev'): - addEvent('app.load', self.updateLibrary) + def updateLibrary(): + self.updateLibrary(full = False) + addEvent('app.load', updateLibrary) def updateLibraryView(self): - params = getParams() - - fireEventAsync('manage.update', full = params.get('full', True)) + full = getParam('full', default = 1) + fireEventAsync('manage.update', full = True if full == '1' else False) return jsonified({ 'success': True @@ -55,7 +56,7 @@ class Manage(Plugin): continue log.info('Updating manage library: %s' % directory) - identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update, single = True) + identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update if not full else 0, single = True) if identifiers: added_identifiers.extend(identifiers) @@ -71,7 +72,7 @@ class Manage(Plugin): for done_movie in done_movies: if done_movie['library']['identifier'] not in added_identifiers: - fireEvent('movie.delete', movie_id = done_movie['id']) + fireEvent('movie.delete', movie_id = done_movie['id'], delete_from = 'all') Env.prop('manage.last_update', time.time()) diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index f122f4b..00e4299 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -103,14 +103,14 @@ class Scanner(Plugin): if group['library']: fireEvent('release.add', group = group) - def scanFolderToLibrary(self, folder = None, newer_than = None, simple = True): + def scanFolderToLibrary(self, folder = None, newer_than = 0, simple = True): folder = os.path.normpath(folder) if not os.path.isdir(folder): return - groups = self.scan(folder = folder, simple = simple) + groups = self.scan(folder = folder, simple = simple, newer_than = newer_than) added_identifier = [] while True and not self.shuttingDown(): @@ -131,7 +131,7 @@ class Scanner(Plugin): return added_identifier - def scan(self, folder = None, files = [], simple = False): + def scan(self, folder = None, files = [], simple = False, newer_than = 0): folder = os.path.normpath(folder) @@ -312,6 +312,19 @@ class Scanner(Plugin): del group['unsorted_files'] continue + + # Only process movies newer than x + if newer_than and newer_than > 0: + for cur_file in group['unsorted_files']: + file_time = [os.path.getmtime(cur_file), os.path.getctime(cur_file)] + if file_time[0] > time.time() or file_time[1] > time.time(): + break + + log.debug('None of the files have changed since %s for %s, skipping.' % (time.ctime(newer_than), identifier)) + + # Delete the unsorted list + del group['unsorted_files'] + continue # Group extra (and easy) files first diff --git a/couchpotato/static/scripts/page/manage.js b/couchpotato/static/scripts/page/manage.js index 0385ee0..aefbb42 100644 --- a/couchpotato/static/scripts/page/manage.js +++ b/couchpotato/static/scripts/page/manage.js @@ -41,7 +41,7 @@ Page.Manage = new Class({ Api.request('manage.update', { 'data': { - 'full': full ? 1 : null + 'full': +full } })