Merge pull request #19 from Totonyus/develop

Develop
This commit is contained in:
Totonyus 2024-04-27 21:53:44 +02:00 committed by GitHub
commit 0097a1a58e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 41 additions and 17 deletions

View File

@ -35,5 +35,6 @@ programmation_object_default = {
'recurrence_start_date': None, 'recurrence_start_date': None,
'recurrence_end_date': None, 'recurrence_end_date': None,
}, },
'extra_parameters' : {},
'presets': None 'presets': None
} }

View File

@ -20,6 +20,7 @@ services:
- ./programmation_persistence_manager.py:/app/programmation_persistence_manager.py - ./programmation_persistence_manager.py:/app/programmation_persistence_manager.py
- ./programmation_daemon.py:/app/programmation_daemon.py - ./programmation_daemon.py:/app/programmation_daemon.py
- ./programmation_class.py:/app/programmation_class.py - ./programmation_class.py:/app/programmation_class.py
- ./defaults.py:/app/defaults.py
- ./config_manager.py:/app/config_manager.py - ./config_manager.py:/app/config_manager.py
- ./ydl_api_ng_utils.py:/app/ydl_api_ng_utils.py - ./ydl_api_ng_utils.py:/app/ydl_api_ng_utils.py
- ./download_manager.py:/app/download_manager.py - ./download_manager.py:/app/download_manager.py

View File

@ -442,7 +442,7 @@ class DownloadManager:
ydl_opts = { ydl_opts = {
'ignoreerrors': True, 'ignoreerrors': True,
'quiet': 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: try:
@ -452,7 +452,7 @@ class DownloadManager:
return str(error), True return str(error), True
try: try:
os.remove(f'/app/cookies/{request_id}.txt') os.remove(f'cookies/{request_id}.txt')
except FileNotFoundError: except FileNotFoundError:
pass pass

View File

@ -538,7 +538,7 @@ class ProcessUtils:
dm = job.args[1] dm = job.args[1]
dm = download_manager.DownloadManager(self.__cm, dm.url, None, user_token, {'presets': [preset]}, 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: if dm.get_api_status_code() != 400:
dm.process_downloads() dm.process_downloads()

View File

@ -41,6 +41,8 @@ class Programmation:
"recurrence_end_date": self.recurrence_end_date, "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() self.errors = self.validate_programmation()
if len(self.errors) == 0: if len(self.errors) == 0:
@ -59,6 +61,7 @@ class Programmation:
"enabled": self.enabled, "enabled": self.enabled,
"presets": self.presets, "presets": self.presets,
"planning": self.planning, "planning": self.planning,
"extra_parameters" : self.extra_parameters
} }
def validate_programmation(self, *args, **kwargs): def validate_programmation(self, *args, **kwargs):

View File

@ -100,6 +100,5 @@ if __name__ == '__main__':
logging.getLogger('programmation').warning('Redis disabled, programmation daemon exited') logging.getLogger('programmation').warning('Redis disabled, programmation daemon exited')
exit() exit()
while True: run()
run() time.sleep(programmation_interval)
time.sleep(programmation_interval)

View File

@ -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_start_date": "string date : YYYY-MM-DD hh:mm (null)",
"recurrence_end_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 - `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 - `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 - `enabled` : if false, the programmation will be ignored
- `recording_start_date` - `planning.recording_start_date`
- `recording_duration` : how many minutes recording is supposed to long - `planning.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 - `planning.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` - `planning.recording_restarts_during_duration` : if False, the download will not be restarted if stopped before `recording_duration`
- `recurrence_cron` : same cron as linux - `planning.recurrence_cron` : same cron as linux
- `recurrence_start_date` : useful only if `recurrence_cron` is used - `planning.recurrence_start_date` : useful only if `recurrence_cron` is used
- `recurrence_end_date` : useful only if `recurrence_cron` is used - `planning.recurrence_end_date` : useful only if `recurrence_cron` is used
- `presets` : list of presets names - `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: Notes:
- `recording_start_date` and `recurrence_cron` cannot be used at the same type - `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 # API
## Application information ## Application information

View File

@ -129,9 +129,12 @@ POST {{host}}/programmation?url=video_url
Content-Type: application/json Content-Type: application/json
{ {
"planning": { "planning": {
"recurrence_cron": "00 13 * * *" "recurrence_cron": "25 10 * * *"
} },
"extra_parameters": {
"send_notification": false
}
} }
> {% > {%