Skip to content

Commit 9f371c8

Browse files
committed
Youtube thumbnail will appear when user send a link with info. Also commented the unnessacary outputs.
1 parent d51aea7 commit 9f371c8

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

bot.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def check_link(message):
5757
# Get the available resoultuions of the video
5858
def getVidInfo(message):
5959

60+
# Thumbnail With Caption
61+
bot.send_photo(message.chat.id, yt.thumbnail_url, caption=f"Title: {yt.title}\nRating: {yt.rating} \nDuration: {yt.length}")
62+
6063
bot.reply_to(message, "Looking for Available Qualities..")
6164

6265
streams = yt.streams.filter(only_video=True, mime_type="video/mp4")
@@ -87,7 +90,7 @@ def callback_query(call):
8790
bot.answer_callback_query(call.id, f"Selected {received_list[1]} to download.")
8891

8992
userInput = int(received_list[0]) - 1
90-
downloadVideo(message=call.message, userInput=userInput)
93+
# downloadVideo(message=call.message, userInput=userInput)
9194

9295

9396
# Download the YouTube Video
@@ -96,25 +99,29 @@ def downloadVideo(message, userInput):
9699
videoFileName = f"{yt.title}_{videoID}.mp4"
97100
mediaPath = f"{os.getcwd()}/vids"
98101

102+
99103
streams = yt.streams.filter(only_video=True, mime_type="video/mp4")
100104
mediaPath = f"{os.getcwd()}/vids"
101105

102-
print(f"\n\n{type(userInput)}\n\n")
103-
print(userInput)
106+
# print(f"\n\n{type(userInput)}\n\n")
107+
# print(userInput)
104108

105109
try:
110+
# -------VIDEO-------
106111
bot.send_message(chat_id=message.chat.id, text="<b>Downloading...</b>📥")
107112
streams[userInput].download(filename=f"{yt.title}.mp4", output_path=mediaPath)
108-
print("Video Downloaded.")
113+
print("Video Downloaded.")
109114

110115
except:
111-
print("Wrong Input! Try Again!")
116+
print("Error while downloading the Video.")
112117

113-
# -------AUDIOS-------
114-
115-
for stream in yt.streams.filter(only_audio=True, abr="128kbps"):
116-
stream.download(filename=f"{yt.title}.mp3", output_path=mediaPath)
117-
print("Audio Downloaded. ✔")
118+
try:
119+
# -------AUDIOS-------
120+
for stream in yt.streams.filter(only_audio=True, abr="128kbps"):
121+
stream.download(filename=f"{yt.title}.mp3", output_path=mediaPath)
122+
print("Audio Downloaded.")
123+
except:
124+
print("Error while downloading the Audio.")
118125

119126
bot.send_message(chat_id=message.chat.id, text="<b>Processing...♻</b>")
120127

0 commit comments

Comments
 (0)