forked from Rohanthakur360/ID-Pass-to-Txt-Extractor-mew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
2431 lines (2244 loc) · 98 KB
/
main.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
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import asyncio
import json
import logging
import os
import re
import subprocess
import sys
import time
from logging.handlers import RotatingFileHandler
from subprocess import getstatusoutput
import requests
from pyrogram import Client, filters
from pyrogram.errors import FloodWait
from pyrogram.types import Message
from pyromod import listen
import online.helpers.vid as helper
from online.Config import *
from online.helpers.button import keyboard
from online.helpers.sudoers import *
from online.helpers.text import *
# ==========Logging==========#
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s [%(filename)s:%(lineno)d]",
datefmt="%d-%b-%y %H:%M:%S",
handlers=[
RotatingFileHandler("Assist.txt", maxBytes=50000000, backupCount=10),
logging.StreamHandler(),
],
)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
logging = logging.getLogger()
# =========== Client ===========#
bot = Client(
"bot",
bot_token=bot_token,
api_id=api_id,
api_hash=api_hash,
)
print(listen.__file__)
# ========== Converter =============#
@bot.on_message(filters.command(["taiyaric"]))
async def gaiyrab(bot: Client, message: Message):
message.from_user.id if message.from_user is not None else None
if not one(message.from_user.id):
return await message.reply_text(
"✨ Hello Sir,\n\nContact Me Click Below",
reply_markup=keyboard,
)
else:
editable = await message.reply_text(
"This is help to convert json file to text of taiyari karlo app ",
disable_web_page_preview=True,
)
input = await bot.listen(editable.chat.id)
x = await input.download()
to_write = ""
try:
with open(x, "r") as file:
data = json.load(file)
for entry in data:
target_change = entry[1][0].get("targetChange")
if target_change and target_change.get("targetChangeType") == "ADD":
continue
document_change = (
entry[1][0]
.get("documentChange", {})
.get("document", {})
.get("fields", {})
)
quality = None
recordings = (
document_change.get("recordings", {})
.get("arrayValue", {})
.get("values", [])
)
for recording in recordings:
recording_fields = recording.get("mapValue", {}).get("fields", {})
quality = recording_fields.get("quality", {}).get("stringValue")
if quality == "480p":
path = recording_fields.get("path", {}).get("stringValue")
title = document_change.get("title", {}).get("stringValue")
to_write += f"{title}:{path}\n"
if document_change.get("type", {}).get("stringValue") == "pdf":
title_pdf = document_change.get("title", {}).get("stringValue")
ref_pdf = document_change.get("ref", {}).get("stringValue")
to_write += f"{title_pdf}:{ref_pdf}\n"
except Exception as e:
os.remove(x)
return await message.reply_text(f"**Error** : {e}")
with open(f"new.txt", "w", encoding="utf-8") as f:
f.write(to_write)
print(1)
with open(f"new.txt", "rb") as f:
await asyncio.sleep(5)
doc = await message.reply_document(document=f, caption="Here is your txt file.")
# =========== Core Commands ======#
shell_usage = f"**USAGE:** Executes terminal commands directly via bot.\n\n<pre>/shell pip install requests</pre>"
@bot.on_message(filters.command(["shell"]))
async def shell(client, message: Message):
"""
Executes terminal commands via bot.
"""
if not two(message.from_user.id):
return
if len(message.command) < 2:
return await message.reply_text(shell_usage, quote=True)
user_input = message.text.split(None, 1)[1].split(" ")
try:
shell = subprocess.Popen(
user_input, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
stdout, stderr = shell.communicate()
result = str(stdout.decode().strip()) + str(stderr.decode().strip())
except Exception as error:
logging.info(f"{error}")
return await message.reply_text(f"**Error**:\n\n{error}", quote=True)
if len(result) > 2000:
file = BytesIO(result.encode())
file.name = "output.txt"
await message.reply_text("Output is too large (Sending it as File)", quote=True)
await client.send_document(message.chat.id, file, caption=file.name)
else:
await message.reply_text(f"**Output:**:\n\n{result}", quote=True)
paid_text = """
» Hello i am online class bot which help you to **Extract** and **Download** video of Physics Wallah / Apni Kaksha / Khan Gs ..... Any Type of Online Class Which You Want.
• **How to Access this bot**
Step 1: Click Below on Developer.
Step 2: Go to Telegram Username
Step 3: Send your Telegram ID From @missrose_bot
"""
# ============== Start Commands ==========#
@bot.on_message(filters.command(["start"]))
async def account_lstarn(bot: Client, m: Message):
if not one(m.from_user.id):
return await m.reply_photo(
photo="https://graph.org/file/aa0147b4d5a8fead84411.jpg",
caption=paid_text,
reply_markup=keyboard,
)
await m.reply_text(start_text)
# ========== Global Concel Command ============
cancel = False
@bot.on_message(filters.command(["cancel"]))
async def cancel(_, m):
if not two(m.from_user.id):
return await m.reply_text(
"✨ Hello Sir,\n\nThis Command is only For Owner",
reply_markup=keyboard,
)
editable = await m.reply_text(
"Canceling All process Plz wait\n🚦🚦 Last Process Stopped 🚦🚦"
)
global cancel
cancel = False
await editable.edit("cancelled all")
return
# ============== Power Commands =================
@bot.on_message(filters.command("restart"))
async def restart_handler(_, m):
if not two(m.from_user.id):
return await m.reply_text(
"✨ Hello Sir,\n\nYou Don't Have Right To Access This Contact Owner",
)
await m.reply_text("➭ 𝗕𝗼𝘁 𝗜𝘀 𝗕𝗲𝗶𝗻𝗴 𝗥𝗲𝘀𝘁𝗮𝗿𝘁𝗶𝗻𝗴. 𝗣𝗹𝗲𝗮𝘀𝗲 𝗞𝗲𝗲𝗽 𝗣𝗮𝘁𝗶𝗲𝗻𝗰𝗲", True)
os.execl(sys.executable, sys.executable, *sys.argv)
# ============ Download Commands ==============#
@bot.on_message(filters.command(["pyro"]))
async def download_pw(bot: Client, m: Message):
global cancel
m.from_user.id if m.from_user is not None else None
if not one(m.from_user.id):
return await m.reply_text(
"✨ Hello Sir,\n\nContact Me Click Below",
reply_markup=keyboard,
)
else:
editable = await m.reply_text(pyro_text, disable_web_page_preview=True)
input = await bot.listen(editable.chat.id)
x = await input.download()
links = []
try:
with open(x, "r") as f:
content = f.read()
new_content = content.split("\n")
for i in new_content:
links.append(re.split(":(?=http)", i))
os.remove(x)
except Exception as e:
await m.reply_text(f"**Error** : {e}")
os.remove(x)
return
await m.reply_text(
f"Total links found are **{len(links)}**\n\nSend From where you want to download initial is **0**"
)
initial_number = await bot.listen(editable.chat.id)
try:
arg = int(initial_number.text)
except:
arg = 0
await m.reply_text(
f"Total links: **{len(links)}**\n\nSend Me Final Number\n\nBy Default Final is {len(links)}"
)
final_number = await bot.listen(editable.chat.id)
try:
arg1 = int(final_number.text)
except:
arg1 = len(links)
await m.reply_text("**Enter batch name**")
input0 = 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(
"**For Thumb Url**\n\n• Custom url : Use @vtelegraphbot and send me links\n• If Your file Contain Url : `yes`\n• Send no if you don't want : `no`"
)
input6 = await bot.listen(editable.chat.id)
lol_thumb = input6.text
if arg == "0":
count = 1
else:
count = int(arg)
cancel = True
for i in range(arg, arg1):
try:
while cancel == False:
return await m.reply_text("Cancelled Process")
url = links[i][1]
name1 = (
links[i][0]
.replace("\t", "")
.replace(":", "")
.replace("/", "")
.replace("+", "")
.replace("#", "")
.replace("|", "")
.replace("@", "")
.replace("*", "")
.replace(".", "")
.strip()
)
try:
if lol_thumb == "yes":
old_thumb = links[i][2]
getstatusoutput(f"wget '{old_thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
elif lol_thumb.startswith("http://") or lol_thumb.startswith(
"https://"
):
old_thumb = lol_thumb
getstatusoutput(f"wget '{lol_thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
else:
thumb = "no"
old_thumb = "No Thumbnail"
except Exception as e:
return await m.reply_text(e)
Total_Links = arg1 - int(arg)
Show_old = f"**Total Links** : {Total_Links}\n\n**Name :-** `{name1}`\n\n**Url :-** `{url}`\n**Thumb :-** `{old_thumb}`"
prog_old = await m.reply_text(Show_old)
if raw_text2 == "144":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
logging.info(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))
logging.info(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 "1280x720" in out:
ytf = out["1280x720"]
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:
pass
else:
list(out.keys())[list(out.values()).index(ytf)]
name = f"{name1}"
except Exception as e:
return await m.reply(f"Error in ytf : {e}")
await prog_old.delete(True)
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 url.startswith("https://apni-kaksha.vercel.app"):
cmd = f'yt-dlp -f "{ytf}+bestaudio" --hls-prefer-ffmpeg --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" or "download" in str(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}`\n**Thumb :-** `{old_thumb}`"
prog = await m.reply_text(Show)
cc = f"**➭ Name » {name1}** \n**➭ Batch » {raw_text0}**"
cc1 = f"**➭ Name » {name1}** \n**➭ Batch » {raw_text0}**"
if cmd == "pdf" or ".pdf" in str(url) or ".pdf" in name:
print("PDF")
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)
await m.reply_document(
ka,
caption=f"{cc1}",
)
count += 1
await reply.delete(True)
time.sleep(1)
os.remove(ka)
time.sleep(5)
except FloodWait as e:
await m.reply_text(str(e))
time.sleep(e.x)
continue
else:
filename = await helper.download_video(url, cmd, name)
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:
return await m.reply_text(f"Overall Error : {e}")
await m.reply_text("Done")
@bot.on_message(filters.command(["patna"]))
async def khan_dowbol(bot: Client, m: Message):
global cancel
m.from_user.id if m.from_user is not None else None
if not one(m.from_user.id):
return await m.reply_text(
"✨ Hello Sir,\n\nContact Me Click Below",
reply_markup=keyboard,
)
else:
editable = await m.reply_text(pyro_text, disable_web_page_preview=True)
input = await bot.listen(editable.chat.id)
x = await input.download()
links = []
try:
with open(x, "r") as f:
content = f.read()
new_content = content.split("\n")
for i in new_content:
links.append(re.split(":(?=http)", i))
os.remove(x)
except Exception as e:
await m.reply_text(f"**Error** : {e}")
os.remove(x)
return
await m.reply_text(
f"Total links found are **{len(links)}**\n\nSend From where you want to download initial is **0**"
)
initial_number = await bot.listen(editable.chat.id)
try:
arg = int(initial_number.text)
except:
arg = 0
await m.reply_text(
f"Total links: **{len(links)}**\n\nSend Me Final Number\n\nBy Default Final is {len(links)}"
)
final_number = await bot.listen(editable.chat.id)
try:
arg1 = int(final_number.text)
except:
arg1 = len(links)
await m.reply_text("**Enter batch name**")
input0 = 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(
"**For Thumb Url**\n\n• Custom url : Use @vtelegraphbot and send me links\n• If Your file Contain Url : `yes`\n• Send no if you don't want : `no`"
)
input6 = await bot.listen(editable.chat.id)
lol_thumb = input6.text
if arg == "0":
count = 1
else:
count = int(arg)
cancel = True
for i in range(arg, arg1):
try:
while cancel == False:
return await m.reply_text("Cancelled Process")
url = links[i][1]
name1 = (
links[i][0]
.replace("\t", "")
.replace(":", "")
.replace("/", "")
.replace("+", "")
.replace("#", "")
.replace("|", "")
.replace("@", "")
.replace("*", "")
.replace(".", "")
.strip()
)
try:
if lol_thumb == "yes":
old_thumb = links[i][2]
getstatusoutput(f"wget '{old_thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
elif lol_thumb.startswith("http://") or lol_thumb.startswith(
"https://"
):
old_thumb = lol_thumb
getstatusoutput(f"wget '{lol_thumb}' -O 'thumb.jpg'")
thumb = "thumb.jpg"
else:
thumb = "no"
old_thumb = "No Thumbnail"
except Exception as e:
return await m.reply_text(e)
Total_Links = arg1 - int(arg)
Show_old = f"**Total Links** : {Total_Links}\n\n**Name :-** `{name1}`\n\n**Url :-** `{url}`\n**Thumb :-** `{old_thumb}`"
prog_old = await m.reply_text(Show_old)
if raw_text2 == "144":
cmd = f'yt-dlp -F "{url}"'
k = await helper.run(cmd)
out = helper.vid_info(str(k))
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))
logging.info(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 "854x360" in out:
ytf = out["854x360"]
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 "1280x720" in out:
ytf = out["1280x720"]
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))
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))
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 as e:
await m.reply(f"Error in ytf : {e}")
continue
res = "NA"
await prog_old.delete(True)
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 url.startswith("https://apni-kaksha.vercel.app"):
cmd = f'yt-dlp -f "{ytf}+bestaudio" --hls-prefer-ffmpeg --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" or "download" in str(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}`\n**Thumb :-** `{old_thumb}`"
prog = await m.reply_text(Show)
cc = f"**➭ Name »** {name} {res}.mkv\n**➭ Batch »** {raw_text0}"
cc1 = f"**➭ Name »** {name} {res}.pdf\n**➭ Batch »** {raw_text0}"
if cmd == "pdf" or ".pdf" in str(url) or ".pdf" in name:
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)
await m.reply_document(
ka,
caption=f"{cc1}",
)
count += 1
await reply.delete(True)
time.sleep(1)
os.remove(ka)
time.sleep(5)
except FloodWait as e:
await m.reply_text(str(e))
time.sleep(e.x)
continue
else:
filename = await helper.download_video(url, cmd, name)
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(f"Overall Error : {e}")
await m.reply_text("Done")
# ================ Class Plus =================#
@bot.on_message(filters.command(["cp"]))
async def infcpsgin(bot: Client, m: Message):
if not one(m.from_user.id):
return await m.reply_text(
"✨ Hello Sir,\n\nContact Me Click Below",
reply_markup=keyboard,
)
s = requests.Session()
editable = await m.reply_text("**Send Token from ClassPlus App**")
input1: Message = await bot.listen(editable.chat.id)
raw_text0 = input1.text
headers = {
"authority": "api.classplusapp.com",
"accept": "application/json, text/plain, */*",
"accept-language": "en",
"api-version": "28",
"cache-control": "no-cache",
"device-id": "516",
"origin": "https://web.classplusapp.com",
"pragma": "no-cache",
"referer": "https://web.classplusapp.com/",
"region": "IN",
"sec-ch-ua": '"Chromium";v="107", "Not=A?Brand";v="24"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Linux"',
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
"x-access-token": f"{raw_text0}",
}
resp = s.get(
"https://api.classplusapp.com/v2/batches/details?limit=20&offset=0&sortBy=createdAt",
headers=headers,
)
if resp.status_code == 200:
pass
else:
editable = await m.reply_text("Login Failed Check Response")
b_data = resp.json()["data"]["totalBatches"]
cool = ""
for data in b_data:
t_name = data["batchName"]
t_id = data["batchId"]
cool += f" **{t_name}** - `{t_id}` \n\n"
await editable.edit(f'{"**You have these batches :-**"}\n\n{cool}')
await m.reply_text("**Now send the Batch ID to Download**")
input2 = message = await bot.listen(editable.chat.id)
cr = input2.text
b_data = s.get(
f"https://api.classplusapp.com/v2/course/content/get?courseId={cr}",
headers=headers,
).json()["data"]["courseContent"]
cool = ""
for data in b_data:
id1 = data["id"]
nam2 = data["name"]
data["contentType"]
cool += f" **{nam2}** - `{id1}`\n\n"
await editable.edit(f"**You have these Folders :-**\n\n{cool}")
await m.reply_text("**Now send the Batch ID to Download**")
input2 = message = await bot.listen(editable.chat.id)
raw_text2 = input2.text
bdata = s.get(
f"https://api.classplusapp.com/v2/course/content/get?courseId={cr}&folderId={raw_text2}",
headers=headers,
).json()["data"]["courseContent"]
folder_m = ""
for data in bdata:
id1 = data["id"]
nam2 = data["name"]
vid = data["resources"]["videos"]
fid = data["resources"]["files"]
data["contentType"]
FFF = "**FOLDER-ID -FOLDER NAME -TOTAL VIDEOS/PDFS**"
folder_m += f" `{id1}` - **{nam2} -{vid} -{fid}**\n\n"
await editable.edit(f'{"**You have these Folders :-**"}\n\n{FFF}\n\n{folder_m}')
await m.reply_text("**Now send the Folder ID to Download**")
input3 = message = await bot.listen(editable.chat.id)
raw_text3 = input3.text
respc = s.get(
f"https://api.classplusapp.com/v2/course/content/get?courseId={cr}&folderId={raw_text3}",
headers=headers,
).json()
ddata = respc["data"]["courseContent"]
if (respc["data"]["courseContent"][0]["contentType"]) == 1:
cool = ""
for datas in ddata:
id2 = datas["id"]
nam2 = datas["name"]
vid2 = datas["resources"]["videos"]
fid = datas["resources"]["files"]
datas["contentType"]
FFF = "**FOLDER-ID -FOLDER NAME -TOTAL VIDEOS/PDFS**"
cool += f" `{id2}` - **{nam2} -{vid2}**\n\n"
await editable.edit(f'{"**You have these Folders :-**"}\n\n{FFF}\n\n{cool}')
await m.reply_text("**Now send the Folder ID to Download**")
input4 = message = await bot.listen(editable.chat.id)
raw_text4 = input4.text
resp = s.get(
f"https://api.classplusapp.com/v2/course/content/get?courseId={cr}&folderId={raw_text4}",
headers=headers,
)
bdat = resp.json()["data"]["courseContent"]
bdat.reverse()
to_write = ""
for data in bdat:
id1 = data["id"]
nam2 = data["name"]
dis2 = data["description"]
url2 = data["url"]
data["contentType"]
to_write += f" `{id2}` - **{nam2} -{dis2}**\n"
mm = "careerplus1"
with open(f"{mm}.txt", "a") as f:
f.write(f"{to_write}")
await m.reply_document(f"{mm}.txt")
else:
ddata.reverse()
cool = ""
vj = ""
for data in ddata:
id2 = str(data["id"])
nam2 = data["name"]
url2 = data["url"]
des2 = data["description"]
# respc = s.get(f'https://api.classplusapp.com/cams/uploader/video/jw-signed-url?url={url}', headers=headers).json()
# urli = respc["url"]
FFF = "**Topic-ID -Topic NAME **"
aa = f" `{id2}` - **{nam2} -{des2}**\n\n"
if len(f"{vj}{aa}") > 4096:
# print(aa)
cool = ""
cool += aa
mm = "classplus"
with open(f"{mm}.txt", "a") as f:
f.write(f"{nam2}-{des2}:{url2}\n")
await m.reply_document(f"{mm}.txt")
# ================ Physics Wallah Commands ===============#
@bot.on_message(filters.command(["infopw"]))
async def info_login(bot: Client, m: Message):
if not one(m.from_user.id):
return await m.reply_text(
"✨ Hello Sir,\n\nContact Me Click Below",
reply_markup=keyboard,
)
editable = await m.reply_text(
"Send **Auth code** in this manner otherwise bot will not respond.\n\nSend like this:- **AUTH CODE**"
)
input1: Message = await bot.listen(editable.chat.id)
raw_text1 = input1.text
headers = {
"Host": "api.penpencil.co",
"authorization": f"Bearer {raw_text1}",
"client-id": "5eb393ee95fab7468a79d189",