Upload 4 files
Browse files- Akeno/plugins/__init__.py +18 -1
- Akeno/plugins/id.py +13 -4
- Akeno/plugins/info.py +7 -15
- Akeno/plugins/youtube.py +111 -2
Akeno/plugins/__init__.py
CHANGED
@@ -1 +1,18 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import glob
|
2 |
+
from os.path import basename, dirname, isfile
|
3 |
+
|
4 |
+
from Akeno.utils.logger import LOGS
|
5 |
+
|
6 |
+
|
7 |
+
def __list_all_modules():
|
8 |
+
mod_paths = glob.glob(dirname(__file__) + "/*.py")
|
9 |
+
all_modules = [
|
10 |
+
basename(f)[:-3]
|
11 |
+
for f in mod_paths
|
12 |
+
if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py")
|
13 |
+
]
|
14 |
+
return all_modules
|
15 |
+
|
16 |
+
ALL_MODULES = sorted(__list_all_modules())
|
17 |
+
LOGS.info("Modules to load: %s", str(ALL_MODULES))
|
18 |
+
__all__ = ALL_MODULES + ["ALL_MODULES"]
|
Akeno/plugins/id.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1 |
-
import os
|
2 |
import asyncio
|
|
|
3 |
import random
|
4 |
import time
|
|
|
5 |
from pyrogram import Client, filters
|
|
|
6 |
from pyrogram.types import Message
|
|
|
7 |
from Akeno.utils.handler import *
|
8 |
from config import *
|
9 |
|
|
|
10 |
@Akeno(
|
11 |
~filters.scheduled
|
12 |
& filters.command(["id"], CMD_HANDLER)
|
@@ -84,7 +88,7 @@ async def get_id(bot: Client, message: Message):
|
|
84 |
f"**Forwarded User ID**: `{message.reply_to_message.forward_from.id}`\n"
|
85 |
)
|
86 |
else:
|
87 |
-
user_detail = (
|
88 |
f"**User ID**: `{message.reply_to_message.from_user.id if message.reply_to_message.from_user else None}`\n"
|
89 |
f"**Sender Chat ID**: `{message.reply_to_message.sender_chat.id if message.reply_to_message.sender_chat else None}`\n"
|
90 |
f"**Sender Chat Title**: `{message.reply_to_message.sender_chat.title if message.reply_to_message.sender_chat else None}`\n"
|
@@ -92,6 +96,11 @@ async def get_id(bot: Client, message: Message):
|
|
92 |
)
|
93 |
user_detail += f"**Message ID**: `{message.reply_to_message.id}`\n\n"
|
94 |
user_detail += file_id
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
96 |
else:
|
97 |
-
await message.
|
|
|
|
|
1 |
import asyncio
|
2 |
+
import os
|
3 |
import random
|
4 |
import time
|
5 |
+
|
6 |
from pyrogram import Client, filters
|
7 |
+
from pyrogram.errors import *
|
8 |
from pyrogram.types import Message
|
9 |
+
|
10 |
from Akeno.utils.handler import *
|
11 |
from config import *
|
12 |
|
13 |
+
|
14 |
@Akeno(
|
15 |
~filters.scheduled
|
16 |
& filters.command(["id"], CMD_HANDLER)
|
|
|
88 |
f"**Forwarded User ID**: `{message.reply_to_message.forward_from.id}`\n"
|
89 |
)
|
90 |
else:
|
91 |
+
user_detail = (
|
92 |
f"**User ID**: `{message.reply_to_message.from_user.id if message.reply_to_message.from_user else None}`\n"
|
93 |
f"**Sender Chat ID**: `{message.reply_to_message.sender_chat.id if message.reply_to_message.sender_chat else None}`\n"
|
94 |
f"**Sender Chat Title**: `{message.reply_to_message.sender_chat.title if message.reply_to_message.sender_chat else None}`\n"
|
|
|
96 |
)
|
97 |
user_detail += f"**Message ID**: `{message.reply_to_message.id}`\n\n"
|
98 |
user_detail += file_id
|
99 |
+
try:
|
100 |
+
await message.reply_text(user_detail)
|
101 |
+
except ChannelInvalid:
|
102 |
+
await message.reply_text("Channel Invalid")
|
103 |
+
except Exception as e:
|
104 |
+
await message.reply_text(f"Error: {e}")
|
105 |
else:
|
106 |
+
await message.reply_text(f"**Chat ID**: `{message.chat.id}`")
|
Akeno/plugins/info.py
CHANGED
@@ -30,20 +30,12 @@ async def who_is(client: Client, message: Message):
|
|
30 |
try:
|
31 |
user = await client.get_users(user_id)
|
32 |
username = f"@{user.username}" if user.username else "-"
|
33 |
-
first_name =
|
34 |
-
last_name =
|
35 |
-
fullname =
|
36 |
-
|
37 |
-
)
|
38 |
-
|
39 |
-
bio = f"{user_details}" if user_details else "-"
|
40 |
-
h = f"{user.status}"
|
41 |
-
if h.startswith("UserStatus"):
|
42 |
-
y = h.replace("UserStatus.", "")
|
43 |
-
status = y.capitalize()
|
44 |
-
else:
|
45 |
-
status = "-"
|
46 |
-
dc_id = f"{user.dc_id}" if user.dc_id else "-"
|
47 |
common = await client.get_common_chats(user.id)
|
48 |
out_str = f"""<b>USER INFORMATION:</b>
|
49 |
|
@@ -83,4 +75,4 @@ async def who_is(client: Client, message: Message):
|
|
83 |
return await ex.edit(f"**INFO:** `{e}`")
|
84 |
|
85 |
module = modules_help.add_module("info", __file__)
|
86 |
-
module.add_command("info", "to info view users.")
|
|
|
30 |
try:
|
31 |
user = await client.get_users(user_id)
|
32 |
username = f"@{user.username}" if user.username else "-"
|
33 |
+
first_name = user.first_name or "-"
|
34 |
+
last_name = user.last_name or "-"
|
35 |
+
fullname = f"{user.first_name} {user.last_name}" if user.last_name else user.first_name
|
36 |
+
user_details = (await client.get_chat(user.id)).bio or "-"
|
37 |
+
status = user.status.replace("UserStatus.", "").capitalize() if user.status.startswith("UserStatus") else "-"
|
38 |
+
dc_id = user.dc_id or "-"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
common = await client.get_common_chats(user.id)
|
40 |
out_str = f"""<b>USER INFORMATION:</b>
|
41 |
|
|
|
75 |
return await ex.edit(f"**INFO:** `{e}`")
|
76 |
|
77 |
module = modules_help.add_module("info", __file__)
|
78 |
+
module.add_command("info", "to info view users.")
|
Akeno/plugins/youtube.py
CHANGED
@@ -3,6 +3,7 @@ import time
|
|
3 |
|
4 |
import requests
|
5 |
from pyrogram.types import Message
|
|
|
6 |
from yt_dlp import YoutubeDL
|
7 |
|
8 |
from Akeno.utils.database import db
|
@@ -14,6 +15,60 @@ from Akeno.utils.scripts import progress
|
|
14 |
from config import *
|
15 |
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
@Akeno(
|
18 |
~filters.scheduled
|
19 |
& filters.command(["yta"], CMD_HANDLER)
|
@@ -64,6 +119,58 @@ async def youtube_audio(_, message: Message):
|
|
64 |
except:
|
65 |
pass
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
@Akeno(
|
68 |
~filters.scheduled
|
69 |
& filters.command(["ytv"], CMD_HANDLER)
|
@@ -135,6 +242,8 @@ async def ytlink(_, message: Message):
|
|
135 |
await pro.edit_text(text, disable_web_page_preview=True)
|
136 |
|
137 |
module = modules_help.add_module("youtube", __file__)
|
138 |
-
module.add_command("yta", "Download the youtube video in .mp3 format!.")
|
139 |
-
module.add_command("ytv", "Download the youtube video in .
|
|
|
|
|
140 |
module.add_command("ytlink", "Search for a video on youtube")
|
|
|
3 |
|
4 |
import requests
|
5 |
from pyrogram.types import Message
|
6 |
+
from youtube_search import YoutubeSearch
|
7 |
from yt_dlp import YoutubeDL
|
8 |
|
9 |
from Akeno.utils.database import db
|
|
|
15 |
from config import *
|
16 |
|
17 |
|
18 |
+
@Akeno(
|
19 |
+
~filters.scheduled
|
20 |
+
& filters.command(["ytsa"], CMD_HANDLER)
|
21 |
+
& filters.me
|
22 |
+
& ~filters.forwarded
|
23 |
+
)
|
24 |
+
async def youtube_search_audio(_, message: Message):
|
25 |
+
if len(message.command) < 2:
|
26 |
+
return await message.reply_text(
|
27 |
+
"Give a valid youtube search to download audio."
|
28 |
+
)
|
29 |
+
query = await input_user(message)
|
30 |
+
results = YoutubeSearch(query, max_results=5).to_dict()
|
31 |
+
watch = results[0]["url_suffix"]
|
32 |
+
url_suffix = watch.split("/")[1]
|
33 |
+
okk = f"https://youtube.com/{url_suffix}"
|
34 |
+
pro = await message.reply_text("Checking ...")
|
35 |
+
status, url = YoutubeDriver.check_url(okk)
|
36 |
+
if not status:
|
37 |
+
return await pro.edit_text(url)
|
38 |
+
await pro.edit_text("πΌ __Downloading audio ...__")
|
39 |
+
try:
|
40 |
+
with YoutubeDL(YoutubeDriver.song_options()) as ytdl:
|
41 |
+
yt_data = ytdl.extract_info(url, False)
|
42 |
+
yt_file = ytdl.prepare_filename(yt_data)
|
43 |
+
ytdl.process_info(yt_data)
|
44 |
+
upload_text = f"**β¬οΈ π΄ππ
ππΊπ½πππ π²πππ ...** \n\n**π³πππ
πΎ:** `{yt_data['title'][:50]}`\n**π’ππΊπππΎπ
:** `{yt_data['channel']}`"
|
45 |
+
await pro.edit_text(upload_text)
|
46 |
+
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
47 |
+
with open(f"{yt_file}.jpg", "wb") as f:
|
48 |
+
f.write(response.content)
|
49 |
+
await message.reply_audio(
|
50 |
+
f"{yt_file}.mp3",
|
51 |
+
caption=f"**π§ π³πππ
πΎ:** {yt_data['title']} \n\n**π π΅ππΎππ:** `{yt_data['view_count']}` \n**β π£πππΊππππ:** `{secs_to_mins(int(yt_data['duration']))}`",
|
52 |
+
duration=int(yt_data["duration"]),
|
53 |
+
performer="[Akeno UB]",
|
54 |
+
title=yt_data["title"],
|
55 |
+
thumb=f"{yt_file}.jpg",
|
56 |
+
progress=progress,
|
57 |
+
progress_args=(
|
58 |
+
pro,
|
59 |
+
time.time(),
|
60 |
+
upload_text,
|
61 |
+
),
|
62 |
+
)
|
63 |
+
await pro.delete()
|
64 |
+
except Exception as e:
|
65 |
+
return await pro.edit_text(f"**π Audio not Downloaded:** `{e}`")
|
66 |
+
try:
|
67 |
+
os.remove(f"{yt_file}.jpg")
|
68 |
+
os.remove(f"{yt_file}.mp3")
|
69 |
+
except:
|
70 |
+
pass
|
71 |
+
|
72 |
@Akeno(
|
73 |
~filters.scheduled
|
74 |
& filters.command(["yta"], CMD_HANDLER)
|
|
|
119 |
except:
|
120 |
pass
|
121 |
|
122 |
+
@Akeno(
|
123 |
+
~filters.scheduled
|
124 |
+
& filters.command(["ytva"], CMD_HANDLER)
|
125 |
+
& filters.me
|
126 |
+
& ~filters.forwarded
|
127 |
+
)
|
128 |
+
async def ytvideo_search(client: Client, message: Message):
|
129 |
+
if len(message.command) < 2:
|
130 |
+
return await message.reply_text(
|
131 |
+
"Give a valid youtube search to download video."
|
132 |
+
)
|
133 |
+
query = await input_user(message)
|
134 |
+
results = YoutubeSearch(query, max_results=5).to_dict()
|
135 |
+
watch = results[0]["url_suffix"]
|
136 |
+
url_suffix = watch.split("/")[1]
|
137 |
+
okk = f"https://youtube.com/{url_suffix}"
|
138 |
+
pro = await message.reply_text("Checking ...")
|
139 |
+
status, url = YoutubeDriver.check_url(okk)
|
140 |
+
if not status:
|
141 |
+
return await pro.edit_text(url)
|
142 |
+
await pro.edit_text("πΌ __Downloading video ...__")
|
143 |
+
try:
|
144 |
+
with YoutubeDL(YoutubeDriver.video_options()) as ytdl:
|
145 |
+
yt_data = ytdl.extract_info(url, True)
|
146 |
+
yt_file = yt_data["id"]
|
147 |
+
|
148 |
+
upload_text = f"**β¬οΈ π΄ππ
ππΊπ½πππ π²πππ ...** \n\n**π³πππ
πΎ:** `{yt_data['title'][:50]}`\n**π’ππΊπππΎπ
:** `{yt_data['channel']}`"
|
149 |
+
await pro.edit_text(upload_text)
|
150 |
+
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
|
151 |
+
with open(f"{yt_file}.jpg", "wb") as f:
|
152 |
+
f.write(response.content)
|
153 |
+
await message.reply_video(
|
154 |
+
f"{yt_file}.mp4",
|
155 |
+
caption=f"**π§ π³πππ
πΎ:** {yt_data['title']} \n\n**π π΅ππΎππ:** `{yt_data['view_count']}` \n**β π£πππΊππππ:** `{secs_to_mins(int(yt_data['duration']))}`",
|
156 |
+
duration=int(yt_data["duration"]),
|
157 |
+
thumb=f"{yt_file}.jpg",
|
158 |
+
progress=progress,
|
159 |
+
progress_args=(
|
160 |
+
pro,
|
161 |
+
time.time(),
|
162 |
+
upload_text,
|
163 |
+
),
|
164 |
+
)
|
165 |
+
await pro.delete()
|
166 |
+
except Exception as e:
|
167 |
+
return await pro.edit_text(f"**π Video not Downloaded:** `{e}`")
|
168 |
+
try:
|
169 |
+
os.remove(f"{yt_file}.jpg")
|
170 |
+
os.remove(f"{yt_file}.mp4")
|
171 |
+
except:
|
172 |
+
pass
|
173 |
+
|
174 |
@Akeno(
|
175 |
~filters.scheduled
|
176 |
& filters.command(["ytv"], CMD_HANDLER)
|
|
|
242 |
await pro.edit_text(text, disable_web_page_preview=True)
|
243 |
|
244 |
module = modules_help.add_module("youtube", __file__)
|
245 |
+
module.add_command("yta", "Download the youtube link video in .mp3 format!.")
|
246 |
+
module.add_command("ytv", "Download the youtube link video in .mp3 format!.")
|
247 |
+
module.add_command("ytsa", "Download the youtube search video in .mp3 format!.")
|
248 |
+
module.add_command("ytva", "Download the youtube search video in .mp4 format!")
|
249 |
module.add_command("ytlink", "Search for a video on youtube")
|