pytube: KeyError: 'streamingData' when trying to download video

This happens when I try to download a video using pytube. Here is the code:

import pytube

def download_video(video_url):
    youtube = pytube.YouTube(video_url)
    print("Be patient. I am now downloading your video.")
    video = youtube.streams.get_highest_resolution()
    video.download(output_path="../Downloads")
    print("Video Downloaded Successfully")

download_video(input("Paste Video Link: "))

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 27

Commits related to this issue

Most upvoted comments

Figured it out. This was as a result of an update by YouTube.

If you encounter this same error, modify youtube = pytube.YouTube(video_url) to youtube = pytube.YouTube(video_url, use_oauth=True, allow_oauth_cache=True)

This way you have to authenticate with your browser once and it’ll keep working.

Figured it out. This was as a result of an update by YouTube.

If you encounter this same error, modify youtube = pytube.YouTube(video_url) to youtube = pytube.YouTube(video_url, use_oauth=True, allow_oauth_cache=True)

This way you have to authenticate with your browser once and it’ll keep working.

It works. thanks!!

Figured it out. This was as a result of an update by YouTube.

If you encounter this same error, modify youtube = pytube.YouTube(video_url) to youtube = pytube.YouTube(video_url, use_oauth=True, allow_oauth_cache=True)

This way you have to authenticate with your browser once and it’ll keep working.

how to use it on a host server like railway?? it needs authentication.

PROBLEM SOLUTION: Upgrade pytube.

Worked fine for me.

Thanks, It works for me, I expanded on your script with a list ill leave the code here in case its useful to anyone:

import pytube

def download_video(video_url):
youtube = pytube.YouTube(video_url, use_oauth=True,allow_oauth_cache=True)
print(f"Downloading video stream: {youtube.title}")
video = youtube.streams.get_highest_resolution()
video.download(output_path="./video")
print(f"{youtube.title} downloaded successfully!")

def main():
yt_url_list = ["Put your youtube url's here","Put your youtube url's here","Put your youtube url's here"]
for x in yt_url_list:
download_video(x)

if name == "main":
main()
 import pytube

def download_video(video_url):
youtube = pytube.YouTube(video_url, use_oauth=True,allow_oauth_cache=True)
print(f"Downloading audio stream from: {youtube.title}")
video = youtube.streams.get_by_itag(140)
video.download(output_path="./audio")
print(f"{youtube.title} audio downloaded successfully!")

def main():
yt_url_list = ["Put your youtube url's here","Put your youtube url's here","Put your youtube url's here"]
for x in yt_url_list:
download_video(x)

if name == "main":
main()