-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbot.py
More file actions
225 lines (212 loc) · 8.3 KB
/
bot.py
File metadata and controls
225 lines (212 loc) · 8.3 KB
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
import urllib
import urllib.parse
import requests
import json
import subprocess
from pyrogram.types.messages_and_media import message
import helper
from pyromod import listen
from pyrogram.types import Message
import tgcrypto
import pyrogram
from pyrogram import Client, filters
from pyrogram.types.messages_and_media import message
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from pyrogram.errors import FloodWait
import time
from pyrogram import Client as bot
from pyrogram.types import User, Message
from p_bar import progress_bar
from subprocess import getstatusoutput
import asyncio, logging
from logging.handlers import RotatingFileHandler
import os
import sys
import re
import cloudscraper
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
from base64 import b64encode, b64decode
LOGGER = logging.getLogger(__name__)
logging.basicConfig(
level=logging.INFO,
format="%(name)s - %(message)s",
datefmt="%d-%b-%y %H:%M:%S",
handlers=[
RotatingFileHandler(
"log.txt", maxBytes=5000000, backupCount=10
),
logging.StreamHandler(),
],
)
bot = Client(
"bot",
api_id= 22779671,
api_hash= "125d8d88b77309dc3b154cbbfc2dacb2",
bot_token= "6847175705:AAHbkU8GFmzoxR9dCQTr6RuZ4NQsev5ufz0"
)
@bot.on_message(filters.command(["cp"]))
async def account_login(bot: Client, m: Message):
global cancel
cancel = False
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': '35',
'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"]
print(b_data)
await input1.delete(True)
cool = ""
for data in b_data:
t_name =data['batchName']
t_id =data['batchId']
FFF = "**BATCH-ID - BATCH NAME**"
aa = f" ```{t_id}``` - **{t_name}**\n\n"
# aa=f"**Batch Name -** {data['batchName']}\n**Batch ID -** ```{data['id']}```\n**By -** {data['instructorName']}\n\n"
if len(f'{cool}{aa}') > 4096:
print(aa)
cool = ""
cool += aa
await editable.edit(f'{"**You have these batches :-**"}\n\n{FFF}\n\n{cool}')
editable1 = await m.reply_text("**Now send the Batch ID to Download**")
input2 = message = await bot.listen(editable.chat.id)
cr = input2.text
resp = s.get(f'https://api.classplusapp.com/v2/course/content/get?courseId={cr}', headers=headers)
print(resp.content)
b_data = resp.txt()['data']['courseContent']
cool = ""
for data in b_data:
id1 = data['id']
nam2 = data["name"]
content = data["contentType"]
FFF = "**FOLDER-ID - FOLDER NAME**"
aa = f" ```{id1}``` - **{nam2}**\n\n"
if len(f'{cool}{aa}') > 4096:
print(aa)
cool = ""
cool += aa
await editable.edit(f'{"**You have these Folders :-**"}\n\n{FFF}\n\n{cool}')
editable1 = await m.reply_text("**Now send the Batch ID to Download**")
input2 = message = await bot.listen(editable.chat.id)
raw_text2 = input2.text
await editable1.delete(True)
resp = s.get(f'https://api.classplusapp.com/v2/course/content/get?courseId={cr}&folderId={raw_text2}', headers=headers)
bdata = resp.json()['data']['courseContent']
cool = ""
for data in bdata:
id1 = data['id']
nam2 = data["name"]
vid = data["resources"]["videos"]
fid = data["resources"]["files"]
content = data["contentType"]
FFF = "**FOLDER-ID -FOLDER NAME -TOTAL VIDEOS/PDFS**"
aa = f" ```{id1}``` - **{nam2} -{vid} -{fid}**\n\n"
if len(f'{cool}{aa}') > 4096:
cool = ""
cool += aa
await editable.edit(f'{"**You have these Folders :-**"}\n\n{FFF}\n\n{cool}')
await input2.delete(True)
editable1 = await m.reply_text("**Now send the Folder ID to Download**")
input3 = message = await bot.listen(editable.chat.id)
raw_text3 = input3.text
await editable1.delete(True)
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:
bdata = resp.json()['data']['courseContent']
cool = ""
for datas in ddata:
id2 = datas['id']
nam2 = datas["name"]
vid2 = datas["resources"]["videos"]
fid = datas["resources"]["files"]
content = datas["contentType"]
print(id2,nam2,vid)
FFF = "**FOLDER-ID -FOLDER NAME -TOTAL VIDEOS/PDFS**"
aa = f" ```{id2}``` - **{nam2} -{vid2}**\n\n"
if len(f'{cool}{aa}') > 4096:
cool = ""
cool += aa
await editable.edit(f'{"**You have these Folders :-**"}\n\n{FFF}\n\n{cool}')
await input2.delete(True)
editable1 = await m.reply_text("**Now send the Folder ID to Download**")
input4 = message = await bot.listen(editable.chat.id)
raw_text4 = input4.text
await editable1.delete(True)
resp = s.get(f'https://api.classplusapp.com/v2/course/content/get?courseId={cr}&folderId={raw_text4}', headers=headers)
#print(resp)
bdat = resp.json()['data']['courseContent']
bdat.reverse()
#print(bdat)
cool = ""
vj1 = ""
for data in bdat:
id1 = data['id']
nam2 = data["name"]
dis2 = data["description"]
url2 = data["url"]
content = data["contentType"]
FFF = "**Topic-ID -Topic NAME **"
aa = f" ```{id2}``` - **{nam2} -{dis2}**\n\n"
if len(f'{vj1}{aa}') > 4096:
#print(aa)
cool = ""
cool += aa
mm = "careerplus1"
with open(f'{mm}.txt', 'a') as f:
f.write(f"{nam2}-{dis2}:{url2}\n")
await m.reply_document(f"{mm}.txt")
await input4.delete(True)
await editable.edit(f'{"**You have these Videos :-**"}\n\n{FFF}\n\n{cool}')
else:
ddata.reverse()
cool = ""
vj = ""
for data in ddata:
id2 = str(data['id'])
#idid = f"{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")
await editable.edit(f'{"**You have these Videos :-**"}\n\n{FFF}\n\n{cool}')
#await m.reply_document(f"{nam2}.txt")
await input3.delete(True)
await m.reply_text("Done")
bot.run()