download subtitles draft
This commit is contained in:
parent
ddc127e6af
commit
e9f03cb6bf
|
@ -1,3 +1,4 @@
|
|||
.DS_Store
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
|
|
@ -103,7 +103,8 @@ class Source(models.Model):
|
|||
EXTENSION_M4A = 'm4a'
|
||||
EXTENSION_OGG = 'ogg'
|
||||
EXTENSION_MKV = 'mkv'
|
||||
EXTENSIONS = (EXTENSION_M4A, EXTENSION_OGG, EXTENSION_MKV)
|
||||
EXTENSION_MP4 = 'mp4'
|
||||
EXTENSIONS = (EXTENSION_M4A, EXTENSION_OGG, EXTENSION_MKV, EXTENSION_MP4)
|
||||
|
||||
|
||||
# as stolen from: https://wiki.sponsor.ajay.app/w/Types / https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/postprocessor/sponsorblock.py
|
||||
|
@ -398,7 +399,7 @@ class Source(models.Model):
|
|||
else:
|
||||
raise ValueError('Unable to choose audio extension, uknown acodec')
|
||||
else:
|
||||
return self.EXTENSION_MKV
|
||||
return self.EXTENSION_MP4
|
||||
|
||||
@classmethod
|
||||
def create_url(obj, source_type, key):
|
||||
|
|
|
@ -73,6 +73,10 @@ def download_media(url, media_format, extension, output_file, info_json,
|
|||
|
||||
def hook(event):
|
||||
filename = os.path.basename(event['filename'])
|
||||
|
||||
if event.get('downloaded_bytes') is None or event.get('total_bytes') is None:
|
||||
return None
|
||||
|
||||
if event['status'] == 'error':
|
||||
log.error(f'[youtube-dl] error occured downloading: {filename}')
|
||||
elif event['status'] == 'downloading':
|
||||
|
|
|
@ -160,6 +160,9 @@ YOUTUBE_DEFAULTS = {
|
|||
'ignoreerrors': True, # Skip on errors (such as unavailable videos in playlists)
|
||||
'cachedir': False, # Disable on-disk caching
|
||||
'addmetadata': True, # Embed metadata during postprocessing where available
|
||||
'writesubtitles': True,
|
||||
'writeautomaticsub': True,
|
||||
'subtitleslangs': ['fr', 'en'],
|
||||
}
|
||||
COOKIES_FILE = CONFIG_BASE_DIR / 'cookies.txt'
|
||||
|
||||
|
|
Loading…
Reference in New Issue