diff options
| author | Shyam Sunder | 2020-04-05 14:58:58 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2020-04-05 15:21:03 -0400 |
| commit | cd6683c2d81accd07962739b9835602e4c8d6b18 (patch) | |
| tree | cc9db995f8915810ed51be760f836278288feab1 /server/szurubooru/func/net.py | |
| parent | 2c6434b08d9e38a1879cd66533b9a2c5d2c09c4f (diff) | |
server/posts/upload: make youtube-dl use best format
Fixes #313
Diffstat (limited to 'server/szurubooru/func/net.py')
| -rw-r--r-- | server/szurubooru/func/net.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/szurubooru/func/net.py b/server/szurubooru/func/net.py index 80a5de0..882e519 100644 --- a/server/szurubooru/func/net.py +++ b/server/szurubooru/func/net.py @@ -32,7 +32,7 @@ def _youtube_dl_wrapper(url: str) -> bytes: options = { 'quiet': True, 'ignoreerrors': False, - 'format': 'webm/mp4', + 'format': 'best[ext=webm]/best[ext=mp4]/best[ext=flv]', 'logger': logger, 'noplaylist': True, 'max_filesize': config.config['max_dl_filesize'], @@ -46,11 +46,12 @@ def _youtube_dl_wrapper(url: str) -> bytes: try: ydl_info = ydl.extract_info(url, download=True) # need to confirm if download was skipped due to size - if ydl_info['filesize'] > config.config['max_dl_filesize']: - raise errors.DownloadTooLargeError( - 'Requested video too large (%d MB > %d MB)' % ( - ydl_info['filesize'] / 1.0e6, - config.config['max_dl_filesize'] / 1.0e6)) + if 'filesize' in ydl_info: + if ydl_info['filesize'] > config.config['max_dl_filesize']: + raise errors.DownloadTooLargeError( + 'Requested video too large (%d MB > %d MB)' % ( + ydl_info['filesize'] / 1.0e6, + config.config['max_dl_filesize'] / 1.0e6)) ydl_filename = ydl.prepare_filename(ydl_info) except YoutubeDLError as ex: raise errors.ThirdPartyError( |