A lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.

pytube logo

pypi pypi

24 July 2020 Actively soliciting contributers!

Ping @ronncc if you would like to help out!

pytube

pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.

Installation

To install from pypi with pip:

$ python -m pip install pytube

Sometime, the pypi release becomes slightly outdated. To install from the source with pip:

$ python -m pip install git+https://github.com/pytube/pytube

Description

YouTube is the most popular video-sharing platform in the world and as a hacker you may encounter a situation where you want to script something to download videos. For this I present to you pytube.

pytube is a lightweight library written in Python. It has no third party dependencies and aims to be highly reliable.

pytube also makes pipelining easy, allowing you to specify callback functions for different download events, such as on progress or on complete.

Finally pytube also includes a command-line utility, allowing you to quickly download videos right from terminal.

Behold, a perfect balance of simplicity versus flexibility:

 >>> YouTube('https://youtu.be/2lAe1cqCOXo').streams.first().download()
 >>> yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
 >>> yt.streams
  ... .filter(progressive=True, file_extension='mp4')
  ... .order_by('resolution')
  ... .desc()
  ... .first()
  ... .download()

Features

  • Support for Both Progressive & DASH Streams
  • Support for downloading complete playlist
  • Easily Register on_download_progress & on_download_complete callbacks
  • Command-line Interfaced Included
  • Caption Track Support
  • Outputs Caption Tracks to .srt format (SubRip Subtitle)
  • Ability to Capture Thumbnail URL.
  • Extensively Documented Source Code
  • No Third-Party Dependencies

Getting started

Let's begin with showing how easy it is to download a video with pytube:

>>> from pytube import YouTube
>>> YouTube('https://youtube.com/watch?v=2lAe1cqCOXo').streams.first().download()

This example will download the highest quality progressive download stream available.

Next, let's explore how we would view what video streams are available:

