new


import requests
from bs4 import BeautifulSoup

def download_video(url):
    response = requests.get(f'https://en.savefrom.net/1/#url={url}')
    soup = BeautifulSoup(response.content, 'html.parser')
    download_link = soup.find('a', {'class': 'def-btn-box'})['href']
    video_response = requests.get(download_link, stream=True)
    filename = f'{soup.find("div", {"class": "title"}).text.strip()}.mp4'
    with open(filename, 'wb') as f:
        for chunk in video_response.iter_content(chunk_size=1024):
            if chunk:
                f.write(chunk)
    print(f'Download complete: {filename}')

if __name__ == '__main__':
    url = input('Enter the URL of the YouTube video: ')
    download_video(url)

No comments:

Post a Comment