import os import requests from pytube import YouTube from bs4 import BeautifulSoup def download_youtube_video(url, output_path="."): try: yt = YouTube(url) video = yt.streams.filter(progressive=True, file_extension='mp4').first() video.download(output_path) print("Download successful.") except Exception as e: print("Error:", e) def download_facebook_video(url, output_path="."): try: response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') video_url = soup.find("meta", property="og:video")['content'] video_name = os.path.basename(video_url) with open(os.path.join(output_path, video_name), 'wb') as f: f.write(requests.get(video_url).content) print("Download successful.") except Exception as e: print("Error:", e) def download_twitter_video(url, output_path="."): try: response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') video_url = soup.find("meta", property="og:video")['content'] video_name = os.path.basename(video_url) with open(os.path.join(output_path, video_name), 'wb') as f: f.write(requests.get(video_url).content) print("Download successful.") except Exception as e: print("Error:", e) def download_instagram_video(url, output_path="."): try: response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') video_url = soup.find("meta", property="og:video")['content'] video_name = os.path.basename(video_url) with open(os.path.join(output_path, video_name), 'wb') as f: f.write(requests.get(video_url).content) print("Download successful.") except Exception as e: print("Error:", e) def main(): while True: platform = input("Enter social media platform (YouTube, Facebook, Twitter, Instagram) or 'exit' to quit: ").lower() if platform == "exit": break url = input("Enter video URL: ") output_path = input("Enter output directory (press Enter for current directory): ") or "." if platform == "youtube": download_youtube_video(url, output_path) elif platform == "facebook": download_facebook_video(url, output_path) elif platform == "twitter": download_twitter_video(url, output_path) elif platform == "instagram": download_instagram_video(url, output_path) else: print("Invalid platform. Please enter YouTube, Facebook, Twitter, Instagram, or 'exit'.") if __name__ == "__main__": main() /* Styles for the header */ .header { background-color: #333; /* Dark gray background */ color: #fff; /* White text color */ padding: 20px; /* Padding around the content */ } /* Styles for the main content */ .content { font-family: Arial, sans-serif; /* Font family for the content */ font-size: 16px; /* Font size */ line-height: 1.6; /* Line height */ padding: 20px; /* Padding around the content */ } /* Styles for links */ a { color: #007bff; /* Link color */ text-decoration: none; /* Remove underline */ } a:hover { text-decoration: underline; /* Add underline on hover */ } /* Styles for buttons */ .button { background-color: #007bff; /* Blue background */ color: #fff; /* White text color */ border: none; /* Remove border */ padding: 10px 20px; /* Padding inside the button */ cursor: pointer; /* Show pointer cursor on hover */ border-radius: 5px; /* Rounded corners */ } .button:hover { background-color: #0056b3; /* Darker blue on hover */ }