Browse Source
Merge pull request #7314 from XanderStrike/AutomationFromApi
allow triggering automation.add_movies from api
pull/7291/head
Ruud Burger
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
11 additions and
0 deletions
-
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) |
|
|
|