parent
2c6434b08d
commit
cd6683c2d8
2 changed files with 8 additions and 7 deletions
|
@ -32,7 +32,7 @@ def _youtube_dl_wrapper(url: str) -> bytes:
|
||||||
options = {
|
options = {
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ignoreerrors': False,
|
'ignoreerrors': False,
|
||||||
'format': 'webm/mp4',
|
'format': 'best[ext=webm]/best[ext=mp4]/best[ext=flv]',
|
||||||
'logger': logger,
|
'logger': logger,
|
||||||
'noplaylist': True,
|
'noplaylist': True,
|
||||||
'max_filesize': config.config['max_dl_filesize'],
|
'max_filesize': config.config['max_dl_filesize'],
|
||||||
|
@ -46,11 +46,12 @@ def _youtube_dl_wrapper(url: str) -> bytes:
|
||||||
try:
|
try:
|
||||||
ydl_info = ydl.extract_info(url, download=True)
|
ydl_info = ydl.extract_info(url, download=True)
|
||||||
# need to confirm if download was skipped due to size
|
# need to confirm if download was skipped due to size
|
||||||
if ydl_info['filesize'] > config.config['max_dl_filesize']:
|
if 'filesize' in ydl_info:
|
||||||
raise errors.DownloadTooLargeError(
|
if ydl_info['filesize'] > config.config['max_dl_filesize']:
|
||||||
'Requested video too large (%d MB > %d MB)' % (
|
raise errors.DownloadTooLargeError(
|
||||||
ydl_info['filesize'] / 1.0e6,
|
'Requested video too large (%d MB > %d MB)' % (
|
||||||
config.config['max_dl_filesize'] / 1.0e6))
|
ydl_info['filesize'] / 1.0e6,
|
||||||
|
config.config['max_dl_filesize'] / 1.0e6))
|
||||||
ydl_filename = ydl.prepare_filename(ydl_info)
|
ydl_filename = ydl.prepare_filename(ydl_info)
|
||||||
except YoutubeDLError as ex:
|
except YoutubeDLError as ex:
|
||||||
raise errors.ThirdPartyError(
|
raise errors.ThirdPartyError(
|
||||||
|
|
|
@ -68,7 +68,7 @@ def test_too_large_download():
|
||||||
|
|
||||||
def test_video_download():
|
def test_video_download():
|
||||||
url = 'https://www.youtube.com/watch?v=C0DPdy98e4c'
|
url = 'https://www.youtube.com/watch?v=C0DPdy98e4c'
|
||||||
expected_sha1 = '508f89ee85bc6186e18cfaa4f4d0279bcf2418ab'
|
expected_sha1 = '365af1c8f59c6865e1a84c6e13e3e25ff89e0ba1'
|
||||||
|
|
||||||
actual_content = net.download(url, use_video_downloader=True)
|
actual_content = net.download(url, use_video_downloader=True)
|
||||||
assert get_sha1(actual_content) == expected_sha1
|
assert get_sha1(actual_content) == expected_sha1
|
||||||
|
|
Loading…
Reference in a new issue