Don't use 2 events after rename
This commit is contained in:
@@ -14,7 +14,7 @@ class Notification(Plugin):
|
||||
test_message = 'ZOMG Lazors Pewpewpew!'
|
||||
|
||||
listen_to = [
|
||||
'movie.downloaded', 'movie.snatched',
|
||||
'renamer.after', 'movie.snatched',
|
||||
'updater.available', 'updater.updated',
|
||||
]
|
||||
dont_listen_to = []
|
||||
@@ -30,10 +30,10 @@ class Notification(Plugin):
|
||||
addEvent(listener, self.createNotifyHandler(listener))
|
||||
|
||||
def createNotifyHandler(self, listener):
|
||||
def notify(message, data):
|
||||
def notify(message = None, group = {}):
|
||||
if not self.conf('on_snatch', default = True) and listener == 'movie.snatched':
|
||||
return
|
||||
return self.notify(message = message, data = data, listener = listener)
|
||||
return self.notify(message = message, data = group, listener = listener)
|
||||
|
||||
return notify
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class CoreNotifier(Notification):
|
||||
listeners = []
|
||||
|
||||
listen_to = [
|
||||
'movie.downloaded', 'movie.snatched',
|
||||
'renamer.after', 'movie.snatched',
|
||||
'updater.available', 'updater.updated',
|
||||
]
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class NMJ(Notification):
|
||||
'mount': mount,
|
||||
})
|
||||
|
||||
def addToLibrary(self, group = {}):
|
||||
def addToLibrary(self, message = None, group = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
host = self.conf('host')
|
||||
@@ -114,8 +114,8 @@ class NMJ(Notification):
|
||||
|
||||
def failed(self):
|
||||
return jsonified({'success': False})
|
||||
|
||||
|
||||
def test(self):
|
||||
return jsonified({'success': self.addToLibrary()})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class Plex(Notification):
|
||||
super(Plex, self).__init__()
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
def addToLibrary(self, group = {}):
|
||||
def addToLibrary(self, message = None, group = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
log.info('Sending notification to Plex')
|
||||
|
||||
@@ -16,7 +16,7 @@ class Synoindex(Notification):
|
||||
super(Synoindex, self).__init__()
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
def addToLibrary(self, group = {}):
|
||||
def addToLibrary(self, message = None, group = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
command = [self.index_path, '-A', group.get('destination_dir')]
|
||||
|
||||
@@ -8,7 +8,7 @@ log = CPLog(__name__)
|
||||
|
||||
class XBMC(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded']
|
||||
listen_to = ['renamer.after']
|
||||
|
||||
def notify(self, message = '', data = {}, listener = None):
|
||||
if self.isDisabled(): return
|
||||
@@ -21,7 +21,7 @@ class XBMC(Notification):
|
||||
if self.send({'command': 'ExecBuiltIn', 'parameter': 'XBMC.updatelibrary(video)'}, host):
|
||||
successful += 1
|
||||
|
||||
return successful == len(hosts)*2
|
||||
return successful == len(hosts) * 2
|
||||
|
||||
def send(self, command, host):
|
||||
|
||||
|
||||
@@ -22,10 +22,9 @@ class Manage(Plugin):
|
||||
fireEvent('scheduler.interval', identifier = 'manage.update_library', handle = self.updateLibrary, hours = 2)
|
||||
|
||||
addEvent('manage.update', self.updateLibrary)
|
||||
addEvent('manage.scan_files', self.scanFilesToLibrary)
|
||||
|
||||
# Add files after renaming
|
||||
def after_rename(group):
|
||||
def after_rename(message = None, group = {}):
|
||||
return self.scanFilesToLibrary(folder = group['destination_dir'], files = group['renamed_files'])
|
||||
addEvent('renamer.after', after_rename)
|
||||
|
||||
|
||||
@@ -377,12 +377,9 @@ class Renamer(Plugin):
|
||||
except:
|
||||
log.error('Failed removing %s: %s', (group['parentdir'], traceback.format_exc()))
|
||||
|
||||
# Search for trailers etc
|
||||
fireEventAsync('renamer.after', group)
|
||||
|
||||
# Notify on download
|
||||
# Notify on download, search for trailers etc
|
||||
download_message = 'Downloaded %s (%s)' % (movie_title, replacements['quality'])
|
||||
fireEventAsync('movie.downloaded', message = download_message, data = group)
|
||||
fireEventAsync('renamer.after', message = download_message, group = group)
|
||||
|
||||
# Break if CP wants to shut down
|
||||
if self.shuttingDown():
|
||||
|
||||
@@ -12,7 +12,7 @@ class Trailer(Plugin):
|
||||
def __init__(self):
|
||||
addEvent('renamer.after', self.searchSingle)
|
||||
|
||||
def searchSingle(self, group):
|
||||
def searchSingle(self, message = None, group = {}):
|
||||
|
||||
if self.isDisabled() or len(group['files']['trailer']) > 0: return
|
||||
|
||||
|
||||
@@ -16,23 +16,23 @@ class MetaDataBase(Plugin):
|
||||
def __init__(self):
|
||||
addEvent('renamer.after', self.create)
|
||||
|
||||
def create(self, release):
|
||||
def create(self, message = None, group = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
log.info('Creating %s metadata.', self.getName())
|
||||
|
||||
# Update library to get latest info
|
||||
try:
|
||||
updated_library = fireEvent('library.update', release['library']['identifier'], force = True, single = True)
|
||||
release['library'] = mergeDicts(release['library'], updated_library)
|
||||
updated_library = fireEvent('library.update', group['library']['identifier'], force = True, single = True)
|
||||
group['library'] = mergeDicts(group['library'], updated_library)
|
||||
except:
|
||||
log.error('Failed to update movie, before creating metadata: %s', traceback.format_exc())
|
||||
|
||||
root_name = self.getRootName(release)
|
||||
root_name = self.getRootName(group)
|
||||
meta_name = os.path.basename(root_name)
|
||||
root = os.path.dirname(root_name)
|
||||
|
||||
movie_info = release['library'].get('info')
|
||||
movie_info = group['library'].get('info')
|
||||
|
||||
for file_type in ['nfo', 'thumbnail', 'fanart']:
|
||||
try:
|
||||
@@ -42,7 +42,7 @@ class MetaDataBase(Plugin):
|
||||
if name and self.conf('meta_' + file_type):
|
||||
|
||||
# Get file content
|
||||
content = getattr(self, 'get' + file_type.capitalize())(movie_info = movie_info, data = release)
|
||||
content = getattr(self, 'get' + file_type.capitalize())(movie_info = movie_info, data = group)
|
||||
if content:
|
||||
log.debug('Creating %s file: %s', (file_type, name))
|
||||
if os.path.isfile(content):
|
||||
|
||||
Reference in New Issue
Block a user