6
def video_downloader(video_url_list: List[str], download_folder: str) -> None:
    """
    Download videos from a list of YouTube video URLs.
    
    Args:
        video_urls (List[str]): The list of YouTube video URLs to download.
        download_folder (str): The folder to save the downloaded videos.
    """
    successful_downloads = 0
    valid_urls: List[str] = []

    for url in video_url_list:
        if not url:
            continue

        try:
            with tempfile.TemporaryDirectory() as temp_dir:
                cleaned_url = clean_youtube_url(url=url)
                if _get_streams(url=cleaned_url, temp_dir=temp_dir):
                    create_folder(download_folder)
                    _merge_streams(
                        temp_dir=temp_dir, url=url, download_folder=download_folder
                    )
                    logger.info(f"The video from {url} was downloaded successfully")
                    successful_downloads += 1
                    valid_urls.append(url)
                else:
                    logger.warning(f"No valid video found at the URL: {url}")

        except Exception as e:
            logger.error(
                f"Error has occurred while downloading the video from {url}: {e}"
            )
            print(e)
    if successful_downloads != 0 and (successful_downloads == len(valid_urls)):
        messagebox.showinfo(
            title="Finished download",
            message=f"Your download is complete!.\n\n\t{successful_downloads}/{len(video_url_list[1:])}",
        )

This is the main function I was using to download YouTube videos using Pytube. It was working fine last night, but this morning it's not. I'm getting the error "pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple", which prevents me from downloading any video or audio. Any possible solutions?

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
AlexOAD
  • 63
  • 4
  • 2
    I am still trying to figure out why it isn't picking the new regex I am trying to update but this is an issue which has occurred in past with older versions. The key reason for this is that the changes in youtube code cause the cipher.py under pytube to fail. You must be able to find the file under site-packages. The issue is with line 272-273 of the file but I have not been able to fix it yet. Still working on doing so. – Sunil Rastogi Jun 23 '23 at 13:45
  • Hi, is there any update? If yes, please let us know. – George Jun 25 '23 at 05:51

1 Answers1

8

The work around in the official github page issue: https://github.com/pytube/pytube/issues/1684

function_patterns = [
# https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
# https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
# var Bpa = [iha];
# ...
# a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
# Bpa.length || iha("")) }};
# In the above case, `iha` is the relevant function name
r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&.*?\|\|\s*([a-z]+)',
r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])?\([a-z]\)',]
zaNe
  • 96
  • 2