randydev commited on
Commit
2b3ea96
Β·
verified Β·
1 Parent(s): aa91b74

Update Akeno/plugins/youtube.py

Browse files
Files changed (1) hide show
  1. 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
- if client.me.is_premium:
68
- caption = f"**{custom_head}𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**{custom_mata}π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**{custom_uptime}π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
69
- else:
70
- caption = f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
71
- duration_rc = time_to_seconds(yt_data["duration"])
72
- await pro.edit_media(
73
- media=InputMediaAudio(
74
- f"{yt_file}.mp3",
75
- caption=caption,
76
- duration=duration_rc,
77
- performer="[Akeno UB]",
78
- title=yt_data["title"],
79
- thumb=f"{yt_file}.jpg",
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
- if client.me.is_premium:
124
- caption = f"**{custom_head}𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**{custom_mata}π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**{custom_uptime}π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
125
- else:
126
- caption = f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
127
- await pro.edit_media(
128
- media=InputMediaAudio(
129
- f"{yt_file}.mp3",
130
- caption=caption,
131
- duration=int(yt_data["duration"]),
132
- performer="[Akeno UB]",
133
- title=yt_data["title"],
134
- thumb=f"{yt_file}.jpg",
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
- if client.me.is_premium:
183
- caption = f"**{custom_head}𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**{custom_mata}π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**{custom_uptime}π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
184
- else:
185
- caption = f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
186
- await pro.edit_media(
187
- media=InputMediaVideo(
188
- f"{yt_file}.mp4",
189
- caption=caption,
190
- duration=int(yt_data["duration"]),
191
- thumb=f"{yt_file}.jpg",
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
- if client.me.is_premium:
236
- caption = f"**{custom_head}𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**{custom_mata}π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**{custom_uptime}π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
237
- else:
238
- caption = f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`"
239
- await pro.edit_media(
240
- media=InputMediaVideo(
241
- f"{yt_file}.mp4",
242
- caption=caption,
243
- duration=int(yt_data["duration"]),
244
- thumb=f"{yt_file}.jpg",
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: