Youtube Downloader using Python


VIDEO :- 

SOURCE_CODE :- 


from pytube import YouTube
import os
 
# url input from user
yt = YouTube(
    str(input("Enter the URL of the video you want to download: \n>> ")))
 
# extract only audio
video = yt.streams.filter(only_audio=True).first()
 
# check for destination to save file
print("Enter the destination (leave blank for current directory)")
destination = str(input(">> ")) or '.'
 
# download the file
out_file = video.download(output_path=destination)
 
# save the file
base, ext = os.path.splitext(out_file)
new_file = base + '.mp3'
os.rename(out_file, new_file)


1 comment:

  1. i get this error:
    cipher = Cipher(js=js)
    File "C:\Users\32489\PycharmProjects\pythonProject8\venv\lib\site-packages\pytube\cipher.py", line 43, in __init__
    self.throttling_plan = get_throttling_plan(js)
    File "C:\Users\32489\PycharmProjects\pythonProject8\venv\lib\site-packages\pytube\cipher.py", line 387, in get_throttling_plan
    raw_code = get_throttling_function_code(js)
    File "C:\Users\32489\PycharmProjects\pythonProject8\venv\lib\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'

    Process finished with exit code 1

    ReplyDelete