[Solved] Unable to extract uploader_id – Python

by
Ali Hasan
llama-cpp-python youtube-dl

Quick Fix: To resolve this issue, update youtube-dl using the following command:

 pip install --upgrade youtube-dl 

The Problem:

When attempting to download a YouTube video using the youtube_dl library in Python, an error message is encountered: "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."

The code snippet provided is as follows:

import youtube_dl

def download_youtube_video(url):
    ydl_opts = {
        'format': 'bestvideo+bestaudio/best',
        'outtmpl': '%(title)s.%(ext)s',
    }
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        try:
            info_dict = ydl.extract_info(url, download=True)
            video_title = info_dict.get('title', None)
            print(f"Downloaded '{video_title}' successfully!")
        except Exception as e:
            print("An error occurred during the download:")
            print(str(e))

video_url = 'https://www.youtube.com/watch?v=nWxB9yiYAgo'
download_youtube_video(video_url)

What is causing this error and how can it be resolved?

The Solutions:

Solution 1: Update youtube-dl

The issue arises due to using an outdated version of youtube-dl. YouTube’s structure and protocols frequently change, and youtube-dl needs to stay up-to-date in order to handle these changes effectively.

To resolve this issue:

  • Update youtube-dl by following the instructions provided at https://yt-dl.org/update.
  • Re-run your code with the updated version of youtube-dl. This should address the error and allow you to successfully download YouTube videos.

Solution 2: Upgrading the youtube-dl Library

To resolve the issue, you need to upgrade the youtube-dl library.

You can do this using the following command:

pip install --upgrade --force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git"

Solution 3: Upgrade to yt-dlp

As indicated in the error message, youtube-dl is outdated. A modern fork called yt-dlp should be used instead. Uninstall youtube-dl and install yt-dlp using the following command:

pip install yt-dlp

Once yt-dlp is installed, the code will work as expected when updated to use yt-dlp instead of youtube-dl. The updated code:

import yt_dlp

def download_youtube_video(url):
    ydl_opts = {
        'format': 'bestvideo+bestaudio/best',
        'outtmpl': '%(title)s.%(ext)s',
    }
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        try:
            info_dict = ydl.extract_info(url, download=True)
            video_title = info_dict.get('title', None)
            print(f"Downloaded '{video_title}' successfully!")
        except Exception as e:
            print("An error occurred during the download:")
            print(str(e))

video_url = 'https://www.youtube.com/watch?v=nWxB9yiYAgo'
download_youtube_video(video_url)

Q&A

Why am I getting the error ‘Unable to extract uploader id’?

youtube-dl is out of date.

How to I fix this error?

Upgrade youtube-dl using ‘pip install –upgrade –force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git"’.

Video Explanation:

The following video, titled "Fix for youtube-dl Unable to extract uploader id - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

How to fix the unable to extract uploader id error with the latest version of youtube-dl Linux paths: ...