Pierre de Fermat
Pierre de Fermat

Reputation: 41

Download youtube videos with Pytube

I'm using the pytubeX to download videos of the YouTube, but since yesterday I'm receiving some errors that is turning impossible download videos, I try some corrections that they show in the pytube github, so I was trying to use pytube after pytube3, and I receive other errors, can you help to solve this, please? Thank you

I'm receiving a error in this line( I already fix it, before I reinstall)

base_js = get_ytplayer_config(html)["assets"]["js"]

Sometimes I receive connection refused error, of the requests and urllib error:

urllib.error.URLError: <urlopen error [WinError 10054]

My code:

# ----------------------------------------------------------------------
# Third Modules:
# ----------------------------------------------------------------------

from pytube import YouTube
from tools import test_arg

# ----------------------------------------------------------------------
# Dunder or magic methods:
# ----------------------------------------------------------------------

__all__ = [
    "ysearch"
]

# ----------------------------------------------------------------------
# Functions:
# ----------------------------------------------------------------------

def download(vlink):

    """
    """

    # --- Argument Type Test ---

    test_arg({"vlink": vlink}, [str])

    # --- Instance Creating ---

    ytv = YouTube(vlink)

    # --- Video Downloading ---

    ytv.streams[-1].download()


# ----------------------------------------------------------------------
# main():
# ----------------------------------------------------------------------


def main():
    
    links = [
        "A lot of youtube videos links"
        "..."
    ]
    
    for c in links:
        print(c)
        download(c)


if __name__ == "__main__":
    main()

# ----------------------------------------------------------------------
# EOF youtube.py
# ----------------------------------------------------------------------

Can you help-me please? Thanks!

Configurations:

Python - 3.8.6 Windows - 10 Pro x86

Upvotes: 0

Views: 490

Answers (1)

Daniel
Daniel

Reputation: 485

Try replacing PyTube files with these one. I had the same issue and I managed to fix it with this replacement. You can use "pip show pytube" to find the location of the files

Upvotes: 1

Related Questions