imseldrith commited on
Commit
9aef05f
1 Parent(s): cf1feb4

Upload 10 files

Browse files
plugins/admin.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # (c) @AbirHasan2005 | Modifieded By : @DC4_WARRIOR
3
+
4
+
5
+ from pyrogram import Client as Clinton
6
+ from pyrogram import filters
7
+ from config import Config
8
+ from database.access import clinton
9
+ from plugins.buttons import *
10
+ @Clinton.on_message(filters.private & filters.command('total'))
11
+ async def sts(c, m):
12
+ if m.from_user.id != Config.OWNER_ID:
13
+ return
14
+ total_users = await clinton.total_users_count()
15
+ await m.reply_text(text=f"Total user(s) {total_users}", quote=True)
16
+
17
+
18
+ @Clinton.on_message(filters.private & filters.command("search"))
19
+ async def serc(bot, update):
20
+
21
+ await bot.send_message(chat_id=update.chat.id, text="🔍 TORRENT SEARCH",
22
+ parse_mode="html", reply_markup=Button.BUTTONS01)
plugins/broadcast.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # (c) @AbirHasan2005 | X-Noid
3
+
4
+ import traceback, datetime, asyncio, string, random, time, os, aiofiles, aiofiles.os
5
+ from database.access import clinton
6
+ from pyrogram import filters
7
+ from pyrogram import Client as Clinton
8
+ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
9
+ from pyrogram.errors import FloodWait, InputUserDeactivated, UserIsBlocked, PeerIdInvalid
10
+
11
+ from config import Config
12
+ broadcast_ids = {}
13
+
14
+ async def send_msg(user_id, message):
15
+ try:
16
+ await message.copy(chat_id=user_id)
17
+ return 200, None
18
+ except FloodWait as e:
19
+ await asyncio.sleep(e.x)
20
+ return send_msg(user_id, message)
21
+ except InputUserDeactivated:
22
+ return 400, f"{user_id} : deactivated\n"
23
+ except UserIsBlocked:
24
+ return 400, f"{user_id} : blocked the bot\n"
25
+ except PeerIdInvalid:
26
+ return 400, f"{user_id} : user id invalid\n"
27
+ except Exception as e:
28
+ return 500, f"{user_id} : {traceback.format_exc()}\n"
29
+
30
+
31
+ @Clinton.on_message(filters.private & filters.command('broadcast') & filters.reply)
32
+ async def broadcast_(c, m):
33
+ if m.from_user.id != Config.OWNER_ID:
34
+ return
35
+ all_users = await clinton.get_all_users()
36
+
37
+ broadcast_msg = m.reply_to_message
38
+
39
+ while True:
40
+ broadcast_id = ''.join([random.choice(string.ascii_letters) for i in range(3)])
41
+ if not broadcast_ids.get(broadcast_id):
42
+ break
43
+
44
+ out = await m.reply_text(
45
+ text = f"Broadcast initiated! You will be notified with log file when all the users are notified."
46
+ )
47
+ start_time = time.time()
48
+ total_users = await clinton.total_users_count()
49
+ done = 0
50
+ failed = 0
51
+ success = 0
52
+
53
+ broadcast_ids[broadcast_id] = dict(
54
+ total = total_users,
55
+ current = done,
56
+ failed = failed,
57
+ success = success
58
+ )
59
+
60
+ async with aiofiles.open('broadcast.txt', 'w') as broadcast_log_file:
61
+ async for user in all_users:
62
+
63
+ sts, msg = await send_msg(
64
+ user_id = int(user['id']),
65
+ message = broadcast_msg
66
+ )
67
+ if msg is not None:
68
+ await broadcast_log_file.write(msg)
69
+
70
+ if sts == 200:
71
+ success += 1
72
+ else:
73
+ failed += 1
74
+
75
+ if sts == 400:
76
+ await clinton.delete_user(user['id'])
77
+
78
+ done += 1
79
+ if broadcast_ids.get(broadcast_id) is None:
80
+ break
81
+ else:
82
+ broadcast_ids[broadcast_id].update(
83
+ dict(
84
+ current = done,
85
+ failed = failed,
86
+ success = success
87
+ )
88
+ )
89
+ if broadcast_ids.get(broadcast_id):
90
+ broadcast_ids.pop(broadcast_id)
91
+ completed_in = datetime.timedelta(seconds=int(time.time()-start_time))
92
+
93
+ await asyncio.sleep(3)
94
+
95
+ await out.delete()
96
+
97
+ if failed == 0:
98
+ await m.reply_text(
99
+ text=f"broadcast completed in `{completed_in}`\n\nTotal users {total_users}.\nTotal done {done}, {success} success and {failed} failed.",
100
+ quote=True
101
+ )
102
+ else:
103
+ await m.reply_document(
104
+ document='broadcast.txt',
105
+ caption=f"broadcast completed in `{completed_in}`\n\nTotal users {total_users}.\nTotal done {done}, {success} success and {failed} failed.",
106
+ quote=True
107
+ )
108
+
109
+ await aiofiles.os.remove('broadcast.txt')
plugins/buttons.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
4
+
5
+
6
+ class Button(object):
7
+
8
+ BUTTONS01 = InlineKeyboardMarkup( [ [ InlineKeyboardButton(text="📁 YTS", callback_data='00'),
9
+ InlineKeyboardButton(text="🔍 ꜱᴇᴀʀᴄʜ", switch_inline_query_current_chat="1 ") ],
10
+ [ InlineKeyboardButton(text="📁 Anime", callback_data='00'),
11
+ InlineKeyboardButton(text="🔍 ꜱᴇᴀʀᴄʜ", switch_inline_query_current_chat="2 ") ],
12
+ [ InlineKeyboardButton(text="📁 1337x", callback_data='00'),
13
+ InlineKeyboardButton(text="🔍 ꜱᴇᴀʀᴄʜ", switch_inline_query_current_chat="3 " ) ],
14
+ [ InlineKeyboardButton(text="📁 ThePirateBay", callback_data='00'),
15
+ InlineKeyboardButton(text="🔍 ꜱᴇᴀʀᴄʜ", switch_inline_query_current_chat="4 ") ],
16
+ [ InlineKeyboardButton(text="❌", callback_data="X0") ] ] )
plugins/callback.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # (c) Shrimadhav U K | Modified By > @DC4_WARRIOR
4
+
5
+ from pyrogram import filters
6
+ from pyrogram import Client as Clinton
7
+ from plugins.youtube_dl_button import youtube_dl_call_back
8
+ from plugins.dl_button import ddl_call_back
9
+
10
+ @Clinton.on_callback_query(filters.regex('^X0$'))
11
+ async def delt(bot, update):
12
+ await update.message.delete(True)
13
+
14
+
15
+ @Clinton.on_callback_query()
16
+ async def button(bot, update):
17
+
18
+ cb_data = update.data
19
+ if "|" in cb_data:
20
+ await youtube_dl_call_back(bot, update)
21
+ elif "=" in cb_data:
22
+ await ddl_call_back(bot, update)
plugins/custom_thumbnail.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # (c) Shrimadhav U K | Modifieded By : @DC4_WARRIOR
4
+
5
+ # the logging things
6
+ import logging
7
+ logging.basicConfig(level=logging.DEBUG,
8
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
9
+ logger = logging.getLogger(__name__)
10
+
11
+ import random
12
+ import numpy
13
+ import os
14
+ from PIL import Image
15
+ import time
16
+
17
+ from config import Config
18
+ # the Strings used for this "thing"
19
+ from translation import Translation
20
+ from pyrogram import Client as Clinton
21
+ from database.access import clinton
22
+ from hachoir.metadata import extractMetadata
23
+ from hachoir.parser import createParser
24
+ logging.getLogger("pyrogram").setLevel(logging.WARNING)
25
+ from pyrogram import filters
26
+ from database.adduser import AddUser
27
+ from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot
28
+
29
+ @Clinton.on_message(filters.private & filters.photo)
30
+ async def save_photo(bot, update):
31
+ await AddUser(bot, update)
32
+ await clinton.set_thumbnail(update.from_user.id, thumbnail=update.photo.file_id)
33
+ await bot.send_message(chat_id=update.chat.id, text=Translation.SAVED_CUSTOM_THUMB_NAIL, reply_to_message_id=update.message_id)
34
+
35
+ @Clinton.on_message(filters.private & filters.command("delthumbnail"))
36
+ async def delthumbnail(bot, update):
37
+ await AddUser(bot, update)
38
+ await clinton.set_thumbnail(update.from_user.id, thumbnail=None)
39
+ await bot.send_message(chat_id=update.chat.id, text=Translation.DEL_ETED_CUSTOM_THUMB_NAIL, reply_to_message_id=update.message_id)
40
+
41
+ @Clinton.on_message(filters.private & filters.command("viewthumbnail") )
42
+ async def viewthumbnail(bot, update):
43
+ await AddUser(bot, update)
44
+ thumbnail = await clinton.get_thumbnail(update.from_user.id)
45
+ if thumbnail is not None:
46
+ await bot.send_photo(
47
+ chat_id=update.chat.id,
48
+ photo=thumbnail,
49
+ caption=f"Your current saved thumbnail 🦠",
50
+ reply_to_message_id=update.message_id)
51
+ else:
52
+ await update.reply_text(text=f"No Thumbnail found 🤒")
53
+
54
+ async def Gthumb01(bot, update):
55
+ thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
56
+ db_thumbnail = await clinton.get_thumbnail(update.from_user.id)
57
+ if db_thumbnail is not None:
58
+ thumbnail = await bot.download_media(message=db_thumbnail, file_name=thumb_image_path)
59
+ Image.open(thumbnail).convert("RGB").save(thumbnail)
60
+ img = Image.open(thumbnail)
61
+ img.resize((100, 100))
62
+ img.save(thumbnail, "JPEG")
63
+ else:
64
+ thumbnail = None
65
+
66
+ return thumbnail
67
+
68
+ async def Gthumb02(bot, update, duration, download_directory):
69
+ thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
70
+ db_thumbnail = await clinton.get_thumbnail(update.from_user.id)
71
+ if db_thumbnail is not None:
72
+ thumbnail = await bot.download_media(message=db_thumbnail, file_name=thumb_image_path)
73
+ else:
74
+ thumbnail = await take_screen_shot(download_directory, os.path.dirname(download_directory), random.randint(0, duration - 1))
75
+
76
+ return thumbnail
77
+
78
+ async def Mdata01(download_directory):
79
+
80
+ width = 0
81
+ height = 0
82
+ duration = 0
83
+ metadata = extractMetadata(createParser(download_directory))
84
+ if metadata is not None:
85
+ if metadata.has("duration"):
86
+ duration = metadata.get('duration').seconds
87
+ if metadata.has("width"):
88
+ width = metadata.get("width")
89
+ if metadata.has("height"):
90
+ height = metadata.get("height")
91
+
92
+ return width, height, duration
93
+
94
+ async def Mdata02(download_directory):
95
+
96
+ width = 0
97
+ duration = 0
98
+ metadata = extractMetadata(createParser(download_directory))
99
+ if metadata is not None:
100
+ if metadata.has("duration"):
101
+ duration = metadata.get('duration').seconds
102
+ if metadata.has("width"):
103
+ width = metadata.get("width")
104
+
105
+ return width, duration
106
+
107
+ async def Mdata03(download_directory):
108
+
109
+ duration = 0
110
+ metadata = extractMetadata(createParser(download_directory))
111
+ if metadata is not None:
112
+ if metadata.has("duration"):
113
+ duration = metadata.get('duration').seconds
114
+
115
+ return duration
plugins/dl_button.py ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # (c) Shrimadhav U K | Modifieded By : @DC4_WARRIOR
4
+
5
+ # the logging things
6
+ import logging
7
+ logging.basicConfig(level=logging.DEBUG,
8
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
9
+ logger = logging.getLogger(__name__)
10
+ import asyncio
11
+ import aiohttp
12
+ import json
13
+ import math
14
+ import os
15
+ import shutil
16
+ import time
17
+ from datetime import datetime
18
+ # the secret configuration specific things
19
+ from config import Config
20
+ # the Strings used for this "thing"
21
+ from translation import Translation
22
+ from plugins.custom_thumbnail import *
23
+ logging.getLogger("pyrogram").setLevel(logging.WARNING)
24
+ from helper_funcs.display_progress import progress_for_pyrogram, humanbytes, TimeFormatter
25
+ from hachoir.metadata import extractMetadata
26
+ from hachoir.parser import createParser
27
+ # https://stackoverflow.com/a/37631799/4723940
28
+ from PIL import Image
29
+
30
+
31
+ async def ddl_call_back(bot, update):
32
+ logger.info(update)
33
+ cb_data = update.data
34
+ # youtube_dl extractors
35
+ tg_send_type, youtube_dl_format, youtube_dl_ext = cb_data.split("=")
36
+ thumb_image_path = Config.DOWNLOAD_LOCATION + \
37
+ "/" + str(update.from_user.id) + ".jpg"
38
+ youtube_dl_url = update.message.reply_to_message.text
39
+ custom_file_name = os.path.basename(youtube_dl_url)
40
+ if "|" in youtube_dl_url:
41
+ url_parts = youtube_dl_url.split("|")
42
+ if len(url_parts) == 2:
43
+ youtube_dl_url = url_parts[0]
44
+ custom_file_name = url_parts[1]
45
+ else:
46
+ for entity in update.message.reply_to_message.entities:
47
+ if entity.type == "text_link":
48
+ youtube_dl_url = entity.url
49
+ elif entity.type == "url":
50
+ o = entity.offset
51
+ l = entity.length
52
+ youtube_dl_url = youtube_dl_url[o:o + l]
53
+ if youtube_dl_url is not None:
54
+ youtube_dl_url = youtube_dl_url.strip()
55
+ if custom_file_name is not None:
56
+ custom_file_name = custom_file_name.strip()
57
+ # https://stackoverflow.com/a/761825/4723940
58
+ logger.info(youtube_dl_url)
59
+ logger.info(custom_file_name)
60
+ else:
61
+ for entity in update.message.reply_to_message.entities:
62
+ if entity.type == "text_link":
63
+ youtube_dl_url = entity.url
64
+ elif entity.type == "url":
65
+ o = entity.offset
66
+ l = entity.length
67
+ youtube_dl_url = youtube_dl_url[o:o + l]
68
+ user = await bot.get_me()
69
+ mention = user["mention"]
70
+ description = Translation.CUSTOM_CAPTION_UL_FILE.format(mention)
71
+ start = datetime.now()
72
+ await bot.edit_message_text(
73
+ text=Translation.DOWNLOAD_START,
74
+ chat_id=update.message.chat.id,
75
+ message_id=update.message.message_id
76
+ )
77
+ tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id)
78
+ if not os.path.isdir(tmp_directory_for_each_user):
79
+ os.makedirs(tmp_directory_for_each_user)
80
+ download_directory = tmp_directory_for_each_user + "/" + custom_file_name
81
+ command_to_exec = []
82
+ async with aiohttp.ClientSession() as session:
83
+ c_time = time.time()
84
+ try:
85
+ await download_coroutine(
86
+ bot,
87
+ session,
88
+ youtube_dl_url,
89
+ download_directory,
90
+ update.message.chat.id,
91
+ update.message.message_id,
92
+ c_time
93
+ )
94
+ except asyncio.TimeoutError:
95
+ await bot.edit_message_text(
96
+ text=Translation.SLOW_URL_DECED,
97
+ chat_id=update.message.chat.id,
98
+ message_id=update.message.message_id
99
+ )
100
+ return False
101
+ if os.path.exists(download_directory):
102
+ end_one = datetime.now()
103
+ await bot.edit_message_text(
104
+ text=Translation.UPLOAD_START,
105
+ chat_id=update.message.chat.id,
106
+ message_id=update.message.message_id
107
+ )
108
+ file_size = Config.TG_MAX_FILE_SIZE + 1
109
+ try:
110
+ file_size = os.stat(download_directory).st_size
111
+ except FileNotFoundError as exc:
112
+ download_directory = os.path.splitext(download_directory)[0] + "." + "mkv"
113
+ # https://stackoverflow.com/a/678242/4723940
114
+ file_size = os.stat(download_directory).st_size
115
+ if file_size > Config.TG_MAX_FILE_SIZE:
116
+ await bot.edit_message_text(
117
+ chat_id=update.message.chat.id,
118
+ text=Translation.RCHD_TG_API_LIMIT,
119
+ message_id=update.message.message_id
120
+ )
121
+ else:
122
+ # ref: message from @SOURCES_CODES
123
+ start_time = time.time()
124
+ # try to upload file
125
+ if tg_send_type == "audio":
126
+ duration = await Mdata03(download_directory)
127
+ thumb_image_path = await Gthumb01(bot, update)
128
+ await bot.send_audio(
129
+ chat_id=update.message.chat.id,
130
+ audio=download_directory,
131
+ caption=description,
132
+ duration=duration,
133
+ thumb=thumb_image_path,
134
+ reply_to_message_id=update.message.reply_to_message.message_id,
135
+ progress=progress_for_pyrogram,
136
+ progress_args=(
137
+ Translation.UPLOAD_START,
138
+ update.message,
139
+ start_time
140
+ )
141
+ )
142
+ elif tg_send_type == "file":
143
+ thumb_image_path = await Gthumb01(bot, update)
144
+ await bot.send_document(
145
+ chat_id=update.message.chat.id,
146
+ document=download_directory,
147
+ thumb=thumb_image_path,
148
+ caption=description,
149
+ reply_to_message_id=update.message.reply_to_message.message_id,
150
+ progress=progress_for_pyrogram,
151
+ progress_args=(
152
+ Translation.UPLOAD_START,
153
+ update.message,
154
+ start_time
155
+ )
156
+ )
157
+ elif tg_send_type == "vm":
158
+ width, duration = await Mdata02(download_directory)
159
+ thumb_image_path = await Gthumb02(bot, update, duration, download_directory)
160
+ await bot.send_video_note(
161
+ chat_id=update.message.chat.id,
162
+ video_note=download_directory,
163
+ duration=duration,
164
+ length=width,
165
+ thumb=thumb_image_path,
166
+ reply_to_message_id=update.message.reply_to_message.message_id,
167
+ progress=progress_for_pyrogram,
168
+ progress_args=(
169
+ Translation.UPLOAD_START,
170
+ update.message,
171
+ start_time
172
+ )
173
+ )
174
+ elif tg_send_type == "video":
175
+ width, height, duration = await Mdata01(download_directory)
176
+ thumb_image_path = await Gthumb02(bot, update, duration, download_directory)
177
+ await bot.send_video(
178
+ chat_id=update.message.chat.id,
179
+ video=download_directory,
180
+ caption=description,
181
+ duration=duration,
182
+ width=width,
183
+ height=height,
184
+ supports_streaming=True,
185
+ thumb=thumb_image_path,
186
+ reply_to_message_id=update.message.reply_to_message.message_id,
187
+ progress=progress_for_pyrogram,
188
+ progress_args=(
189
+ Translation.UPLOAD_START,
190
+ update.message,
191
+ start_time
192
+ )
193
+ )
194
+ else:
195
+ logger.info("Did this happen? :\\")
196
+ end_two = datetime.now()
197
+ try:
198
+ os.remove(download_directory)
199
+ os.remove(thumb_image_path)
200
+ except:
201
+ pass
202
+ time_taken_for_download = (end_one - start).seconds
203
+ time_taken_for_upload = (end_two - end_one).seconds
204
+ await bot.edit_message_text(
205
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(time_taken_for_download, time_taken_for_upload),
206
+ chat_id=update.message.chat.id,
207
+ message_id=update.message.message_id,
208
+ disable_web_page_preview=True
209
+ )
210
+ else:
211
+ await bot.edit_message_text(
212
+ text=Translation.NO_VOID_FORMAT_FOUND.format("Incorrect Link"),
213
+ chat_id=update.message.chat.id,
214
+ message_id=update.message.message_id,
215
+ disable_web_page_preview=True
216
+ )
217
+
218
+
219
+ async def download_coroutine(bot, session, url, file_name, chat_id, message_id, start):
220
+ downloaded = 0
221
+ display_message = ""
222
+ async with session.get(url, timeout=Config.PROCESS_MAX_TIMEOUT) as response:
223
+ total_length = int(response.headers["Content-Length"])
224
+ content_type = response.headers["Content-Type"]
225
+ if "text" in content_type and total_length < 500:
226
+ return await response.release()
227
+ await bot.edit_message_text(
228
+ chat_id,
229
+ message_id,
230
+ text="""Initiating Download
231
+ URL: {}
232
+ File Size: {}""".format(url, humanbytes(total_length))
233
+ )
234
+ with open(file_name, "wb") as f_handle:
235
+ while True:
236
+ chunk = await response.content.read(Config.CHUNK_SIZE)
237
+ if not chunk:
238
+ break
239
+ f_handle.write(chunk)
240
+ downloaded += Config.CHUNK_SIZE
241
+ now = time.time()
242
+ diff = now - start
243
+ if round(diff % 5.00) == 0 or downloaded == total_length:
244
+ percentage = downloaded * 100 / total_length
245
+ speed = downloaded / diff
246
+ elapsed_time = round(diff) * 1000
247
+ time_to_completion = round(
248
+ (total_length - downloaded) / speed) * 1000
249
+ estimated_total_time = elapsed_time + time_to_completion
250
+ try:
251
+ current_message = """**Download Status**
252
+ URL: {}
253
+ File Size: {}
254
+ Downloaded: {}
255
+ ETA: {}""".format(
256
+ url,
257
+ humanbytes(total_length),
258
+ humanbytes(downloaded),
259
+ TimeFormatter(estimated_total_time)
260
+ )
261
+ if current_message != display_message:
262
+ await bot.edit_message_text(
263
+ chat_id,
264
+ message_id,
265
+ text=current_message
266
+ )
267
+ display_message = current_message
268
+ except Exception as e:
269
+ logger.info(str(e))
270
+ pass
271
+ return await response.release()
plugins/forcesub.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # soon...
2
+ """
3
+ from config import Config
4
+ from pyrogram.errors import UserNotParticipant
5
+ """
plugins/help_text.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # (c) Shrimadhav U K
4
+
5
+ # the logging things
6
+ import logging
7
+ logging.basicConfig(level=logging.DEBUG,
8
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
9
+ logger = logging.getLogger(__name__)
10
+
11
+ import os
12
+
13
+ from config import Config
14
+ # the Strings used for this "thing"
15
+ from translation import Translation
16
+
17
+ from pyrogram import filters
18
+ from database.adduser import AddUser
19
+ from pyrogram import Client as Clinton
20
+ logging.getLogger("pyrogram").setLevel(logging.WARNING)
21
+
22
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
23
+
24
+
25
+ @Clinton.on_message(filters.private & filters.command(["help"]))
26
+ async def help_user(bot, update):
27
+ # logger.info(update)
28
+ await AddUser(bot, update)
29
+ await bot.send_message(
30
+ chat_id=update.chat.id,
31
+ text=Translation.HELP_USER,
32
+ parse_mode="html",
33
+ disable_web_page_preview=True,
34
+ reply_to_message_id=update.message_id
35
+ )
36
+
37
+
38
+ @Clinton.on_message(filters.private & filters.command(["start"]))
39
+ async def start(bot, update):
40
+ # logger.info(update)
41
+ await AddUser(bot, update)
42
+ await bot.send_message(
43
+ chat_id=update.chat.id,
44
+ text=Translation.START_TEXT.format(update.from_user.mention),
45
+ reply_markup=InlineKeyboardMarkup(
46
+ [
47
+ [
48
+ InlineKeyboardButton(
49
+ "Source code ⚡", url="https://github.com/imseldrith/UPLOADER-BOT"
50
+ ),
51
+ InlineKeyboardButton("Project Channel 👨🏻‍💻", url="https://t.me/url_upload_bots"),
52
+ ],
53
+ [InlineKeyboardButton("Developer 👨‍⚖️", url="https://t.me/imseldrith")],
54
+ ]
55
+ ),
56
+ reply_to_message_id=update.message_id
57
+ )
plugins/youtube_dl_button.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # Modified By > @Clinton_Abraham
4
+
5
+ import logging
6
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
7
+ logging.getLogger("pyrogram").setLevel(logging.WARNING)
8
+ logger = logging.getLogger(__name__)
9
+
10
+ import os
11
+ import json
12
+ import math
13
+ import time
14
+ import shutil
15
+ import asyncio
16
+ from PIL import Image
17
+ from config import Config
18
+ from datetime import datetime
19
+ from database.access import clinton
20
+ from translation import Translation
21
+ from plugins.custom_thumbnail import *
22
+ from pyrogram.types import InputMediaPhoto
23
+ from helper_funcs.display_progress import progress_for_pyrogram, humanbytes
24
+
25
+
26
+ async def youtube_dl_call_back(bot, update):
27
+ cb_data = update.data
28
+ tg_send_type, youtube_dl_format, youtube_dl_ext = cb_data.split("|")
29
+ save_ytdl_json_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".json"
30
+ try:
31
+ with open(save_ytdl_json_path, "r", encoding="utf8") as f:
32
+ response_json = json.load(f)
33
+ except (FileNotFoundError) as e:
34
+ await update.message.delete(True)
35
+ return False
36
+ youtube_dl_url = update.message.reply_to_message.text
37
+ custom_file_name = str(response_json.get("title"))[:50] + "_" + youtube_dl_format + "." + youtube_dl_ext
38
+ youtube_dl_username = None
39
+ youtube_dl_password = None
40
+ if "|" in youtube_dl_url:
41
+ url_parts = youtube_dl_url.split("|")
42
+ if len(url_parts) == 2:
43
+ youtube_dl_url = url_parts[0]
44
+ custom_file_name = url_parts[1]
45
+ elif len(url_parts) == 4:
46
+ youtube_dl_url = url_parts[0]
47
+ custom_file_name = url_parts[1]
48
+ youtube_dl_username = url_parts[2]
49
+ youtube_dl_password = url_parts[3]
50
+ else:
51
+ for entity in update.message.reply_to_message.entities:
52
+ if entity.type == "text_link":
53
+ youtube_dl_url = entity.url
54
+ elif entity.type == "url":
55
+ o = entity.offset
56
+ l = entity.length
57
+ youtube_dl_url = youtube_dl_url[o:o + l]
58
+ if youtube_dl_url is not None:
59
+ youtube_dl_url = youtube_dl_url.strip()
60
+ if custom_file_name is not None:
61
+ custom_file_name = custom_file_name.strip()
62
+ if youtube_dl_username is not None:
63
+ youtube_dl_username = youtube_dl_username.strip()
64
+ if youtube_dl_password is not None:
65
+ youtube_dl_password = youtube_dl_password.strip()
66
+ else:
67
+ for entity in update.message.reply_to_message.entities:
68
+ if entity.type == "text_link":
69
+ youtube_dl_url = entity.url
70
+ elif entity.type == "url":
71
+ o = entity.offset
72
+ l = entity.length
73
+ youtube_dl_url = youtube_dl_url[o:o + l]
74
+ await bot.edit_message_text(
75
+ text=Translation.DOWNLOAD_START,
76
+ chat_id=update.message.chat.id,
77
+ message_id=update.message.message_id)
78
+ description = Translation.CUSTOM_CAPTION_UL_FILE
79
+ if "fulltitle" in response_json:
80
+ description = response_json["fulltitle"][0:1021]
81
+ # escape Markdown and special characters
82
+ tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id)
83
+ if not os.path.isdir(tmp_directory_for_each_user):
84
+ os.makedirs(tmp_directory_for_each_user)
85
+ if '/' in custom_file_name:
86
+ file_mimx = custom_file_name
87
+ file_maix = file_mimx.split('/')
88
+ file_name = ' '.join(file_maix)
89
+ else:
90
+ file_name = custom_file_name
91
+ download_directory = tmp_directory_for_each_user + "/" + str(file_name)
92
+ command_to_exec = []
93
+ if tg_send_type == "audio":
94
+ command_to_exec = ["yt-dlp", "-c",
95
+ "--max-filesize", str(Config.TG_MAX_FILE_SIZE),
96
+ "--prefer-ffmpeg", "--extract-audio",
97
+ "--audio-format", youtube_dl_ext,
98
+ "--audio-quality", youtube_dl_format,
99
+ youtube_dl_url, "-o", download_directory]
100
+ else:
101
+ minus_f_format = youtube_dl_format
102
+ if "youtu" in youtube_dl_url:
103
+ minus_f_format = youtube_dl_format + "+bestaudio"
104
+ command_to_exec = ["yt-dlp", "-c",
105
+ "--max-filesize", str(Config.TG_MAX_FILE_SIZE),
106
+ "--embed-subs", "-f", minus_f_format,
107
+ "--hls-prefer-ffmpeg", youtube_dl_url,
108
+ "-o", download_directory]
109
+
110
+ if Config.HTTP_PROXY != "":
111
+ command_to_exec.append("--proxy")
112
+ command_to_exec.append(Config.HTTP_PROXY)
113
+ if youtube_dl_username is not None:
114
+ command_to_exec.append("--username")
115
+ command_to_exec.append(youtube_dl_username)
116
+ if youtube_dl_password is not None:
117
+ command_to_exec.append("--password")
118
+ command_to_exec.append(youtube_dl_password)
119
+ command_to_exec.append("--no-warnings")
120
+ command_to_exec.append("--quiet")
121
+
122
+ start = datetime.now()
123
+ process = await asyncio.create_subprocess_exec(*command_to_exec,
124
+ stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,)
125
+
126
+ stdout, stderr = await process.communicate()
127
+ e_response = stderr.decode().strip()
128
+ t_response = stdout.decode().strip()
129
+
130
+ ad_string_to_replace = "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output."
131
+ if e_response and ad_string_to_replace in e_response:
132
+ error_message = e_response.replace(ad_string_to_replace, "")
133
+ await bot.edit_message_text(
134
+ chat_id=update.message.chat.id,
135
+ message_id=update.message.message_id,
136
+ text=error_message)
137
+ return False
138
+ if t_response:
139
+ asyncio.create_task(clendir(save_ytdl_json_path))
140
+ try:
141
+ file_size = os.stat(download_directory).st_size
142
+ except FileNotFoundError:
143
+ try:
144
+ download_directory = os.path.splitext(download_directory)[0] + "." + "mkv"
145
+ file_size = os.stat(download_directory).st_size
146
+ except Exception:
147
+ await update.message.edit(text="File Not found 🤒")
148
+ asyncio.create_task(clendir(tmp_directory_for_each_user))
149
+ return
150
+ if file_size > Config.TG_MAX_FILE_SIZE:
151
+ await bot.edit_message_text(
152
+ chat_id=update.message.chat.id,
153
+ text=Translation.RCHD_TG_API_LIMIT.format(time_taken_for_download, humanbytes(file_size)),
154
+ message_id=update.message.message_id)
155
+ else:
156
+ await bot.edit_message_text(
157
+ text=Translation.UPLOAD_START,
158
+ chat_id=update.message.chat.id,
159
+ message_id=update.message.message_id)
160
+ try:
161
+ start_time = time.time()
162
+ if tg_send_type == "audio":
163
+ duration = await Mdata03(download_directory)
164
+ thumbnail = await Gthumb01(bot, update)
165
+ await bot.send_audio(
166
+ chat_id=update.message.chat.id,
167
+ audio=download_directory,
168
+ caption=description,
169
+ parse_mode="HTML",
170
+ duration=duration,
171
+ thumb=thumbnail,
172
+ reply_to_message_id=update.message.reply_to_message.message_id,
173
+ progress=progress_for_pyrogram,
174
+ progress_args=(Translation.UPLOAD_START, update.message, start_time))
175
+ elif tg_send_type == "file":
176
+ thumbnail = await Gthumb01(bot, update)
177
+ await bot.send_document(chat_id=update.message.chat.id,
178
+ document=download_directory,
179
+ thumb=thumbnail,
180
+ caption=description,
181
+ parse_mode="HTML",
182
+ reply_to_message_id=update.message.reply_to_message.message_id,
183
+ progress=progress_for_pyrogram,
184
+ progress_args=(Translation.UPLOAD_START, update.message, start_time))
185
+ elif tg_send_type == "vm":
186
+ width, duration = await Mdata02(download_directory)
187
+ thumbnail = await Gthumb02(bot, update, duration, download_directory)
188
+ await bot.send_video_note(chat_id=update.message.chat.id,
189
+ video_note=download_directory,
190
+ duration=duration,
191
+ length=width,
192
+ thumb=thumb_image_path,
193
+ reply_to_message_id=update.message.reply_to_message.message_id,
194
+ progress=progress_for_pyrogram,
195
+ progress_args=(Translation.UPLOAD_START, update.message, start_time))
196
+ elif tg_send_type == "video":
197
+ width, height, duration = await Mdata01(download_directory)
198
+ thumbnail = await Gthumb02(bot, update, duration, download_directory)
199
+ await bot.send_video(chat_id=update.message.chat.id,
200
+ video=download_directory,
201
+ caption=description,
202
+ parse_mode="HTML",
203
+ duration=duration,
204
+ width=width,
205
+ height=height,
206
+ thumb=thumbnail,
207
+ supports_streaming=True,
208
+ reply_to_message_id=update.message.reply_to_message.message_id,
209
+ progress=progress_for_pyrogram,
210
+ progress_args=(Translation.UPLOAD_START,
211
+ update.message, start_time) )
212
+
213
+ asyncio.create_task(clendir(download_directory))
214
+ asyncio.create_task(clendir(thumbnail))
215
+ await bot.edit_message_text(
216
+ text="Uploaded sucessfully ✓\n\nJOIN : @url_upload_bots",
217
+ chat_id=update.message.chat.id,
218
+ message_id=update.message.message_id,
219
+ disable_web_page_preview=True)
220
+
221
+ except Exception as e:
222
+ asyncio.create_task(clendir(download_directory))
223
+ await bot.edit_message_text(text=Translation.ERROR.format(e),
224
+ chat_id=update.message.chat.id, message_id=update.message.message_id)
225
+
226
+ #=================================
227
+
228
+ async def clendir(directory):
229
+
230
+ try:
231
+ os.remove(directory)
232
+ except:
233
+ pass
234
+
235
+ #=================================
plugins/youtube_dl_echo.py ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @SPACE_X_BOTS | @Clinton_Abraham </>
2
+
3
+ import logging, requests, urllib.parse, os, time, shutil, asyncio, json, math
4
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
5
+ logging.getLogger("pyrogram").setLevel(logging.WARNING)
6
+ logger = logging.getLogger(__name__)
7
+
8
+ from config import Config
9
+ from pyrogram import filters
10
+ from database.access import clinton
11
+ from translation import Translation
12
+ from database.adduser import AddUser
13
+ from pyrogram import Client as Clinton
14
+ from hachoir.parser import createParser
15
+ from hachoir.metadata import extractMetadata
16
+ from helper_funcs.display_progress import humanbytes
17
+ from helper_funcs.help_uploadbot import DownLoadFile
18
+ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
19
+ from helper_funcs.display_progress import progress_for_pyrogram, humanbytes, TimeFormatter
20
+
21
+ @Clinton.on_message(filters.private & ~filters.via_bot & filters.regex(pattern=".*http.*"))
22
+ async def echo(bot, update):
23
+ await AddUser(bot, update)
24
+ imog = await update.reply_text("Processing...⚡", reply_to_message_id=update.message_id)
25
+ youtube_dl_username = None
26
+ youtube_dl_password = None
27
+ file_name = None
28
+ url = update.text
29
+ if "|" in url:
30
+ url_parts = url.split("|")
31
+ if len(url_parts) == 2:
32
+ url = url_parts[0]
33
+ file_name = url_parts[1]
34
+ elif len(url_parts) == 4:
35
+ url = url_parts[0]
36
+ file_name = url_parts[1]
37
+ youtube_dl_username = url_parts[2]
38
+ youtube_dl_password = url_parts[3]
39
+ else:
40
+ for entity in update.entities:
41
+ if entity.type == "text_link":
42
+ url = entity.url
43
+ elif entity.type == "url":
44
+ o = entity.offset
45
+ l = entity.length
46
+ url = url[o:o + l]
47
+ if url is not None:
48
+ url = url.strip()
49
+ if file_name is not None:
50
+ file_name = file_name.strip()
51
+ # https://stackoverflow.com/a/761825/4723940
52
+ if youtube_dl_username is not None:
53
+ youtube_dl_username = youtube_dl_username.strip()
54
+ if youtube_dl_password is not None:
55
+ youtube_dl_password = youtube_dl_password.strip()
56
+ logger.info(url)
57
+ logger.info(file_name)
58
+ else:
59
+ for entity in update.entities:
60
+ if entity.type == "text_link":
61
+ url = entity.url
62
+ elif entity.type == "url":
63
+ o = entity.offset
64
+ l = entity.length
65
+ url = url[o:o + l]
66
+ if Config.HTTP_PROXY != "":
67
+ command_to_exec = [
68
+ "yt-dlp",
69
+ "--no-warnings",
70
+ "--youtube-skip-dash-manifest",
71
+ "-j",
72
+ url,
73
+ "--proxy", Config.HTTP_PROXY
74
+ ]
75
+ else:
76
+ command_to_exec = [
77
+ "yt-dlp",
78
+ "--no-warnings",
79
+ "--youtube-skip-dash-manifest",
80
+ "-j",
81
+ url
82
+ ]
83
+ if youtube_dl_username is not None:
84
+ command_to_exec.append("--username")
85
+ command_to_exec.append(youtube_dl_username)
86
+ if youtube_dl_password is not None:
87
+ command_to_exec.append("--password")
88
+ command_to_exec.append(youtube_dl_password)
89
+ process = await asyncio.create_subprocess_exec(*command_to_exec,
90
+ stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
91
+ stdout, stderr = await process.communicate()
92
+ e_response = stderr.decode().strip()
93
+ t_response = stdout.decode().strip()
94
+ if e_response and "nonnumeric port" not in e_response:
95
+ error_message = e_response.replace(Translation.ERROR_YTDLP, "")
96
+ if "This video is only available for registered users." in error_message:
97
+ error_message = Translation.SET_CUSTOM_USERNAME_PASSWORD
98
+ else:
99
+ error_message = "Invalid url 🚸</code>"
100
+ await bot.send_message(chat_id=update.chat.id,
101
+ text=Translation.NO_VOID_FORMAT_FOUND.format(str(error_message)),
102
+ disable_web_page_preview=True, parse_mode="html",
103
+ reply_to_message_id=update.message_id)
104
+ await imog.delete(True)
105
+ return False
106
+ if t_response:
107
+ # logger.info(t_response)
108
+ x_reponse = t_response
109
+ if "\n" in x_reponse:
110
+ x_reponse, _ = x_reponse.split("\n")
111
+ response_json = json.loads(x_reponse)
112
+ save_ytdl_json_path = Config.DOWNLOAD_LOCATION + \
113
+ "/" + str(update.from_user.id) + ".json"
114
+ with open(save_ytdl_json_path, "w", encoding="utf8") as outfile:
115
+ json.dump(response_json, outfile, ensure_ascii=False)
116
+ # logger.info(response_json)
117
+ inline_keyboard = []
118
+ duration = None
119
+ if "duration" in response_json:
120
+ duration = response_json["duration"]
121
+ if "formats" in response_json:
122
+ for formats in response_json["formats"]:
123
+ format_id = formats.get("format_id")
124
+ format_string = formats.get("format_note")
125
+ if format_string is None:
126
+ format_string = formats.get("format")
127
+ format_ext = formats.get("ext")
128
+ approx_file_size = ""
129
+ if "filesize" in formats:
130
+ approx_file_size = humanbytes(formats["filesize"])
131
+ cb_string_video = "{}|{}|{}".format(
132
+ "video", format_id, format_ext)
133
+ cb_string_file = "{}|{}|{}".format(
134
+ "file", format_id, format_ext)
135
+ if format_string is not None and not "audio only" in format_string:
136
+ ikeyboard = [
137
+ InlineKeyboardButton(
138
+ "S " + format_string + " video " + approx_file_size + " ",
139
+ callback_data=(cb_string_video).encode("UTF-8")
140
+ ),
141
+ InlineKeyboardButton(
142
+ "D " + format_ext + " " + approx_file_size + " ",
143
+ callback_data=(cb_string_file).encode("UTF-8")
144
+ )
145
+ ]
146
+ """if duration is not None:
147
+ cb_string_video_message = "{}|{}|{}".format(
148
+ "vm", format_id, format_ext)
149
+ ikeyboard.append(
150
+ InlineKeyboardButton(
151
+ "VM",
152
+ callback_data=(
153
+ cb_string_video_message).encode("UTF-8")
154
+ )
155
+ )"""
156
+ else:
157
+ # special weird case :\
158
+ ikeyboard = [
159
+ InlineKeyboardButton(
160
+ "SVideo [" +
161
+ "] ( " +
162
+ approx_file_size + " )",
163
+ callback_data=(cb_string_video).encode("UTF-8")
164
+ ),
165
+ InlineKeyboardButton(
166
+ "DFile [" +
167
+ "] ( " +
168
+ approx_file_size + " )",
169
+ callback_data=(cb_string_file).encode("UTF-8")
170
+ )
171
+ ]
172
+ inline_keyboard.append(ikeyboard)
173
+ if duration is not None:
174
+ cb_string_64 = "{}|{}|{}".format("audio", "64k", "mp3")
175
+ cb_string_128 = "{}|{}|{}".format("audio", "128k", "mp3")
176
+ cb_string = "{}|{}|{}".format("audio", "320k", "mp3")
177
+ inline_keyboard.append([
178
+ InlineKeyboardButton(
179
+ "MP3 " + "(" + "64 kbps" + ")", callback_data=cb_string_64.encode("UTF-8")),
180
+ InlineKeyboardButton(
181
+ "MP3 " + "(" + "128 kbps" + ")", callback_data=cb_string_128.encode("UTF-8"))
182
+ ])
183
+ inline_keyboard.append([
184
+ InlineKeyboardButton(
185
+ "MP3 " + "(" + "320 kbps" + ")", callback_data=cb_string.encode("UTF-8"))
186
+ ])
187
+ else:
188
+ format_id = response_json["format_id"]
189
+ format_ext = response_json["ext"]
190
+ cb_string_file = "{}|{}|{}".format(
191
+ "file", format_id, format_ext)
192
+ cb_string_video = "{}|{}|{}".format(
193
+ "video", format_id, format_ext)
194
+ inline_keyboard.append([
195
+ InlineKeyboardButton(
196
+ "SVideo",
197
+ callback_data=(cb_string_video).encode("UTF-8")
198
+ ),
199
+ InlineKeyboardButton(
200
+ "DFile",
201
+ callback_data=(cb_string_file).encode("UTF-8")
202
+ )
203
+ ])
204
+ cb_string_file = "{}={}={}".format(
205
+ "file", format_id, format_ext)
206
+ cb_string_video = "{}={}={}".format(
207
+ "video", format_id, format_ext)
208
+ inline_keyboard.append([
209
+ InlineKeyboardButton(
210
+ "video",
211
+ callback_data=(cb_string_video).encode("UTF-8")
212
+ ),
213
+ InlineKeyboardButton(
214
+ "file",
215
+ callback_data=(cb_string_file).encode("UTF-8")
216
+ )
217
+ ])
218
+ reply_markup = InlineKeyboardMarkup(inline_keyboard)
219
+ await imog.delete(True)
220
+ await bot.send_message(
221
+ chat_id=update.chat.id,
222
+ text=Translation.FORMAT_SELECTION + "\n" + Translation.SET_CUSTOM_USERNAME_PASSWORD,
223
+ reply_markup=reply_markup,
224
+ parse_mode="html",
225
+ reply_to_message_id=update.message_id
226
+ )
227
+ else:
228
+ inline_keyboard = []
229
+ cb_string_file = "{}={}={}".format(
230
+ "file", "LFO", "NONE")
231
+ cb_string_video = "{}={}={}".format(
232
+ "video", "OFL", "ENON")
233
+ inline_keyboard.append([
234
+ InlineKeyboardButton(
235
+ "SVideo",
236
+ callback_data=(cb_string_video).encode("UTF-8")
237
+ ),
238
+ InlineKeyboardButton(
239
+ "DFile",
240
+ callback_data=(cb_string_file).encode("UTF-8")
241
+ )
242
+ ])
243
+ reply_markup = InlineKeyboardMarkup(inline_keyboard)
244
+ await imog.delete(True)
245
+ await bot.send_message(
246
+ chat_id=update.chat.id,
247
+ text=Translation.FORMAT_SELECTION,
248
+ reply_markup=reply_markup,
249
+ parse_mode="html",
250
+ reply_to_message_id=update.message_id)