Add the possibility to put a timer on a post download
This commit is contained in:
parent
1ce88335c5
commit
c6d52f6f56
33
main.py
33
main.py
|
|
@ -11,6 +11,7 @@ import os
|
|||
|
||||
import programmation_manager
|
||||
import programmation_daemon
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
__cm = config_manager.ConfigManager()
|
||||
__pu = process_utils.ProcessUtils(__cm)
|
||||
|
|
@ -101,7 +102,37 @@ async def download_request(response: Response, background_tasks: BackgroundTasks
|
|||
response.status_code = 400
|
||||
return {'status_code': response.status_code}
|
||||
|
||||
dm = download_manager.DownloadManager(__cm, param_url, None, param_token, body)
|
||||
programmation_object = body.get('programmation')
|
||||
generated_programmation = None
|
||||
programmation_end_date = None
|
||||
|
||||
if programmation_object is not None:
|
||||
programmation_object['url'] = param_url
|
||||
programmation_object['user_token'] = token
|
||||
programmation_object['not_stored'] = True
|
||||
|
||||
generated_programmation = __pm.generate_programmation(programmation=programmation_object)
|
||||
validation_result = __pm.validate_programmation(programmation=generated_programmation)
|
||||
|
||||
if len(validation_result) != 0:
|
||||
response.status_code = 400
|
||||
return validation_result
|
||||
|
||||
planning = generated_programmation.get('planning')
|
||||
|
||||
if planning.get('recording_duration') is not None:
|
||||
planning['recording_stops_at_end'] = True
|
||||
programmation_end_date = datetime.now().replace(second=0, microsecond=0) + timedelta(minutes=1 + planning.get('recording_duration'))
|
||||
|
||||
if generated_programmation is None:
|
||||
dm = download_manager.DownloadManager(__cm, param_url, None, param_token, body)
|
||||
else:
|
||||
dm = download_manager.DownloadManager(__cm, param_url, None, param_token, body,
|
||||
programmation_id=generated_programmation.get('id'),
|
||||
programmation_end_date=programmation_end_date,
|
||||
programmation_date=datetime.now(),
|
||||
programmation=generated_programmation)
|
||||
|
||||
response.status_code = dm.get_api_status_code()
|
||||
|
||||
if response.status_code != 400:
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ _when_playlist = {"ignoreerrors" : true}
|
|||
[preset:AUDIO]
|
||||
_template = AUDIO
|
||||
format = bestaudio
|
||||
postprocessors = [{"key": "FFmpegSplitChapters", "force_keyframes": false}]
|
||||
postprocessors = [{"key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320"}, {"key": "FFmpegSplitChapters", "force_keyframes": false}]
|
||||
writethumbnail = true
|
||||
|
||||
[preset:BEST]
|
||||
format = bestvideo+bestaudio/best
|
||||
|
|
|
|||
|
|
@ -119,8 +119,9 @@ _when_playlist = {"ignoreerrors": true}
|
|||
; will use AUDIO template to have a different naming convention
|
||||
_template = AUDIO
|
||||
format = bestaudio
|
||||
; allow to split each track when the video contains chapters
|
||||
postprocessors = [{"key": "FFmpegSplitChapters", "force_keyframes": false}]
|
||||
; convert to mp3 then split each track when the video contains chapters
|
||||
postprocessors = [{"key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320"}, {"key": "FFmpegSplitChapters", "force_keyframes": false}]
|
||||
writethumbnail = true
|
||||
|
||||
[preset:BEST]
|
||||
format = bestvideo+bestaudio/best
|
||||
|
|
|
|||
|
|
@ -45,11 +45,13 @@ restrictfilenames = true
|
|||
windowsfilenames = true
|
||||
ignoreerrors = true
|
||||
_when_playlist = {"ignoreerrors" : true}
|
||||
cachedir = /home/ydl_api_ng/cache
|
||||
|
||||
[preset:AUDIO]
|
||||
_template = AUDIO
|
||||
format = bestaudio
|
||||
postprocessors = [{"key": "FFmpegSplitChapters", "force_keyframes": false}]
|
||||
postprocessors = [{"key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320"}, {"key": "FFmpegSplitChapters", "force_keyframes": false}]
|
||||
writethumbnail = true
|
||||
|
||||
[preset:BEST]
|
||||
format = bestvideo+bestaudio/best
|
||||
|
|
|
|||
20
readme.md
20
readme.md
|
|
@ -387,6 +387,26 @@ Content-Type: application/json
|
|||
}
|
||||
```
|
||||
|
||||
It is possible to add a timer to stop the download (`recording_stops_at_end` will be automatically set on `True`) :
|
||||
|
||||
```shell
|
||||
POST http://localhost:5011/download?url=https://www.youtube.com/watch?v=wV4wepiucf4&token=dad_super_password
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"programmation": {
|
||||
"planning": {
|
||||
"recording_duration": 10
|
||||
}
|
||||
},
|
||||
"presets": [
|
||||
{
|
||||
"_preset": "HD"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Reminder if you want to expand a preset : all presets automatically expand the `DEFAULT` preset. Basically, expand a
|
||||
preset with `_preset` means `_ignore_default_preset`can't be true.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue