diff --git a/.gitignore b/.gitignore index eec472f..cb14cfd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 35fcda1..fb4d950 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -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): diff --git a/tubesync/sync/youtube.py b/tubesync/sync/youtube.py index 00ae958..a55e92a 100644 --- a/tubesync/sync/youtube.py +++ b/tubesync/sync/youtube.py @@ -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': diff --git a/tubesync/tubesync/settings.py b/tubesync/tubesync/settings.py index de7a1bc..8762d4c 100644 --- a/tubesync/tubesync/settings.py +++ b/tubesync/tubesync/settings.py @@ -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'