Update Akeno/plugins/youtube.py
Browse files- Akeno/plugins/youtube.py +54 -60
Akeno/plugins/youtube.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import os
|
2 |
import time
|
|
|
3 |
import requests
|
4 |
-
from pyrogram.types import
|
5 |
from pyrogram import Client, filters
|
6 |
from youtube_search import YoutubeSearch
|
7 |
from yt_dlp import YoutubeDL
|
@@ -16,16 +17,6 @@ from Akeno.utils.prefixprem import command
|
|
16 |
from config import *
|
17 |
|
18 |
custom_loading = "<emoji id=5974235702701853774>πΏ</emoji>"
|
19 |
-
custom_head = "<emoji id=5316919120149619748>π€</emoji>"
|
20 |
-
custom_mata = "<emoji id=5253959125838090076>π€</emoji>"
|
21 |
-
custom_uptime = "<emoji id=5451732530048802485>π€</emoji>"
|
22 |
-
|
23 |
-
def time_to_seconds(time):
|
24 |
-
stringt = str(time)
|
25 |
-
return sum(
|
26 |
-
int(x) * 60**i
|
27 |
-
for i, x in enumerate(reversed(stringt.split(":")))
|
28 |
-
)
|
29 |
|
30 |
@Akeno(
|
31 |
~filters.scheduled
|
@@ -64,21 +55,21 @@ async def youtube_search_audio(client: Client, message: Message):
|
|
64 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
65 |
with open(f"{yt_file}.jpg", "wb") as f:
|
66 |
f.write(response.content)
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
)
|
81 |
)
|
|
|
82 |
except Exception as e:
|
83 |
return await pro.edit_text(f"**π Audio not Downloaded:** `{e}`")
|
84 |
try:
|
@@ -120,20 +111,21 @@ async def youtube_audio(client: Client, message: Message):
|
|
120 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
121 |
with open(f"{yt_file}.jpg", "wb") as f:
|
122 |
f.write(response.content)
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
)
|
136 |
)
|
|
|
137 |
except Exception as e:
|
138 |
return await pro.edit_text(f"**π Audio not Downloaded:** `{e}`")
|
139 |
try:
|
@@ -179,18 +171,19 @@ async def ytvideo_search(client: Client, message: Message):
|
|
179 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
180 |
with open(f"{yt_file}.jpg", "wb") as f:
|
181 |
f.write(response.content)
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
)
|
193 |
)
|
|
|
194 |
except Exception as e:
|
195 |
return await pro.edit_text(f"**π Video not Downloaded:** `{e}`")
|
196 |
try:
|
@@ -232,18 +225,19 @@ async def ytvideo(client: Client, message: Message):
|
|
232 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
233 |
with open(f"{yt_file}.jpg", "wb") as f:
|
234 |
f.write(response.content)
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
)
|
246 |
)
|
|
|
247 |
except Exception as e:
|
248 |
return await pro.edit_text(f"**π Video not Downloaded:** `{e}`")
|
249 |
try:
|
|
|
1 |
import os
|
2 |
import time
|
3 |
+
|
4 |
import requests
|
5 |
+
from pyrogram.types import Message
|
6 |
from pyrogram import Client, filters
|
7 |
from youtube_search import YoutubeSearch
|
8 |
from yt_dlp import YoutubeDL
|
|
|
17 |
from config import *
|
18 |
|
19 |
custom_loading = "<emoji id=5974235702701853774>πΏ</emoji>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@Akeno(
|
22 |
~filters.scheduled
|
|
|
55 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
56 |
with open(f"{yt_file}.jpg", "wb") as f:
|
57 |
f.write(response.content)
|
58 |
+
await message.reply_audio(
|
59 |
+
f"{yt_file}.mp3",
|
60 |
+
caption=f"**π§ π³πππ
πΎ:** {yt_data['title']} \n\n**π π΅ππΎππ:** `{yt_data['view_count']}` \n**β π£πππΊππππ:** `{secs_to_mins(int(yt_data['duration']))}`",
|
61 |
+
duration=int(yt_data["duration"]),
|
62 |
+
performer="[Akeno UB]",
|
63 |
+
title=yt_data["title"],
|
64 |
+
thumb=f"{yt_file}.jpg",
|
65 |
+
progress=progress,
|
66 |
+
progress_args=(
|
67 |
+
pro,
|
68 |
+
time.time(),
|
69 |
+
upload_text,
|
70 |
+
),
|
|
|
71 |
)
|
72 |
+
await pro.delete()
|
73 |
except Exception as e:
|
74 |
return await pro.edit_text(f"**π Audio not Downloaded:** `{e}`")
|
75 |
try:
|
|
|
111 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
112 |
with open(f"{yt_file}.jpg", "wb") as f:
|
113 |
f.write(response.content)
|
114 |
+
await message.reply_audio(
|
115 |
+
f"{yt_file}.mp3",
|
116 |
+
caption=f"**π§ π³πππ
πΎ:** {yt_data['title']} \n\n**π π΅ππΎππ:** `{yt_data['view_count']}` \n**β π£πππΊππππ:** `{secs_to_mins(int(yt_data['duration']))}`",
|
117 |
+
duration=int(yt_data["duration"]),
|
118 |
+
performer="[Akeno UB]",
|
119 |
+
title=yt_data["title"],
|
120 |
+
thumb=f"{yt_file}.jpg",
|
121 |
+
progress=progress,
|
122 |
+
progress_args=(
|
123 |
+
pro,
|
124 |
+
time.time(),
|
125 |
+
upload_text,
|
126 |
+
),
|
127 |
)
|
128 |
+
await pro.delete()
|
129 |
except Exception as e:
|
130 |
return await pro.edit_text(f"**π Audio not Downloaded:** `{e}`")
|
131 |
try:
|
|
|
171 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
172 |
with open(f"{yt_file}.jpg", "wb") as f:
|
173 |
f.write(response.content)
|
174 |
+
await message.reply_video(
|
175 |
+
f"{yt_file}.mp4",
|
176 |
+
caption=f"**π§ π³πππ
πΎ:** {yt_data['title']} \n\n**π π΅ππΎππ:** `{yt_data['view_count']}` \n**β π£πππΊππππ:** `{secs_to_mins(int(yt_data['duration']))}`",
|
177 |
+
duration=int(yt_data["duration"]),
|
178 |
+
thumb=f"{yt_file}.jpg",
|
179 |
+
progress=progress,
|
180 |
+
progress_args=(
|
181 |
+
pro,
|
182 |
+
time.time(),
|
183 |
+
upload_text,
|
184 |
+
),
|
185 |
)
|
186 |
+
await pro.delete()
|
187 |
except Exception as e:
|
188 |
return await pro.edit_text(f"**π Video not Downloaded:** `{e}`")
|
189 |
try:
|
|
|
225 |
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
226 |
with open(f"{yt_file}.jpg", "wb") as f:
|
227 |
f.write(response.content)
|
228 |
+
await message.reply_video(
|
229 |
+
f"{yt_file}.mp4",
|
230 |
+
caption=f"**π§ π³πππ
πΎ:** {yt_data['title']} \n\n**π π΅ππΎππ:** `{yt_data['view_count']}` \n**β π£πππΊππππ:** `{secs_to_mins(int(yt_data['duration']))}`",
|
231 |
+
duration=int(yt_data["duration"]),
|
232 |
+
thumb=f"{yt_file}.jpg",
|
233 |
+
progress=progress,
|
234 |
+
progress_args=(
|
235 |
+
pro,
|
236 |
+
time.time(),
|
237 |
+
upload_text,
|
238 |
+
),
|
239 |
)
|
240 |
+
await pro.delete()
|
241 |
except Exception as e:
|
242 |
return await pro.edit_text(f"**π Video not Downloaded:** `{e}`")
|
243 |
try:
|