From df761ba3a32b6a373fca493ae22c855a3bd163dd Mon Sep 17 00:00:00 2001 From: Alex Standke Date: Fri, 24 Jan 2020 14:07:09 -0800 Subject: [PATCH] allow triggering automation.add_movies from api --- couchpotato/core/plugins/automation.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/couchpotato/core/plugins/automation.py b/couchpotato/core/plugins/automation.py index e98a00a..110d4c4 100644 --- a/couchpotato/core/plugins/automation.py +++ b/couchpotato/core/plugins/automation.py @@ -1,3 +1,4 @@ +from couchpotato.api import addApiView from couchpotato.core.event import addEvent, fireEvent from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin @@ -17,11 +18,21 @@ class Automation(Plugin): if not Env.get('dev'): addEvent('app.load', self.addMovies) + addApiView('automation.add_movies', self.addMoviesFromApi, docs = { + 'desc': 'Manually trigger the automation scan. Hangs until scan is complete. Useful for webhooks.', + 'return': {'type': 'object: {"success": true}'}, + }) addEvent('setting.save.automation.hour.after', self.setCrons) def setCrons(self): fireEvent('schedule.interval', 'automation.add_movies', self.addMovies, hours = self.conf('hour', default = 12)) + def addMoviesFromApi(self, **kwargs): + self.addMovies() + return { + 'success': True + } + def addMovies(self): movies = fireEvent('automation.get_movies', merge = True)