diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index e540d3d992..4d963816d0 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -1204,6 +1204,8 @@ def __init__(self): # On-import analysis. if self.config['auto']: + self.register_listener('import_begin', self.import_begin) + self.register_listener('import', self.import_end) self.import_stages = [self.imported] # Formats to use R128. @@ -1442,6 +1444,16 @@ def close_pool(self): self.pool.close() self.pool.join() + def import_begin(self, session): + """Handle `import_begin` event -> open pool + """ + self.open_pool(self.config['threads'].get(int)) + + def import_end(self, paths): + """Handle `import` event -> close pool + """ + self.close_pool() + def imported(self, session, task): """Add replay gain info to items or albums of ``task``. """