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

问题描述 投票:0回答:2

代码:

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:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_dl\YoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_dl\YoutubeDL.py", line 838, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_dl\YoutubeDL.py", line 909, in process_ie_result
    return self.process_ie_result(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_dl\YoutubeDL.py", line 872, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_dl\YoutubeDL.py", line 1674, in process_video_result
    raise ExtractorError('requested format not available',
youtube_dl.utils.ExtractorError: requested format not available

为什么我会收到此错误?我知道格式

'best'
应该可以查看 docs,但我不知道我是否在这里遗漏了一些愚蠢的东西。

python-3.x youtube-dl
2个回答
0
投票

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

我不确定如何将 youtube-dl 与 reddit 视频一起使用,或者这是否是一个选项。然而,在我的 Waterfox(基于 Firefox 的浏览器)中快速查看页面信息 > 媒体,显示视频的直接 URL 为 https://v.redd.it/hlrzahmcqiq61/DASH_96.mp4,可以使用以下命令保存“另存为”按钮。


0
投票

只需选择

pip3 install yt_dlp --upgrade
pip install yt_dlp --upgrade
它应该可以工作。

© www.soinside.com 2019 - 2024. All rights reserved.