Pytube error "get_throttling_function_name: could not find match" when downloading YouTube videos

I’m getting an error when using the pytube library to download YouTube videos. The error occurs when the function runs video = YouTube(audio_link) and the error message is get_throttling_function_name: could not find match for multiple.

I’ve tried using different YouTube links and updating pytube to the latest version, but the error persists.

The code snippet where pytube is used is as follows:

`

# from pytube import YouTube
# import base64

# Get the video
video = YouTube(audio_link)

# Create a buffer
buffer = io.BytesIO()

# Download audio stream into memory
audio_stream = video.streams.get_audio_only()
audio_stream.stream_to_buffer(buffer)

# Base64 encode audio bytes
b64 = base64.b64encode(buffer.getvalue()).decode()

if download_link:
    # Create download link and write to Streamlit
    href = f'<a href="data:audio/mp3;base64,{b64}" download="{meeting_name}.mp3">Download audio file</a>'
    st.markdown(href, unsafe_allow_html=True)

meeting_audio = buffer.getvalue()


# Close the buffer
buffer.close()

`

Does anyone have any idea why this might be happening and how to fix it? Any help would be greatly appreciated.

The error message get_throttling_function_name: could not find match for multiple suggests that there might be an issue with the version compatibility between pytube and youtube-dl, which is a dependency of pytube.

To fix this issue, you can try the following steps:

  1. Uninstall the current version of pytube by running the command:

    pip uninstall pytube
    
  2. Install the specific version of pytube that is known to work with youtube-dl. Use the command:

    pip install pytube==10.0.0
    

    Note: Make sure to replace 10.0.0 with the latest version of pytube that is compatible with youtube-dl. You can find the latest compatible version in the pytube documentation.

  3. Install youtube-dl separately by running the command:

    pip install youtube-dl
    
  4. Run your code again and check if the error persists.

By following these steps, you should be able to resolve the compatibility issue between pytube and youtube-dl and download YouTube videos successfully.