diff --git a/defaults.py b/defaults.py index d0965d2..ddb81f7 100644 --- a/defaults.py +++ b/defaults.py @@ -35,5 +35,6 @@ programmation_object_default = { 'recurrence_start_date': None, 'recurrence_end_date': None, }, + 'extra_parameters' : {}, 'presets': None } diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2de9447..01cbffa 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -20,6 +20,7 @@ services: - ./programmation_persistence_manager.py:/app/programmation_persistence_manager.py - ./programmation_daemon.py:/app/programmation_daemon.py - ./programmation_class.py:/app/programmation_class.py + - ./defaults.py:/app/defaults.py - ./config_manager.py:/app/config_manager.py - ./ydl_api_ng_utils.py:/app/ydl_api_ng_utils.py - ./download_manager.py:/app/download_manager.py diff --git a/download_manager.py b/download_manager.py index e92da93..02f3bd6 100644 --- a/download_manager.py +++ b/download_manager.py @@ -442,7 +442,7 @@ class DownloadManager: ydl_opts = { 'ignoreerrors': True, 'quiet': True, - 'cookiefile' : f'/app/cookies/{request_id}.txt' if request_id is not None else None + 'cookiefile' : f'cookies/{request_id}.txt' if request_id is not None else None } try: @@ -452,7 +452,7 @@ class DownloadManager: return str(error), True try: - os.remove(f'/app/cookies/{request_id}.txt') + os.remove(f'cookies/{request_id}.txt') except FileNotFoundError: pass diff --git a/process_utils.py b/process_utils.py index de9b6c0..0cf7e9f 100644 --- a/process_utils.py +++ b/process_utils.py @@ -538,7 +538,7 @@ class ProcessUtils: dm = job.args[1] dm = download_manager.DownloadManager(self.__cm, dm.url, None, user_token, {'presets': [preset]}, - ignore_post_security=True) + ignore_post_security=True, programmation_id=dm.programmation_id) if dm.get_api_status_code() != 400: dm.process_downloads() diff --git a/programmation_class.py b/programmation_class.py index 48733ba..c83749e 100644 --- a/programmation_class.py +++ b/programmation_class.py @@ -41,6 +41,8 @@ class Programmation: "recurrence_end_date": self.recurrence_end_date, } + self.extra_parameters = programmation.get('extra_parameters') if programmation is not None and programmation.get('extra_parameters') is not None else merged_programmation.get('extra_parameters') + self.errors = self.validate_programmation() if len(self.errors) == 0: @@ -59,6 +61,7 @@ class Programmation: "enabled": self.enabled, "presets": self.presets, "planning": self.planning, + "extra_parameters" : self.extra_parameters } def validate_programmation(self, *args, **kwargs): diff --git a/programmation_daemon.py b/programmation_daemon.py index ba5b6e7..60725db 100644 --- a/programmation_daemon.py +++ b/programmation_daemon.py @@ -100,6 +100,5 @@ if __name__ == '__main__': logging.getLogger('programmation').warning('Redis disabled, programmation daemon exited') exit() - while True: - run() - time.sleep(programmation_interval) + run() + time.sleep(programmation_interval) diff --git a/readme.md b/readme.md index 7a8dc71..627f801 100644 --- a/readme.md +++ b/readme.md @@ -300,7 +300,8 @@ Here what a programmation object looks like in database : "recurrence_start_date": "string date : YYYY-MM-DD hh:mm (null)", "recurrence_end_date": "string date : YYYY-MM-DD hh:mm (null)" }, -"presets": ["string"] +"presets": ["string"], +"extra_parameters" : {} } ``` @@ -309,14 +310,15 @@ Fields: - `url` : url to download, it will not be checked - `user_token` : unused if the `_allow_programmation` is not explicitly set at true in the user config - `enabled` : if false, the programmation will be ignored -- `recording_start_date` -- `recording_duration` : how many minutes recording is supposed to long -- `recording_stops_at_end` : if true, the download will be force stopped when `recording_duration` is reached -- `recording_restarts_during_duration` : if False, the download will not be restarted if stopped before `recording_duration` -- `recurrence_cron` : same cron as linux -- `recurrence_start_date` : useful only if `recurrence_cron` is used -- `recurrence_end_date` : useful only if `recurrence_cron` is used +- `planning.recording_start_date` +- `planning.recording_duration` : how many minutes recording is supposed to long +- `planning.recording_stops_at_end` : if true, the download will be force stopped when `recording_duration` is reached +- `planning.recording_restarts_during_duration` : if False, the download will not be restarted if stopped before `recording_duration` +- `planning.recurrence_cron` : same cron as linux +- `planning.recurrence_start_date` : useful only if `recurrence_cron` is used +- `planning.recurrence_end_date` : useful only if `recurrence_cron` is used - `presets` : list of presets names +- `extra_parameters` : an arbitrary object of parameters you can use to store informations or directives to use in hooks Notes: - `recording_start_date` and `recurrence_cron` cannot be used at the same type @@ -373,6 +375,21 @@ Will last at least 4 hours } ``` +#### Programmation with extra parameters + +```json +{ + "url": "string", + "planning": { + "recurrence_cron": "00 * * * *" + }, + "extra_parameters": { + "notification_level": "critical", + "video_description": "Josephine Ange Gardien - 25th anniversary epic trailer" + } +} +``` + # API ## Application information diff --git a/requests.http b/requests.http index aff95c5..c355bf4 100644 --- a/requests.http +++ b/requests.http @@ -129,9 +129,12 @@ POST {{host}}/programmation?url=video_url Content-Type: application/json { -"planning": { - "recurrence_cron": "00 13 * * *" - } + "planning": { + "recurrence_cron": "25 10 * * *" + }, + "extra_parameters": { + "send_notification": false + } } > {%