>>> yt = YouTube('https://youtube.com/watch?v=2lAe1cqCOXo')
>>> yt.streams
 [<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">,
 <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">,
 <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">,
 <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="399" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.08M.08" progressive="False" type="video">,
 <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video">,
 <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="398" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.05M.08" progressive="False" type="video">,
 <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">,
 <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="397" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.04M.08" progressive="False" type="video">,
 <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">,
 <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="396" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.01M.08" progressive="False" type="video">,
 <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015" progressive="False" type="video">,
 <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="395" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.08" progressive="False" type="video">,
 <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c" progressive="False" type="video">,
 <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="394" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.08" progressive="False" type="video">,
 <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">,
 <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio">,
 <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio">,
 <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">]

You may notice that some streams listed have both a video codec and audio codec, while others have just video or just audio, this is a result of YouTube supporting a streaming technique called Dynamic Adaptive Streaming over HTTP (DASH).

In the context of pytube, the implications are for the highest quality streams; you now need to download both the audio and video tracks and then post-process them with software like FFmpeg to merge them.

The legacy streams that contain the audio and video in a single file (referred to as "progressive download") are still available, but only for resolutions 720p and below.

To only view these progressive download streams:

 >>> yt.streams.filter(progressive=True)
  [<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">,
  <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">]

Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do:

>>> yt.streams.filter(adaptive=True)
 [<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">,
 <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="399" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.08M.08" progressive="False" type="video">,
 <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video">,
 <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="398" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.05M.08" progressive="False" type="video">,
 <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">,
 <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="397" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.04M.08" progressive="False" type="video">,
 <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">,
 <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="396" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.01M.08" progressive="False" type="video">,
 <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015" progressive="False" type="video">,
 <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="395" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.08" progressive="False" type="video">,
 <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c" progressive="False" type="video">,
 <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9" progressive="False" type="video">,
 <Stream: itag="394" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.08" progressive="False" type="video">,
 <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">,
 <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio">,
 <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio">,
 <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">]

You can also interact with Youtube playlists:

>>> from pytube import Playlist
>>> pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU")
>>> for video in pl.videos:
>>>     video.streams.first().download()

Pytube allows you to filter on every property available (see the documentation for the complete list), let's take a look at some of the most useful ones.

To list the audio only streams:

>>> yt.streams.filter(only_audio=True)
  [<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">,
  <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio">,
  <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio">,
  <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">]

To list only mp4 streams:

>>> yt.streams.filter(subtype='mp4').all()
 [<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">,
 <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">,
 <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">,
 <Stream: itag="399" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.08M.08" progressive="False" type="video">,
 <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video">,
 <Stream: itag="398" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.05M.08" progressive="False" type="video">,
 <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">,
 <Stream: itag="397" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.04M.08" progressive="False" type="video">,
 <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">,
 <Stream: itag="396" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.01M.08" progressive="False" type="video">,
 <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015" progressive="False" type="video">,
 <Stream: itag="395" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.08" progressive="False" type="video">,
 <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c" progressive="False" type="video">,
 <Stream: itag="394" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.08" progressive="False" type="video">,
 <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">]

Multiple filters can also be specified:

>>> yt.streams.filter(subtype='mp4', progressive=True).all()
>>> # this can also be expressed as:
>>> yt.streams.filter(subtype='mp4').filter(progressive=True).all()
  [<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">,
  <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">]

You also have an interface to select streams by their itag, without needing to filter:

>>> yt.streams.get_by_itag(22)
  <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">

If you need to optimize for a specific feature, such as the "highest resolution" or "lowest average bitrate":

>>> yt.streams.filter(progressive=True).order_by('resolution').desc().all()
  [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">,
  <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">]

Note that order_by cannot be used if your attribute is undefined in any of the Stream instances, so be sure to apply a filter to remove those before calling it.

If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function:

 >>> def convert_to_aac(stream, file_handle):
         return  # do work

 >>> yt.register_on_complete_callback(convert_to_aac)

Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well:

 >>> def show_progress_bar(stream, chunk, bytes_remaining):
         return  # do work

 >>> yt.register_on_progress_callback(show_progress_bar)

You can also download videos to a specific directory with specific filename:

>>> yt = YouTube('https://youtube.com/watch?v=2lAe1cqCOXo')
>>> yt.streams.first().download(output_path="/tmp" ,filename='output')

Command-line interface (CLI)

Pytube also ships with a tiny CLI for interacting with videos and playlists.

To download the highest resolution progressive stream:

$ pytube https://www.youtube.com/watch?v=2lAe1cqCOXo

To view available streams:

$ pytube https://www.youtube.com/watch?v=2lAe1cqCOXo --list

To download a specific stream, use the itag

$ pytube https://www.youtube.com/watch?v=2lAe1cqCOXo --itag=22

To get a list of all subtitles (caption codes)

$ pytube https://www.youtube.com/watch?v=2lAe1cqCOXo --list-captions

To download a specific subtitle (caption code) - in this case the english subtitles (in srt format) - use:

$ pytube https://www.youtube.com/watch?v=2lAe1cqCOXo -c en

It is also possible to just download the audio stream (default AAC/mp4):

$ pytube https://www.youtube.com/watch?v=2lAe1cqCOXo -a

Finally, if you're filing a bug report, the cli contains a switch called --build-playback-report, which bundles up the state, allowing others to easily replay your issue.

Comments
  • [BUG] 'NoneType' object has no attribute 'span'

    [BUG] 'NoneType' object has no attribute 'span'

    Before creating an issue

    Please confirm that you are on the latest version of pytube by installing from the source. You can do this by running python -m pip install git+https://github.com/pytube/pytube. Sometimes, the pypi library repository is not up to date, and your issue may have been fixed already!

    Describe the bug I have been running PyTube at different points today with success and fast downloads, but as of about 30 minutes ago I started to get this when I would run it:

    'NoneType' object has no attribute 'span'

    To Reproduce I have tried on these two links, both of which were working earlier today: -https://www.youtube.com/watch?v=twtGL8WbllM&ab_channel=HarritonRams -https://www.youtube.com/watch?v=mA_3LkF_Cdo&ab_channel=IndianaSRN

    Here is the code sample where it is being used:

    def download_youtube_video(row, game_id): filename = game_id + ".mp4" try: YouTube(row[0]).streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename=filename) upload_successful = True except Exception as e: print(e) print("HEY, LOOK HERE") print("I'VE GOT SOME BAD NEWS, SADLY") print("YOU'RE GOING TO HAVE TO DOWNLOAD AND UPLOAD THIS ONE MANUALLY") print(row[0]) print(game_id) print("I TRIED TWO DIFFERENT YOUTUBE DOWNLOADER PACKAGES, BLAME THOSE F**** OVER AT GOOGLE FOR THIS")

    Expected behavior I expected the video to be downloaded in the same directory as my python script as it was earlier today.

    Output Traceback (most recent call last): File "test.py", line 3, in <module> YouTube("https://www.youtube.com/watch?v=mA_3LkF_Cdo&ab_channel=IndianaSRN").streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename="hello.mp4") File "/Users/hunterhawley/Library/Python/3.7/lib/python/site-packages/pytube/__main__.py", line 292, in streams return StreamQuery(self.fmt_streams) File "/Users/hunterhawley/Library/Python/3.7/lib/python/site-packages/pytube/__main__.py", line 177, in fmt_streams extract.apply_signature(stream_manifest, self.vid_info, self.js) File "/Users/hunterhawley/Library/Python/3.7/lib/python/site-packages/pytube/extract.py", line 409, in apply_signature cipher = Cipher(js=js) File "/Users/hunterhawley/Library/Python/3.7/lib/python/site-packages/pytube/cipher.py", line 43, in __init__ self.throttling_plan = get_throttling_plan(js) File "/Users/hunterhawley/Library/Python/3.7/lib/python/site-packages/pytube/cipher.py", line 387, in get_throttling_plan raw_code = get_throttling_function_code(js) File "/Users/hunterhawley/Library/Python/3.7/lib/python/site-packages/pytube/cipher.py", line 301, in get_throttling_function_code code_lines_list = find_object_from_startpoint(js, match.span()[1]).split('\n') AttributeError: 'NoneType' object has no attribute 'span'

    System information Please provide the following information:

    • Python version: Python 3.7.1rc1
    • Pytube version: Unsure as the provided way to find this didn't work
    • Command used to install pytube: First was python -m pip install pytube but before posting it was python -m pip install git+https://github.com/pytube/pytube
  • HTTP Error 404: Not Found when trying get stream

    HTTP Error 404: Not Found when trying get stream

    Describe the bug I need to get URL to upload the video on AWS. The code is simplest as possible

    yt = YouTube(video_url)
    streams = yt.streams
    

    The video that I want to download: http://youtube.com/watch?v=2lAe1cqCOXo On the line where we get streams, it returns the error urllib.error.HTTPError: HTTP Error 404: Not Found It's happening not always around once at 2-3 requests.

    Full error list:

    Internal Server Error: /api/external-video-upload/
    Traceback (most recent call last):
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
        response = get_response(request)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/base.py", line 179, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
        return callback(request, *args, **kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
        return view_func(*args, **kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
        return self.dispatch(request, *args, **kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
        response = self.handle_exception(exc)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
        self.raise_uncaught_exception(exc)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
        raise exc
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
        response = handler(request, *args, **kwargs)
      File "/home/alex/Developer/blossom-backend/blossom/recordings/views.py", line 819, in get
        youtube_video_upload(video_url, recording)
      File "/home/alex/Developer/blossom-backend/blossom/recordings/utils.py", line 791, in youtube_video_upload
        streams = yt.streams
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 321, in streams
        return StreamQuery(self.fmt_streams)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 214, in fmt_streams
        if "adaptive_fmts" in self.player_config_args:
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 188, in player_config_args
        self._player_config_args = self.vid_info
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 291, in vid_info
        return dict(parse_qsl(self.vid_info_raw))
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 109, in vid_info_raw
        self._vid_info_raw = request.get(self.vid_info_url)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 53, in get
        response = _execute_request(url, headers=extra_headers, timeout=timeout)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 37, in _execute_request
        return urlopen(request, timeout=timeout)  # nosec
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 214, in urlopen
        return opener.open(url, data, timeout)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 523, in open
        response = meth(req, response)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 632, in http_response
        response = self.parent.error(
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 561, in error
        return self._call_chain(*args)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 494, in _call_chain
        result = func(*args)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 641, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 404: Not Found
    Internal Server Error: /api/external-video-upload/
    Traceback (most recent call last):
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
        response = get_response(request)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/base.py", line 179, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
        return callback(request, *args, **kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
        return view_func(*args, **kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
        return self.dispatch(request, *args, **kwargs)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
        response = self.handle_exception(exc)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
        self.raise_uncaught_exception(exc)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
        raise exc
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
        response = handler(request, *args, **kwargs)
      File "/home/alex/Developer/blossom-backend/blossom/recordings/views.py", line 819, in get
        youtube_video_upload(video_url, recording)
      File "/home/alex/Developer/blossom-backend/blossom/recordings/utils.py", line 791, in youtube_video_upload
        streams = yt.streams
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 321, in streams
        return StreamQuery(self.fmt_streams)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 214, in fmt_streams
        if "adaptive_fmts" in self.player_config_args:
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 188, in player_config_args
        self._player_config_args = self.vid_info
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 291, in vid_info
        return dict(parse_qsl(self.vid_info_raw))
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 109, in vid_info_raw
        self._vid_info_raw = request.get(self.vid_info_url)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 53, in get
        response = _execute_request(url, headers=extra_headers, timeout=timeout)
      File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 37, in _execute_request
        return urlopen(request, timeout=timeout)  # nosec
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 214, in urlopen
        return opener.open(url, data, timeout)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 523, in open
        response = meth(req, response)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 632, in http_response
        response = self.parent.error(
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 561, in error
        return self._call_chain(*args)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 494, in _call_chain
        result = func(*args)
      File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 641, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 404: Not Found
    

    System information

    • Python version 3.9
    • Pytube version 10.9.3
  • urllib.error.HTTPError: HTTP Error 403: Forbidden

    urllib.error.HTTPError: HTTP Error 403: Forbidden

    Hi all,

    I'm aware that there are some older issues with the same error, howevery I thought I would just give it a try. For some videos (like this one: https://www.youtube.com/watch?v=393C3pr2ioY ) I get a 403 error...others work fine though. Do you know of any workaround for that? I saw this thread in the older issue https://stackoverflow.com/questions/16627227/http-error-403-in-python-3-web-scraping but I'm not good enough in Python to find the right spot to implement it. Any help would be appreciated.

    PS: I already updated to the most current version (9.5.0).

  • KeyError: 'url_encoded_fmt_stream_map'

    KeyError: 'url_encoded_fmt_stream_map'

    Seems like starting from today every video will cause this error when initialize a YouTube instance. Is there a quick way to fix this? I was using the same code yesterday and everything works fine.

    python version 3.6 I've tried various pytube version such as 8.0.0, 9.5.0 and 9.5.2. None of them works and all lead to this error.

    yt = YouTube('https://www.youtube.com/watch?v=p1X5A9Nmsy4') Traceback (most recent call last): File "", line 1, in File "/home/bshen/anaconda3/envs/videodata/lib/python3.6/site-packages/pytube/main.py", line 88, in init self.prefetch_init() File "/home/bshen/anaconda3/envs/videodata/lib/python3.6/site-packages/pytube/main.py", line 97, in prefetch_init self.init() File "/home/bshen/anaconda3/envs/videodata/lib/python3.6/site-packages/pytube/main.py", line 130, in init mixins.apply_descrambler(self.player_config_args, fmt) File "/home/bshen/anaconda3/envs/videodata/lib/python3.6/site-packages/pytube/mixins.py", line 89, in apply_descrambler for i in stream_data[key].split(',') KeyError: 'url_encoded_fmt_stream_map'

  • KeyError: 'cipher'

    KeyError: 'cipher'

    from pytube import YouTube
    yt = YouTube('https://www.youtube.com/watch?v=3AtDnEC4zak')
    
    ---------------------------------------------------------------------------
    KeyError                                  Traceback (most recent call last)
    ~/.conda/envs/Karaoke/lib/python3.7/site-packages/pytube/extract.py in apply_descrambler(stream_data, key)
        296                 }
    --> 297                 for format_item in formats
        298             ]
    
    ~/.conda/envs/Karaoke/lib/python3.7/site-packages/pytube/extract.py in <listcomp>(.0)
        296                 }
    --> 297                 for format_item in formats
        298             ]
    
    KeyError: 'url'
    
    During handling of the above exception, another exception occurred:
    
    KeyError                                  Traceback (most recent call last)
    <ipython-input-3-bc6543d387ce> in <module>
    ----> 1 yt = YouTube('https://www.youtube.com/watch?v=3AtDnEC4zak')
    
    ~/.conda/envs/Karaoke/lib/python3.7/site-packages/pytube/__main__.py in __init__(self, url, defer_prefetch_init, on_progress_callback, on_complete_callback, proxies)
         90         if not defer_prefetch_init:
         91             self.prefetch()
    ---> 92             self.descramble()
         93 
         94     def descramble(self) -> None:
    
    ~/.conda/envs/Karaoke/lib/python3.7/site-packages/pytube/__main__.py in descramble(self)
        130             if not self.age_restricted and fmt in self.vid_info:
        131                 apply_descrambler(self.vid_info, fmt)
    --> 132             apply_descrambler(self.player_config_args, fmt)
        133 
        134             if not self.js:
    
    ~/.conda/envs/Karaoke/lib/python3.7/site-packages/pytube/extract.py in apply_descrambler(stream_data, key)
        299         except KeyError:
        300             cipher_url = [
    --> 301                 parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
        302             ]
        303             stream_data[key] = [
    
    ~/.conda/envs/Karaoke/lib/python3.7/site-packages/pytube/extract.py in <listcomp>(.0)
        299         except KeyError:
        300             cipher_url = [
    --> 301                 parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
        302             ]
        303             stream_data[key] = [
    
    KeyError: 'cipher'
    
    
  • [BUG] Download speed getting slower and slower when downloading many videos

    [BUG] Download speed getting slower and slower when downloading many videos

    When downloading multiple videos continuously, the download speed will become slower and slower.

    image image

    System information Please provide the following information:

    • Python version (run python --version) Python 3.8.0
    • Pytube version (run print(pytube.__version__) in python) 10.8.5
    • Command used to install pytube python3.8 -m pip install pytube
  • [BUG] 'NoneType' object has no attribute 'span'

    [BUG] 'NoneType' object has no attribute 'span'

    arr = yt.streams.filter(only_video=True, file_extension='mp4')
    
    line 292, in streams
        return StreamQuery(self.fmt_streams)
      File "...\Python39\lib\site-packages\pytube\__main__.py", line 177, in fmt_streams
        extract.apply_signature(stream_manifest, self.vid_info, self.js)
      File "...\Python39\lib\site-packages\pytube\extract.py", line 409, in apply_signature
        cipher = Cipher(js=js)
      File "...\Python39\lib\site-packages\pytube\cipher.py", line 44, in __init__
        self.throttling_array = get_throttling_function_array(js)
      File "...\Python39\lib\site-packages\pytube\cipher.py", line 323, in get_throttling_function_array
        str_array = throttling_array_split(array_raw)
    
      File "...\Python39\lib\site-packages\pytube\parser.py", line 158, in throttling_array_split
        match_start, match_end = match.span()
    AttributeError: 'NoneType' object has no attribute 'span'
    

    Pytube version: 11.0.1 Python 3.9.7

  • "urllib.error.HTTPError: HTTP Error 404: Not Found" when downloading using pytube

    I've been getting this error ever since I downloaded pytube, which was only two weeks ago, but it keeps getting worse. At least 1 in 30 downloads will give me the error "urllib.error.HTTPError: HTTP Error 404: Not Found"

    When I run the loop using the same YouTube link and Download location:

    import pytube
    
    for i in range(50):
        out_file = pytube.YouTube("https://www.youtube.com/watch?v=yHwGIA4VeOc").streams.first().download("D:\Music")
        print("Done")
    

    I get the error "urllib.error.HTTPError: HTTP Error 404: Not Found" at least once during the loop. Sometimes it will give the error on the 5th download, sometimes on the 43rd. It is random. If I'm lucky it will download them all successfully, but that almost never happens.

    I've tried putting a delay between downloads and looping through a list of links instead of using the same link for each download, but neither worked.

    There is an old issue from 2019, where people have left comments having the same issue within the last two weeks, so I'm not the only one.

    Information:

    • Python 3.9.5
    • Pytube 10.8.1
    • I used "python -m pip install git+https://github.com/pytube/pytube" to download pytube
  • RegexMatchError:  (\W[\'

    RegexMatchError: (\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]) had zero matches

    Tried adding the pattern into cipher.py to no effect... help please?

    pytube==9.4.0, Python 3.7.1

    Traceback (most recent call last):
      File "filename.py", line 13, in <module>
        yt = YouTube(link, on_progress_callback=progress_function)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/__main__.py", line 88, in __init__
        self.prefetch_init()
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/__main__.py", line 96, in prefetch_init
        self.prefetch()
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/__main__.py", line 170, in prefetch
        age_restricted=self.age_restricted,
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/extract.py", line 121, in video_info_url
        group=0,
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/helpers.py", line 65, in regex_search
        .format(pattern=pattern),
    pytube.exceptions.RegexMatchError: regex pattern (\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]) had zero matches
    
    
  • [BUG] urllib.error.HTTPError: HTTP Error 404: Not Found

    [BUG] urllib.error.HTTPError: HTTP Error 404: Not Found

    Describe the bug urllib.error.HTTPError: HTTP Error 404: Not Found cannot download video or list out streams (sometimes the download did work but most of the time it throws the same error)

    To Reproduce Using Command CLI: pytube https://www.youtube.com/watch?v=1MmQUT3TjtI --list

    Expected behavior A list of streams is printed

    Output

    Traceback (most recent call last):
      File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "c:\program files\python39\lib\runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "C:\Program Files\Python39\Scripts\pytube.exe\__main__.py", line 7, in <module>
      File "c:\program files\python39\lib\site-packages\pytube\cli.py", line 50, in main
        _perform_args_on_youtube(youtube, args)
      File "c:\program files\python39\lib\site-packages\pytube\cli.py", line 63, in _perform_args_on_youtube
        display_streams(youtube)
      File "c:\program files\python39\lib\site-packages\pytube\cli.py", line 489, in display_streams
        for stream in youtube.streams:
      File "c:\program files\python39\lib\site-packages\pytube\__main__.py", line 310, in streams
        return StreamQuery(self.fmt_streams)
      File "c:\program files\python39\lib\site-packages\pytube\__main__.py", line 213, in fmt_streams
        if "adaptive_fmts" in self.player_config_args:
      File "c:\program files\python39\lib\site-packages\pytube\__main__.py", line 187, in player_config_args
        self._player_config_args = self.vid_info
      File "c:\program files\python39\lib\site-packages\pytube\__main__.py", line 280, in vid_info
        return dict(parse_qsl(self.vid_info_raw))
      File "c:\program files\python39\lib\site-packages\pytube\__main__.py", line 108, in vid_info_raw
        self._vid_info_raw = request.get(self.vid_info_url)
      File "c:\program files\python39\lib\site-packages\pytube\request.py", line 52, in get
        response = _execute_request(url, headers=extra_headers, timeout=timeout)
      File "c:\program files\python39\lib\site-packages\pytube\request.py", line 36, in _execute_request
        return urlopen(request, timeout=timeout)  # nosec
      File "c:\program files\python39\lib\urllib\request.py", line 214, in urlopen
        return opener.open(url, data, timeout)
      File "c:\program files\python39\lib\urllib\request.py", line 523, in open
        response = meth(req, response)
      File "c:\program files\python39\lib\urllib\request.py", line 632, in http_response
        response = self.parent.error(
      File "c:\program files\python39\lib\urllib\request.py", line 561, in error
        return self._call_chain(*args)
      File "c:\program files\python39\lib\urllib\request.py", line 494, in _call_chain
        result = func(*args)
      File "c:\program files\python39\lib\urllib\request.py", line 641, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 404: Not Found
    

    System information

    • Python version 3.9.5
    • Pytube version 10.8.4
    • Command used to install pytube: pip install git+https://github.com/pytube/pytube
  • ValueError: too many values to unpack (expected 2)

    ValueError: too many values to unpack (expected 2)

    Ran into this error in my main file i was using.

    So i made the most basic version i could and still got that error. Running in python 3.8 64 bit

    from pytube import YouTube yt = YouTube('https://www.youtube.com/watch?v=jNQXAC9IVRw')

    Error thrown: Traceback (most recent call last): File "c:\Users\user\Documents\My scripting projects\yt download testr\test.py", line 4, in <module> yt = YouTube('https://www.youtube.com/watch?v=jNQXAC9IVRw') File "C:\Python38\lib\site-packages\pytube\__main__.py", line 92, in __init__ self.descramble() File "C:\Python38\lib\site-packages\pytube\__main__.py", line 140, in descramble apply_signature(self.player_config_args, fmt, self.js) File "C:\Python38\lib\site-packages\pytube\extract.py", line 225, in apply_signature cipher = Cipher(js=js) File "C:\Python38\lib\site-packages\pytube\cipher.py", line 31, in __init__ var, _ = self.transform_plan[0].split(".") ValueError: too many values to unpack (expected 2)

    Is it just me or are you guys getting this error also?

  • Module prints empty titles [BUG]

    Module prints empty titles [BUG]

    Hello and thanks for your help.

    Everything is up to date.

    I'm on mac, I created a script in PyCharm that checks the youtube urls in an Excel doc and returns the video titles in a column. It works great on my computer BUT, when I create an app and an executable script file with PyInstaller, it's not returning any titles anymore and I don't get any errors when I run them with the terminal...

    I did a test where I removed the pytube module and just printed "test" in the cells and it worked, so the issue is with the pytube module...I did another test where instead of returning the titles in my Excel doc, it would print the titles in the terminal, and it's printing blank...

  • [BUG] Channe() not working when using the new http://youtube.com/@username url

    [BUG] Channe() not working when using the new http://youtube.com/@username url

    Before creating an issue

    Use the Channel() function with the URL set to the new channel ID urls "http://youtube.com/@username"

    Describe the bug the code will not work as expected with this type of URL and returns the following error

    You see my full code here: https://github.com/flyinggoatman/YouTube-Link-Extractor/blob/master/QualityYouTube.py

    The part of the code that is throwing errors is:

    ` if re.search ("/channel/", channelURL) or re.search ("@", channelURL) or re.search ("/user/", channelURL) or re.search ("/c/", channelURL):

                    # This code detects if the given URL is a channel. If the check comes back as True then it grabs the data using pytube.
                
                        
                    c = Channel(channelURL)
                    channel_name = c.channel_name
                    
                    channel_id =  c.channel_id
                    channel_id_link = "http://youtube.com/channel/"+channel_id
                    
                    print("Channel Name: "+channel_name)
                    print("Channel ID: "+channel_id) 
                    print("Channel Link: "+channel_id_link)`
    

    To Reproduce Please provide the following information:

    • Install Python3
    • Install Pytube
    • Get a channel URL that contains a "@" symbol
    • put that URL into code.

    Expected behavior Expected the pytube library to parse the link like it does with /user/, /channel/ and /c/ links.

    Output ←[31mTraceback (most recent call last): File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 409, in _run_event await coro(*args, **kwargs) File "c:\Users\[redacted]\test\QualityYouTube.py", line 108, in on_message channel_name = c.channel_name File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\contrib\channel.py", line 48, in channel_name return self.initial_data['metadata']['channelMetadataRenderer']['title'] File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\contrib\playlist.py", line 81, in initial_data self._initial_data = extract.initial_data(self.html) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\contrib\channel.py", line 78, in html self._html = request.get(self.videos_url) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\request.py", line 53, in get response = _execute_request(url, headers=extra_headers, timeout=timeout) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\request.py", line 37, in _execute_request return urlopen(request, timeout=timeout) # nosec File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen return opener.open(url, data, timeout) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open response = meth(req, response) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response response = self.parent.error( File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 557, in error result = self._call_chain(*args) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain result = func(*args) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 749, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open response = meth(req, response) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response response = self.parent.error( File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 557, in error result = self._call_chain(*args) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain result = func(*args) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 749, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open response = meth(req, response) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response response = self.parent.error( File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error return self._call_chain(*args) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain result = func(*args) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 404: Not Found←[0m PS C:\Users\[redacted]\test> c:; cd 'c:\Users\[redacted]\test'; & 'C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\[redacted]\.vscode\extensions\ms-python.python-2022.20.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '53915' '--' 'c:\Users\[redacted]\test\QualityYouTube.py' ←[30;1m2022-12-30 02:03:22←[0m ←[34;1mINFO ←[0m ←[35mdiscord.client←[0m logging in using static token ←[30;1m2022-12-30 02:03:23←[0m ←[34;1mINFO ←[0m ←[35mdiscord.gateway←[0m Shard ID None has connected to Gateway (Session ID: 8003fa54f91ca34bdc56b56901acc63c). We have logged in as QualityYouTube Bot#2815 Using Discord channel: pending-channels The bot has now fully booted up and may be used. Please be advised this bot only supports one Discord server at a time. Future updates will allow for more than one server to be active at a time. ←[30;1m2022-12-30 02:20:50←[0m ←[31mERROR ←[0m ←[35mdiscord.client←[0m Ignoring exception in on_message ←[31mTraceback (most recent call last): File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 409, in _run_event await coro(*args, **kwargs) File "c:\Users\[redacted]\test\QualityYouTube.py", line 101, in on_message c = Channel(channelURL) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\contrib\channel.py", line 24, in __init__ self.channel_uri = extract.channel_name(url) File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\extract.py", line 185, in channel_name raise RegexMatchError( pytube.exceptions.RegexMatchError: channel_name: could not find match for patterns←[0m

    System information Please provide the following information:

    • Python 3.10.9
    • pip install pytube
  • [BUG]

    [BUG]

    Before creating an issue

    Please confirm that you are on the latest version of pytube by installing from the source. You can do this by running python -m pip install git+https://github.com/pytube/pytube. Sometimes, the pypi library repository is not up to date, and your issue may have been fixed already!

    Describe the bug Unexpected renderer encountered

    To Reproduce Please provide the following information: Getting an error with Search module While trying to search for "Youtube Rewind"

    Expected behavior pytube.main.YouTube object: videoId=YbJOTdZBX1g>, Output Unexpected renderer encountered. Renderer name: dict_keys(['reelShelfRenderer']) Search term: YouTube Rewind

    System information Please provide the following information:

    • Python version (run python --version) [3.8]
    • Pytube version (run print(pytube.__version__) in python) [12.1.2]
    • Command used to install pytube [pip install pytube] Screenshot (119)
  • Unexpected renderer encountered.

    Unexpected renderer encountered.

    so i was testing z program that i created using pytube everything worked perfectly until i searched this term "central cee let her go" it actually worked fine and i downloaded the video but i got this output: Unexpected renderer encountered. Renderer name: dict_keys(['reelShelfRenderer']) Search term: central cee let her go Please open an issue at https://github.com/pytube/pytube/issues and provide this log output. other than this output everything worked fine pytube version 12.0.0

  • [BUG]

    [BUG]

    With Python 3.10.8 pytube 12.1.0 pip install pytube

    I've searched RegexMatchError on the web and it appears it had been fixed, but apparently it repeats itself.

    This is the code it's just a test: class MainPage(App): def build(self): c = Channel('https://www.youtube.com/@PyMike/videos') for url in c.video_urls[:3]: print(url) MainPage().run()

    With this channel "https://www.youtube.com/@PyMike/videos" I keep getting this error:

    Traceback (most recent call last): File "d:_python\yt_manage\main.py", line 36, in MainPage().run() File "d:_python\yt_manage\venv\lib\site-packages\kivy\app.py", line 954, in run self._run_prepare() File "d:_python\yt_manage\venv\lib\site-packages\kivy\app.py", line 924, in _run_prepare root = self.build() File "d:_python\yt_manage\main.py", line 29, in build c = Channel('https://www.youtube.com/@PyMike/videos') File "d:_python\yt_manage\venv\lib\site-packages\pytube\contrib\channel.py", line 24, in init self.channel_uri = extract.channel_name(url) File "d:_python\yt_manage\venv\lib\site-packages\pytube\extract.py", line 185, in channel_name

    raise RegexMatchError( pytube.exceptions.RegexMatchError: channel_name: could not find match for patterns

    With this other channel "https://www.youtube.com/c/ProgrammingKnowledge/videos" instead:

    Traceback (most recent call last): File "d:_python\yt_manage\venv\lib\site-packages\pytube\helpers.py", line 57, in getitem next_item = next(self.gen) StopIteration

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "d:_python\yt_manage\main.py", line 35, in MainPage().run() File "d:_python\yt_manage\venv\lib\site-packages\kivy\app.py", line 954, in run self._run_prepare() File "d:_python\yt_manage\venv\lib\site-packages\kivy\app.py", line 924, in _run_prepare root = self.build() File "d:_python\yt_manage\main.py", line 22, in build for url in c.video_urls[:3]: File "d:_python\yt_manage\venv\lib\site-packages\pytube\helpers.py", line 60, in getitem raise IndexError IndexError

    Can you help me? I just started learning python.

Command-line program to download videos from YouTube.com and other video sites

youtube-dl - download videos from youtube.com or other video platforms INSTALLATION DESCRIPTION OPTIONS CONFIGURATION OUTPUT TEMPLATE FORMAT SELECTION

Jan 7, 2023
Python wrapper for Xeno-canto API 2.0. Enables downloading bird data with one command line

Python wrapper for Xeno-canto API 2.0. Enables downloading bird data with one command line. Supports multithreading

Dec 10, 2022
Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

Telegram VCVideoPlayBot An Telegram Bot By @ZauteKm To Stream Videos in Telegram Voice Chat. NOTE: Make sure you have started a VoiceChat in your Grou

Oct 21, 2022
Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

Dec 27, 2022
📢 Video Chat Stream Telegram Bot. Can ⏳ Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Video Chat Of Channels & Groups !

Telegram Video Chat Bot (Beta) ?? Video Chat Stream Telegram Bot ?? Can Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Vide

Dec 24, 2022
Utility for downloading fanfiction in bulk from the Archive of Our Own

What is this? This is a program intended to help you download fanfiction from the Archive of Our Own in bulk. This program is primarily intended to wo

Dec 30, 2022
Script for downloading Coursera.org videos and naming them.

Coursera Downloader Coursera Downloader Introduction Features Disclaimer Installation instructions Recommended installation method for all Operating S

Jan 2, 2023
Python Library to Extract youtube video Tags without Youtube API

YoutubeTags Python Library to Extract youtube video Tags without Youtube API Installation pip install YoutubeTags Example import YoutubeTags from Yout

Nov 12, 2022
A youtube videos or channels tag finder python module

A youtube videos or channels tag finder python module

Dec 3, 2021
Python bot for send videos of a Youtube channel to a telegram group , channel or chat
Python bot for send videos of a Youtube channel to a telegram group , channel or chat

py_youtube_to_telegram Usage: If you want to install ytt and use it, run this command: sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/nima

Nov 22, 2022
Download videos from Youtube and other platforms through a Telegram Bot
Download videos from Youtube and other platforms through a Telegram Bot

ytdl-bot Download videos from YouTube and other platforms through a Telegram Bot Usage: https://t.me/benny_ytdlbot Send link from YouTube directly to

Jan 3, 2023
Telegram bot to trim and download videos from youtube.

Inline-YouTube-Trim-Bot Telegram bot to trim and download youtube videos Deploy You can deploy this bot anywhere. Demo - YouTubeBot Required Variables

Dec 11, 2022
A Telegram Bot to Play Audio in Voice Chats With Youtube and Deezer support. Supports Live streaming from youtube Supports Mega Radio Fm Streamings

Bot To Stream Musics on PyTGcalls with Channel Support. A Telegram Bot to Play Audio in Voice Chats With Supports Live streaming from youtube and Mega

Dec 15, 2022
A Telegram bot to download youtube playlists and upload them to telegram. (may be slow becoz youtube limitations)

YTPlaylistDL ?? A Telegram bot to download youtube playlists and upload them to telegram. (may be slow becoz youtube limitations) ?? Follow me and sta

Dec 28, 2022
Google Drive, OneDrive and Youtube as covert-channels - Control systems remotely by uploading files to Google Drive, OneDrive, Youtube or Telegram
Google Drive, OneDrive and Youtube as covert-channels - Control systems remotely by uploading files to Google Drive, OneDrive, Youtube or Telegram

covert-control Control systems remotely by uploading files to Google Drive, OneDrive, Youtube or Telegram using Python to create the files and the lis

Dec 6, 2022
Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Nov 21, 2021
A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster
A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster

tokeks A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster. No AWS CLI, third-party client or library (boto3, botoc

Nov 4, 2022
This is a very easy to use tool developed in python that will search for free courses from multiple sites including youtube and enroll in the ones in which it can.
This is a very easy to use tool developed in python that will search for free courses from multiple sites including youtube and enroll in the ones in which it can.

Free-Course-Hunter-and-Enroller This is a very easy to use tool developed in python that will search for free courses from multiple sites including yo

Nov 12, 2022