You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用youtube-dl下载YouTube视频遇“Unable to extract uploader id”错误求助

解决youtube-dl"Unable to extract uploader id"错误

问题重现

使用youtube-dl下载YouTube视频的代码如下:

import youtube_dl

video_url = "https://www.youtube.com/watch?v=w9Fcgdlw-Nc"

desired_format = 'mp4'

ydl_opts = {
    'format': desired_format,
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([video_url])

错误日志

运行代码后触发以下错误:

PS C:\Users\sepeh\Desktop\Bot> & "C:/Program Files/Python39/python.exe" c:/Users/sepeh/Desktop/Bot/main.py
[youtube] w9Fcgdlw-Nc: Downloading webpage
ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\extractor\common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\extractor\youtube.py", line 1794, in _real_extract
    'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None,
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\extractor\common.py", line 1012, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\sepeh\Desktop\Bot\main.py", line 26, in <module>
    ydl.download(["https://www.youtube.com/watch?v=w9Fcgdlw-Nc"])
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 2068, in download
    res = self.extract_info(
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 824, in wrapper
    self.report_error(compat_str(e), e.format_traceback())
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 628, in report_error
    self.trouble(error_message, tb)
  File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 598, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
PS C:\Users\sepeh\Desktop\Bot> 

已尝试升级youtube-dl(pip install --upgrade youtube-dl)及考虑提交bug,但认为问题出在自身环境,需要针对性解决办法。

可行解决办法

1. 切换到yt-dlp替代youtube-dl

youtube-dl已长期停止维护,无法适配YouTube页面结构的更新。yt-dlp是其活跃分支,兼容性和更新频率更优:

  • 安装yt-dlp:
    pip install yt-dlp
    
  • 修改代码适配:
    import yt_dlp
    
    video_url = "https://www.youtube.com/watch?v=w9Fcgdlw-Nc"
    desired_format = 'mp4'
    
    ydl_opts = {
        'format': desired_format,
    }
    
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([video_url])
    

2. 检查并配置网络代理

若处于无法直接访问YouTube的环境,需为工具配置代理:

  • 在配置中添加代理信息(根据你的代理类型调整):
    ydl_opts = {
        'format': desired_format,
        'proxy': 'http://your-proxy-address:port', # 或socks5://your-socks-proxy:port
    }
    

3. 验证视频访问权限

手动打开目标视频链接,确认:

  • 视频未设置地区限制、年龄限制或需要登录才能观看
  • 若需登录,可导出浏览器的Cookie文件,在配置中添加:
    ydl_opts = {
        'format': desired_format,
        'cookiefile': 'path/to/your/cookie/file.txt',
    }
    

内容的提问来源于stack exchange,提问作者rar 4

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 09:44:57