youtube_dl 错误:请求的格式不可用

代码:

import tempfile
import youtube_dl

link = "https://www.reddit.com/r/CatastrophicFailure/comments/mhqgso/industrial_fire_in_volendam_netherlands_3132021/?utm_source=share&utm_medium=web2x&context=3"

with tempfile.TemporaryDirectory() as tempdir:
    settings = {
        'verbose': True,
        'noplaylist': True,
        'format': 'best',
        'outtmpl': f'{tempdir}/%(id)s.%(ext)s'
    }
    with youtube_dl.YoutubeDL(settings) as ytdl:
        meta = ytdl.extract_info(
            link,
            download=True
        )

错误:

[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] youtube-dl version 2021.03.31
[debug] Python version 3.8.5 (CPython) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg git-2020-08-31-4a11a6f, ffprobe git-2020-08-31-4a11a6f
[debug] Proxy map: {}
[RedditR] mhqgso: Downloading JSON metadata
[Reddit] hlrzahmcqiq61: Downloading m3u8 information
[Reddit] hlrzahmcqiq61: Downloading MPD manifest
ERROR: requested format not available
Traceback (most recent call last):
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 838, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 909, in process_ie_result
    return self.process_ie_result(
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 872, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 1674, in process_video_result
    raise ExtractorError('requested format not available',
youtube_dl.utils.ExtractorError: requested format not available

为什么我会收到此错误?我知道格式 'best' 应该可以查看 docs 并且我不知道我是否在这里遗漏了一些愚蠢的东西。

stack overflow youtube_dl ERROR: requested format not available
原文答案

答案:

作者头像

据我了解,错误的原因是链接(URL)而不是视频格式。该 URL 不指向视频,而是指向显示视频和其他内容的 reddit 页面。

我不确定如何将 youtube-dl 与 reddit 视频一起使用,或者是否可以选择。但是,快速查看我的 Waterfox(基于 Firefox 的浏览器)中的 Page info > Media 会显示视频的直接 URL 为 https://v.redd.it/hlrzahmcqiq61/DASH_96.mp4 ,可以使用“另存为”按钮进行保存。

相关问题