-
Notifications
You must be signed in to change notification settings - Fork 20
/
main2.py
721 lines (611 loc) · 28.2 KB
/
main2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
import pyrogram
from pyrogram.errors.exceptions.bad_request_400 import StickerEmojiInvalid
import requests
import json
import subprocess
from pyrogram import Client,filters
from pyrogram.types.messages_and_media import message
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from pyrogram.errors import FloodWait
from pyromod import listen
from pyrogram.types import Message
from pyrogram import Client, filters
import tgcrypto
from p_bar import progress_bar
from details import api_id, api_hash, bot_token, sudo_groups
from subprocess import getstatusoutput
import helper
import logging
import time
import aiohttp
import asyncio
import aiofiles
from pyrogram.types import User, Message
# import progressor
# from progressor import progress_for_pyrogram
import sys
import re
import os
# import pycurl
bot = Client(
"bot",
api_id=api_id,
api_hash=api_hash,
bot_token=bot_token)
#bot = Client(
# "bot",
# bot_token=os.environ.get("BOT_TOKEN"),
# api_id=int(os.environ.get("API_ID")),
# api_hash=os.environ.get("API_HASH")
#)
#auth_users = [ int(chat) for chat in os.environ.get("AUTH_USERS").split(",") if chat != '']
#sudo_users = auth_users
#sudo_groups = [ int(chat) for chat in os.environ.get("GROUPS").split(",") if chat != '']
@bot.on_message(filters.command(["start"])& (filters.chat(sudo_groups)))
async def account_login(bot: Client, m: Message):
editable = await m.reply_text("Hi\nPress /pyro")
@bot.on_message(filters.command(["cancel"])& (filters.chat(sudo_groups)))
async def cancel(_, m):
editable = await m.reply_text("Canceling All process Plz wait")
global cancel
cancel = True
await editable.edit("cancled")
return
@bot.on_message(filters.command("restart")& (filters.chat(sudo_groups)))
async def restart_handler(_, m):
await m.reply_text("Restarted!", True)
os.execl(sys.executable, sys.executable, *sys.argv)
@bot.on_message(filters.command(["pyro"])& (filters.chat(sudo_groups)))
async def account_login(bot: Client, m: Message):
editable = await m.reply_text("Send txt file**")
input: Message = await bot.listen(editable.chat.id)
x = await input.download()
await input.delete(True)
path = f"./downloads/{m.chat.id}"
try:
with open(x, "r") as f:
content = f.read()
content = content.split("\n")
links = []
for i in content:
links.append(i.split(":", 1))
os.remove(x)
# print(len(links))
except:
await m.reply_text("Invalid file input.")
os.remove(x)
return
editable = await m.reply_text(f"Total links found are **{len(links)}**\n\nSend From where you want to download initial is **0**")
input1: Message = await bot.listen(editable.chat.id)
raw_text = input1.text
try:
arg = int(raw_text)
except:
arg = 0
editable = await m.reply_text("**Enter Title**")
input0: Message = await bot.listen(editable.chat.id)
raw_text0 = input0.text
await m.reply_text("**Enter resolution**")
input2: Message = await bot.listen(editable.chat.id)
raw_text2 = input2.text
editable4= await m.reply_text("Now send the **Thumb url**\nEg : ```https://telegra.ph/file/d9e24878bd4aba05049a1.jpg```\n\nor Send **no**")
input6 = message = await bot.listen(editable.chat.id)
raw_text6 = input6.text
thumb = input6.text
if thumb.startswith("http://") or thumb.startswith("https://"):
getstatusoutput(f"wget '{thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
else:
thumb == "no"
if raw_text =='0':
count =1
else:
count =int(raw_text)
try:
for i in range(arg, len(links)):
url = links[i][1]
name1 = links[i][0].replace("\t", "").replace(":", "").replace("/", "").replace("+", "").replace("#", "").replace("|", "").replace("@","").replace("*","").replace(".","").strip()
if raw_text2 =="144":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
# print(out)
if '256x144' in out:
ytf = f"{out['256x144']}"
elif '320x180' in out:
ytf = out['320x180']
elif 'unknown' in out:
ytf = out["unknown"]
else:
for data1 in out:
ytf = out[data1]
elif raw_text2 =="180":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
# print(out)
if '320x180' in out:
ytf = out['320x180']
elif '426x240' in out:
ytf = out['426x240']
elif 'unknown' in out:
ytf = out["unknown"]
else:
for data2 in out:
ytf = out[data2]
elif raw_text2 =="240":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
# print(out)
if '426x240' in out:
ytf = out['426x240']
elif '426x234' in out:
ytf = out['426x234']
elif '480x270' in out:
ytf = out['480x270']
elif '480x272' in out:
ytf = out['480x272']
elif '640x360' in out:
ytf = out['640x360']
elif 'unknown' in out:
ytf = out["unknown"]
else:
for data3 in out:
ytf = out[data3]
elif raw_text2 =="360":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
# print(out)
if '640x360' in out:
ytf = out['640x360']
elif '638x360' in out:
ytf = out['638x360']
elif '636x360' in out:
ytf = out['636x360']
elif '768x432' in out:
ytf = out['768x432']
elif '638x358' in out:
ytf = out['638x358']
elif '852x316' in out:
ytf = out['852x316']
elif '850x480' in out:
ytf = out['850x480']
elif '848x480' in out:
ytf = out['848x480']
elif '854x480' in out:
ytf = out['854x480']
elif '852x480' in out:
ytf = out['852x480']
elif '854x470' in out:
ytf = out['852x470']
elif 'unknown' in out:
ytf = out["unknown"]
else:
for data4 in out:
ytf = out[data4]
elif raw_text2 =="480":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
# print(out)
if '854x480' in out:
ytf = out['854x480']
elif '852x480' in out:
ytf = out['852x480']
elif '854x470' in out:
ytf = out['854x470']
elif '768x432' in out:
ytf = out['768x432']
elif '848x480' in out:
ytf = out['848x480']
elif '850x480' in out:
ytf =['850x480']
elif '960x540' in out:
ytf = out['960x540']
elif '640x360' in out:
ytf = out['640x360']
elif 'unknown' in out:
ytf = out["unknown"]
else:
for data5 in out:
ytf = out[data5]
elif raw_text2 =="720":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
# print(out)
if '1280x720' in out:
ytf = out['1280x720']
elif '1280x704' in out:
ytf = out['1280x704']
elif '1280x474' in out:
ytf = out['1280x474']
elif '1920x712' in out:
ytf = out['1920x712']
elif '1920x1056' in out:
ytf = out['1920x1056']
elif '854x480' in out:
ytf = out['854x480']
elif '640x360' in out:
ytf = out['640x360']
elif 'unknown' in out:
ytf = out["unknown"]
else:
for data6 in out:
ytf = out[data6]
elif "player.vimeo" in url:
if raw_text2 == '144':
ytf= 'http-240p'
elif raw_text2 == "240":
ytf= 'http-240p'
elif raw_text2 == '360':
ytf= 'http-360p'
elif raw_text2 == '480':
ytf= 'http-540p'
elif raw_text2 == '720':
ytf= 'http-720p'
else:
ytf = 'http-360p'
else:
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
for dataS in out:
ytf = out[dataS]
try:
if "unknown" in out:
res = "NA"
else:
res = list(out.keys())[list(out.values()).index(ytf)]
name = f'{str(count).zfill(3)}) {name1} {res}'
except Exception:
res = "NA"
# if "youtu" in url:
# if ytf == f"'bestvideo[height<={raw_text2}][ext=mp4]+bestaudio[ext=m4a]'" or "acecwply" in url:
if "acecwply" in url:
cmd = f'yt-dlp -o "{name}.%(ext)s" -f "bestvideo[height<={raw_text2}]+bestaudio" --hls-prefer-ffmpeg --no-keep-video --remux-video mkv --no-warning "{url}"'
elif "youtu" in url:
cmd = f'yt-dlp -i -f "bestvideo[height<={raw_text2}]+bestaudio" --no-keep-video --remux-video mkv --no-warning "{url}" -o "{name}.%(ext)s"'
elif "player.vimeo" in url:
cmd = f'yt-dlp -f "{ytf}+bestaudio" --no-keep-video --remux-video mkv "{url}" -o "{name}.%(ext)s"'
elif "m3u8" or "livestream" in url:
cmd = f'yt-dlp -f "{ytf}" --no-keep-video --remux-video mkv "{url}" -o "{name}.%(ext)s"'
elif ytf == "0" or "unknown" in out:
cmd = f'yt-dlp -f "{ytf}" --no-keep-video --remux-video mkv "{url}" -o "{name}.%(ext)s"'
elif ".pdf" in url:
cmd = "pdf"
else:
cmd = f'yt-dlp -f "{ytf}+bestaudio" --hls-prefer-ffmpeg --no-keep-video --remux-video mkv "{url}" -o "{name}.%(ext)s"'
try:
Show = f"**Downloading:-**\n\n**Name :-** `{name}\nQuality - {raw_text2}`\n\n**Url :-** `{url}`"
prog = await m.reply_text(Show)
cc = f'**Title »** {name1} {res}.mkv\n**Caption »** {raw_text0}\n**Index »** {str(count).zfill(3)}'
cc1 =f'**Title »** {name1} {res}.pdf\n**Caption »** {raw_text0}\n**Index »** {str(count).zfill(3)}'
# if cmd == "pdf" or "drive" in url:
# try:
# ka=await helper.download(url,name)
# await prog.delete (True)
# time.sleep(1)
# # await helper.send_doc(bot,m,cc,ka,cc1,prog,count,name)
# reply = await m.reply_text(f"Uploading - `{name}`")
# time.sleep(1)
# start_time = time.time()
# await m.reply_document(ka,caption=cc1)
# count+=1
# await reply.delete (True)
# time.sleep(1)
# os.remove(ka)
# time.sleep(3)
# except FloodWait as e:
# await m.reply_text(str(e))
# time.sleep(e.x)
# continue
if cmd == "pdf" or ".pdf" in url:
try:
ka=await helper.aio(url,name)
await prog.delete (True)
time.sleep(1)
reply = await m.reply_text(f"Uploading - ```{name}```")
time.sleep(1)
start_time = time.time()
await m.reply_document(ka, caption=f'**Title »** {name1} {res}.pdf\n**Caption »** {raw_text0}\n**Index »** {str(count).zfill(3)}')
count+=1
# time.sleep(1)
await reply.delete (True)
time.sleep(1)
os.remove(ka)
time.sleep(3)
except FloodWait as e:
await m.reply_text(str(e))
time.sleep(e.x)
continue
else:
res_file = await helper.download_video(url,cmd, name)
filename = res_file
await helper.send_vid(bot, m,cc,filename,thumb,name,prog)
count+=1
time.sleep(1)
except Exception as e:
await m.reply_text(f"**downloading failed ❌**\n{str(e)}\n**Name** - {name}\n**Link** - `{url}`")
continue
except Exception as e:
await m.reply_text(e)
await m.reply_text("Done")
@bot.on_message(filters.command(["top"])& (filters.chat(sudo_groups)))
async def account_login(bot: Client, m: Message):
editable = await m.reply_text(f"**Hi im Topranker dl**")
input: Message = await bot.listen(editable.chat.id)
x = await input.download()
await input.delete(True)
try:
with open(x, "r") as f:
content = f.read()
content = content.split("\n")
links = []
for i in content:
links.append(i.split(":", 1))
os.remove(x)
# print(len(links))
except:
await m.reply_text("Invalid file input.")
os.remove(x)
return
editable = await m.reply_text(f"Total links found are **{len(links)}**\n\nSend From where you want to download initial is **0**")
input1: Message = await bot.listen(editable.chat.id)
raw_text = input1.text
try:
arg = int(raw_text)
except:
arg = 0
editable = await m.reply_text(f"**Copy Paste the App Name of which you want to download videos.**\n\n`vikramjeet`\n\n`sure60`\n\n`theoptimistclasses`")
input0: Message = await bot.listen(editable.chat.id)
raw_text0 = input0.text
editable2 = await m.reply_text("**Enter Title**")
input5: Message = await bot.listen(editable.chat.id)
raw_text5 = input5.text
editable4= await m.reply_text("Now send the **Thumb url**\nEg : ```https://telegra.ph/file/d9e24878bd4aba05049a1.jpg```\n\nor Send **no**")
input6 = message = await bot.listen(editable.chat.id)
raw_text6 = input6.text
thumb = input6.text
if thumb.startswith("http://") or thumb.startswith("https://"):
getstatusoutput(f"wget '{thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
else:
thumb == "no"
if raw_text =='0':
count =1
else:
count =int(raw_text)
try:
for i in range(arg, len(links)):
url = links[i][1]
name1 = links[i][0].replace("\t", "").replace("/", "").replace("+", "").replace("#", "").replace("|", "").replace("@","").replace(":","").replace("*","").replace(".","").strip()
# await m.reply_text(name +":"+ url)
# Show = f"**Downloading:-**\n\n**Name :-** ```{name}\nQuality - {raw_text2}```\n\n**Url :-** ```{url}```"
# prog = await m.reply_text(Show)
# cc = f'>> **Name :** {name}\n>> **Title :** {raw_text0}\n\n>> **Index :** {count}'
if raw_text0 in "vikramjeet" :
y= url.replace("/", "%2F")
# rout = f"https://www.toprankers.com/?route=common/ajax&mod=liveclasses&ack=getcustompolicysignedcookiecdn&stream=https%3A%2F%2Fsignedsec.toprankers.com%2Flivehttporigin%2F{y[56:-14]}%2Fmaster.m3u8"
rout =f"https://www.toprankers.com/?route=common/ajax&mod=liveclasses&ack=getcustompolicysignedcookiecdn&stream=https%3A%2F%2Fsignedsec.toprankers.com%2F{y[39:-14]}%2Fmaster.m3u8"
getstatusoutput(f'curl "{rout}" -c "cookie.txt"')
cook = "cookie.txt"
# print (rout)
# print(url)
elif raw_text0 in "sure60":
y1= url.replace("/", "%2F")
# rout = f"https://onlinetest.sure60.com/?route=common/ajax&mod=liveclasses&ack=getcustompolicysignedcookiecdn&stream=https%3A%2F%2Fvodcdn.sure60.com%2Flivehttporigin%2F{y[49:-14]}%2Fmaster.m3u8"
rout =f"https://onlinetest.sure60.com/?route=common/ajax&mod=liveclasses&ack=getcustompolicysignedcookiecdn&stream=https%3A%2F%2Fvodcdn.sure60.com%2F{y1[32:-14]}%2Fmaster.m3u8"
getstatusoutput(f'curl "{rout}" -c "cookie.txt"')
cook = "cookie.txt"
elif raw_text0 in "theoptimistclasses":
y= url.replace("/", "%2F")
rout=f"https://live.theoptimistclasses.com/?route=common/ajax&mod=liveclasses&ack=getcustompolicysignedcookiecdn&stream=https%3A%2F%2Fvodcdn.theoptimistclasses.com%2F{y[44:-14]}%2Fmaster.m3u8"
getstatusoutput(f'curl "{rout}" -c "cookie.txt"')
cook = "cookie.txt"
name = f'{str(count).zfill(3)}) {name1}'
Show = f"**Downloading:-**\n\n**Name :-** `{name}`\n\n**Url :-** `{url}`\n\n**rout** :- `{rout}`"
prog = await m.reply_text(Show)
cc = f'**Title »** {name1}.mp4\n**Caption »** {raw_text5}\n**Index »** {str(count).zfill(3)}'
cmd = f'yt-dlp -o "{name}.mp4" --cookies {cook} "{url}"'
try:
download_cmd = f"{cmd} -R 25 --fragment-retries 25 --external-downloader aria2c --downloader-args 'aria2c: -x 16 -j 32'"
os.system(download_cmd)
filename = f"{name}.mp4"
subprocess.run(f'ffmpeg -i "{filename}" -ss 00:01:00 -vframes 1 "{filename}.jpg"', shell=True)
await prog.delete (True)
reply = await m.reply_text(f"Uploading - ```{name}```")
try:
if thumb == "no":
thumbnail = f"{filename}.jpg"
else:
thumbnail = thumb
except Exception as e:
await m.reply_text(str(e))
dur = int(helper.duration(filename))
start_time = time.time()
await m.reply_video(f"{name}.mp4",supports_streaming=True,height=720,width=1280,caption=cc,duration=dur,thumb=thumbnail, progress=progress_bar,progress_args=(reply,start_time) )
count+=1
os.remove(f"{name}.mp4")
os.remove(f"{filename}.jpg")
os.remove(cook)
await reply.delete (True)
time.sleep(1)
except Exception as e:
await m.reply_text(f"**downloading failed ❌**\n{str(e)}\n**Name** - {name}\n**Link** - `{url}`\n\n**rout** :- `{rout}`")
continue
except Exception as e:
await m.reply_text(str(e))
await m.reply_text("Done")
@bot.on_message(filters.command(["adda_pdf"]))
async def adda_pdf(bot: Client, m: Message):
editable = await m.reply_text(f"**Hi im Pdf Adda pdf dl**")
input: Message = await bot.listen(editable.chat.id)
x = await input.download()
await input.delete(True)
try:
with open(x, "r") as f:
content = f.read()
content = content.split("\n")
links = []
for i in content:
links.append(i.split(":", 1))
os.remove(x)
# print(len(links))
except:
await m.reply_text("Invalid file input.")
os.remove(x)
return
editable = await m.reply_text(f"Total links found are **{len(links)}**\n\nSend From where you want to download initial is **0**")
input1: Message = await bot.listen(editable.chat.id)
raw_text = input1.text
try:
arg = int(raw_text)
except:
arg = 0
editable2 = await m.reply_text("**Enter Token**")
input5: Message = await bot.listen(editable.chat.id)
raw_text5 = input5.text
if raw_text =='0':
count =1
else:
count =int(raw_text)
try:
for i in range(arg, len(links)):
url = links[i][1]
name1 = links[i][0].replace("\t", "").replace("/", "").replace("+", "").replace("#", "").replace("|", "").replace("@","").replace(":","").replace("*","").replace(".","").replace("'","").replace('"','').strip()
name = f'{str(count).zfill(3)} {name1}'
Show = f"**Downloading:-**\n\n**Name :-** `{name}`\n\n**Url :-** `{url}`"
prog = await m.reply_text(Show)
cc = f'{str(count).zfill(3)}. {name1}.pdf\n'
try:
getstatusoutput(f'curl --http2 -X GET -H "Host:store.adda247.com" -H "user-agent:Mozilla/5.0 (Linux; Android 11; moto g(40) fusion Build/RRI31.Q1-42-51-8; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/97.0.4692.98 Mobile Safari/537.36" -H "accept:*/*" -H "x-requested-with:com.adda247.app" -H "sec-fetch-site:same-origin" -H "sec-fetch-mode:cors" -H "sec-fetch-dest:empty" -H "referer:https://store.adda247.com/build/pdf.worker.js" -H "accept-encoding:gzip, deflate" -H "accept-language:en-US,en;q=0.9" -H "cookie:cp_token={raw_text5}" "{url}" --output "{name}.pdf"')
await m.reply_document(f"{name}.pdf",caption=cc)
count+=1
await prog.delete (True)
os.remove(f"{name}.pdf")
time.sleep(2)
except Exception as e:
await m.reply_text(f"{e}\nDownload Failed\n\nName : {name}\n\nLink : {url}")
continue
except Exception as e:
await m.reply_text(e)
await m.reply_text("Done")
@bot.on_message(filters.command(["jw"])& (filters.chat(sudo_groups)))
async def account_login(bot: Client, m: Message):
editable = await m.reply_text("Send txt file**")
input: Message = await bot.listen(editable.chat.id)
x = await input.download()
await input.delete(True)
path = f"./downloads/{m.chat.id}"
try:
with open(x, "r") as f:
content = f.read()
content = content.split("\n")
links = []
for i in content:
links.append(i.split(":", 1))
os.remove(x)
# print(len(links))
except:
await m.reply_text("Invalid file input.")
os.remove(x)
return
editable = await m.reply_text(f"Total links found are **{len(links)}**\n\nSend From where you want to download initial is **0**")
input1: Message = await bot.listen(editable.chat.id)
raw_text = input1.text
try:
arg = int(raw_text)
except:
arg = 0
editable = await m.reply_text("**Enter Title**")
input0: Message = await bot.listen(editable.chat.id)
raw_text0 = input0.text
await m.reply_text("**Enter resolution**")
input2: Message = await bot.listen(editable.chat.id)
raw_text2 = input2.text
editable4= await m.reply_text("Now send the **Thumb url**\nEg : ```https://telegra.ph/file/d9e24878bd4aba05049a1.jpg```\n\nor Send **no**")
input6 = message = await bot.listen(editable.chat.id)
raw_text6 = input6.text
thumb = input6.text
if thumb.startswith("http://") or thumb.startswith("https://"):
getstatusoutput(f"wget '{thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
else:
thumb == "no"
if raw_text =='0':
count =1
else:
count =int(raw_text)
try:
for i in range(arg, len(links)):
url = links[i][1]
name1 = links[i][0].replace("\t", "").replace(":", "").replace("/", "").replace("+", "").replace("#", "").replace("|", "").replace("@","").replace("*","").replace(".","").strip()
if "cpcdn" in url:
if "playlist" in url:
url1 = url.replace("playlist", "360p")
else:
list01 = url.split("/")
list01[-1] = "stream_2/stream.m3u8"
url1 = "/".join(list01)
elif "videos" in url:
list01 = url.replace(".m3u8" , "").split("/")
last01 = list01.pop()
if len(list01[-1])>8:
last02 = "video/" + last01 + "-49aced368452fa67022235a5c4b7055c-video-fd.m3u8"
list01.append(last02)
else:
last02 = "videos/" + last01 + "-33948335.mp4.m3u8"
list01.append(last02)
url1 = "/".join(list01)
# url1 = b
else:
url1 = url
name = f'{str(count).zfill(3)}) {name1}'
Show = f"**Downloading:-**\n\n**Name :-** `{name}`\n\n**Url :-** `{url1}`"
prog = await m.reply_text(Show)
cc = f'**Title »** {name1}.mkv\n**Caption »** {raw_text0}\n**Index »** {str(count).zfill(3)}'
if "pdf" in url:
cmd = f'yt-dlp -o "{name}.pdf" "{url1}"'
else:
cmd = f'yt-dlp --no-check-certificates -o "{name}.mp4" --no-keep-video --remux-video mkv "{url1}"'
try:
download_cmd = f"{cmd} -R 25 --fragment-retries 25 --external-downloader aria2c --downloader-args 'aria2c: -x 16 -j 32'"
os.system(download_cmd)
if os.path.isfile(f"{name}.mkv"):
filename = f"{name}.mkv"
elif os.path.isfile(f"{name}.mp4"):
filename = f"{name}.mp4"
elif os.path.isfile(f"{name}.pdf"):
filename = f"{name}.pdf"
# filename = f"{name}.mkv"
subprocess.run(f'ffmpeg -i "{filename}" -ss 00:01:00 -vframes 1 "{filename}.jpg"', shell=True)
await prog.delete (True)
reply = await m.reply_text(f"Uploading - ```{name}```")
try:
if thumb == "no":
thumbnail = f"{filename}.jpg"
else:
thumbnail = thumb
except Exception as e:
await m.reply_text(str(e))
dur = int(helper.duration(filename))
start_time = time.time()
if "pdf" in url1:
await m.reply_document(filename,caption=cc)
else:
await m.reply_video(filename,supports_streaming=True,height=720,width=1280,caption=cc,duration=dur,thumb=thumbnail, progress=progress_bar,progress_args=(reply,start_time) )
count+=1
os.remove(filename)
os.remove(f"{filename}.jpg")
await reply.delete (True)
time.sleep(1)
except Exception as e:
await m.reply_text(f"**downloading failed ❌**\n{str(e)}\n**Name** - {name}\n**Link** - `{url}` & `{url1}`")
continue
except Exception as e:
await m.reply_text(e)
await m.reply_text("Done")
bot.run()