Skip to content

Adding some Feature, That make the App better #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions history.yt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

86 changes: 68 additions & 18 deletions ytDownloader.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,70 @@
from pytube import YouTube
import os, time

try:
# Ask the user to input the YouTube URL
url = input("Enter the YouTube URL: ")

yt = YouTube(url)

print("Title:", yt.title)
print("Views:", yt.views)

# Get the highest resolution stream
yd = yt.streams.get_highest_resolution()

# Download the video to the current directory
yd.download()

print("Download complete.")
except Exception as e:
print("An error occurred:", str(e))

def home():
print("\033[31mYoutube Video Downloader\033[0m")
print("1. Download Video \n2. See Download History")
inpt = input("> ").strip().lower()
if inpt == "1":
download()
elif inpt == "2":
history()
else:
print("Input not valid. You will directed to download.")
time.sleep(2)
os.system("clear")
download()


def download():
os.system("clear")
try:
url = input("Enter the YouTube Video URL: ")
yt = YouTube(url)
os.system("clear")
print("Video URL :", url)
print("Video Title:", yt.title)
print("Video Views:", yt.views)
print()
print("\033[32mVideo caught. Request the highest resolution...\033[0m")
yd = yt.streams.get_highest_resolution()
os.system("clear")
print("Video URL :", url)
print("Video Title:", yt.title)
print("Video Views:", yt.views)
print()
print(
"\033[32mThe highest resolution video has been obtained. Downloading Videos...\033[0m"
)
yd.download()
os.system("clear")
print("\033[32mDownload complete.\033[0m")
f = open("history.yt", "a+")
f.write(
f"\nVideo URL: {url}\nVideo Title: {yt.title}\nVideo Views: {yt.views}"
)
f.write("\n-----------------")
f.close()
time.sleep(2)
os.system("clear")
home()
except Exception as e:
print("An error occurred:", str(e))
time.sleep(2)
os.system("clear")
home()


def history():
os.system("clear")
f = open("history.yt", "r")
data = f.read()
print(data)
print()
exit = input("Press enter to exit. ")
os.system("clear")
home()


home()