├── Dockerfile ├── Installer ├── LICENSE ├── Procfile ├── README.md ├── __pycache__ └── core.cpython-312.pyc ├── app.json ├── core.py ├── heroku.yml ├── logs.py ├── main.py ├── requirements.txt ├── utils.py └── vars.py /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | RUN apt-get update -y && apt-get upgrade -y \ 3 | && apt-get install -y --no-install-recommends gcc libffi-dev musl-dev ffmpeg aria2 python3-pip \ 4 | && apt-get clean \ 5 | && rm -rf /var/lib/apt/lists/* 6 | 7 | COPY . /app/ 8 | WORKDIR /app/ 9 | RUN pip3 install --no-cache-dir --upgrade --requirement Installer 10 | CMD python3 modules/main.py 11 | -------------------------------------------------------------------------------- /Installer: -------------------------------------------------------------------------------- 1 | async-lru==2.0.2 2 | certifi==2023.5.7 3 | charset-normalizer==3.1.0 4 | idna==3.4 5 | mutagen==1.46.0 6 | pyaes==1.6.1 7 | pycryptodome==3.18.0 8 | pyrogram==2.0.106 9 | pyromod==1.5 10 | PySocks==1.7.1 11 | python-dotenv==1.0.0 12 | requests==2.31.0 13 | soupsieve==2.4.1 14 | TgCrypto==1.2.5 15 | urllib3==2.0.3 16 | websockets==11.0.3 17 | yt-dlp==2023.6.22 18 | motor 19 | aiohttp==3.8.4 20 | aiofiles 21 | pytz 22 | umongo==3.1.0 23 | speedtest-cli 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python main.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rishav'S Classplus Videos Downloader via Text File 2 | 3 | ## How to Deploy? 🤔. you can deploy on your VPS. 4 | 1. First Click on Star 5 | 2. Then Fork This Repo 6 | 3. Then Deploy Over Vps 7 | 8 | note This Repo will only work in VPS. 9 | 10 | ## Deploy to vps 11 | before Deploying Change your Credentials in Vars.py 12 | 13 | ``` 14 | sudo apt update 15 | git clone https://github.com/rishavdevkr/cpdown 16 | cd cpdown 17 | pip3 install -r requirements.txt 18 | python3 main.py 19 | Note:- use (nohup python3 main.py) to run 24×7 20 | ``` 21 | ### AVAILABLE COMMANDS 22 | ``` 23 | /start - check whether the bot is alive 24 | /Classplus - For downloading all app videos of Classplus app and all the other app which is available in you text Files such as .m3u8. 25 | ``` 26 | 27 | [![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/) 28 | 29 | -------------------------------------------------------------------------------- /__pycache__/core.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rishavdevkr/cpdown/8901cff939492e49245fea492f155f2fdbdaa691/__pycache__/core.cpython-312.pyc -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | 4 | "name": "MG", 5 | 6 | "description": "A Modular telegram bot.", 7 | 8 | "repository": "https://github.com/Devid176/idu", 9 | "buildpacks":[ 10 | { 11 | "url": "https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git" 12 | }, 13 | { 14 | "url": "https://github.com/amivin/aria2-heroku.git" 15 | }, 16 | { 17 | "url": "heroku/python" 18 | } 19 | ], 20 | "keywords": [ 21 | 22 | 23 | 24 | "telegram bot", 25 | 26 | "pyrogram" 27 | 28 | ], 29 | 30 | "env": { 31 | 32 | "BOT_TOKEN": { 33 | 34 | "description": "Your Bot token from @Botfather", 35 | "required": false 36 | 37 | }, 38 | 39 | "API_ID": { 40 | 41 | "description": "Your API_ID from https://my.telegram.org/apps", 42 | "required": false 43 | 44 | }, 45 | 46 | "API_HASH": { 47 | 48 | "description": "Your API_HASH from https://my.telegram.org/apps", 49 | "required": false 50 | 51 | } 52 | 53 | }, 54 | 55 | "buildpacks": [ 56 | 57 | { 58 | 59 | "url": "heroku/python" 60 | 61 | } 62 | 63 | ] 64 | 65 | } 66 | -------------------------------------------------------------------------------- /core.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import datetime 4 | import aiohttp 5 | import aiofiles 6 | import asyncio 7 | import logging 8 | import requests 9 | import tgcrypto 10 | import subprocess 11 | import concurrent.futures 12 | 13 | from utils import progress_bar 14 | 15 | from pyrogram import Client, filters 16 | from pyrogram.types import Message 17 | 18 | 19 | 20 | def duration(filename): 21 | result = subprocess.run(["ffprobe", "-v", "error", "-show_entries", 22 | "format=duration", "-of", 23 | "default=noprint_wrappers=1:nokey=1", filename], 24 | stdout=subprocess.PIPE, 25 | stderr=subprocess.STDOUT) 26 | return float(result.stdout) 27 | 28 | def exec(cmd): 29 | process = subprocess.run(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE) 30 | output = process.stdout.decode() 31 | print(output) 32 | return output 33 | #err = process.stdout.decode() 34 | def pull_run(work, cmds): 35 | with concurrent.futures.ThreadPoolExecutor(max_workers=work) as executor: 36 | print("Waiting for tasks to complete") 37 | fut = executor.map(exec,cmds) 38 | async def aio(url,name): 39 | k = f'{name}.pdf' 40 | async with aiohttp.ClientSession() as session: 41 | async with session.get(url) as resp: 42 | if resp.status == 200: 43 | f = await aiofiles.open(k, mode='wb') 44 | await f.write(await resp.read()) 45 | await f.close() 46 | return k 47 | 48 | 49 | async def download(url,name): 50 | ka = f'{name}.pdf' 51 | async with aiohttp.ClientSession() as session: 52 | async with session.get(url) as resp: 53 | if resp.status == 200: 54 | f = await aiofiles.open(ka, mode='wb') 55 | await f.write(await resp.read()) 56 | await f.close() 57 | return ka 58 | 59 | 60 | 61 | def parse_vid_info(info): 62 | info = info.strip() 63 | info = info.split("\n") 64 | new_info = [] 65 | temp = [] 66 | for i in info: 67 | i = str(i) 68 | if "[" not in i and '---' not in i: 69 | while " " in i: 70 | i = i.replace(" ", " ") 71 | i.strip() 72 | i = i.split("|")[0].split(" ",2) 73 | try: 74 | if "RESOLUTION" not in i[2] and i[2] not in temp and "audio" not in i[2]: 75 | temp.append(i[2]) 76 | new_info.append((i[0], i[2])) 77 | except: 78 | pass 79 | return new_info 80 | 81 | 82 | def vid_info(info): 83 | info = info.strip() 84 | info = info.split("\n") 85 | new_info = dict() 86 | temp = [] 87 | for i in info: 88 | i = str(i) 89 | if "[" not in i and '---' not in i: 90 | while " " in i: 91 | i = i.replace(" ", " ") 92 | i.strip() 93 | i = i.split("|")[0].split(" ",3) 94 | try: 95 | if "RESOLUTION" not in i[2] and i[2] not in temp and "audio" not in i[2]: 96 | temp.append(i[2]) 97 | 98 | # temp.update(f'{i[2]}') 99 | # new_info.append((i[2], i[0])) 100 | # mp4,mkv etc ==== f"({i[1]})" 101 | 102 | new_info.update({f'{i[2]}':f'{i[0]}'}) 103 | 104 | except: 105 | pass 106 | return new_info 107 | 108 | 109 | 110 | async def run(cmd): 111 | proc = await asyncio.create_subprocess_shell( 112 | cmd, 113 | stdout=asyncio.subprocess.PIPE, 114 | stderr=asyncio.subprocess.PIPE) 115 | 116 | stdout, stderr = await proc.communicate() 117 | 118 | print(f'[{cmd!r} exited with {proc.returncode}]') 119 | if proc.returncode == 1: 120 | return False 121 | if stdout: 122 | return f'[stdout]\n{stdout.decode()}' 123 | if stderr: 124 | return f'[stderr]\n{stderr.decode()}' 125 | 126 | 127 | 128 | def old_download(url, file_name, chunk_size = 1024 * 10): 129 | if os.path.exists(file_name): 130 | os.remove(file_name) 131 | r = requests.get(url, allow_redirects=True, stream=True) 132 | with open(file_name, 'wb') as fd: 133 | for chunk in r.iter_content(chunk_size=chunk_size): 134 | if chunk: 135 | fd.write(chunk) 136 | return file_name 137 | 138 | 139 | def human_readable_size(size, decimal_places=2): 140 | for unit in ['B', 'KB', 'MB', 'GB', 'TB', 'PB']: 141 | if size < 1024.0 or unit == 'PB': 142 | break 143 | size /= 1024.0 144 | return f"{size:.{decimal_places}f} {unit}" 145 | 146 | 147 | def time_name(): 148 | date = datetime.date.today() 149 | now = datetime.datetime.now() 150 | current_time = now.strftime("%H%M%S") 151 | return f"{date} {current_time}.mp4" 152 | 153 | 154 | async def download_video(url,cmd, name): 155 | download_cmd = f'{cmd} -R 25 --external-downloader aria2c --downloader-args "aria2c: -x 32 -j 64 -s 32 -k 2M --optimize-concurrent-downloads"' 156 | global failed_counter 157 | print(download_cmd) 158 | logging.info(download_cmd) 159 | k = subprocess.run(download_cmd, shell=True) 160 | if "visionias" in cmd and k.returncode != 0 and failed_counter <= 10: 161 | failed_counter += 1 162 | await asyncio.sleep(5) 163 | await download_video(url, cmd, name) 164 | failed_counter = 0 165 | try: 166 | if os.path.isfile(name): 167 | return name 168 | elif os.path.isfile(f"{name}.webm"): 169 | return f"{name}.webm" 170 | name = name.split(".")[0] 171 | if os.path.isfile(f"{name}.mkv"): 172 | return f"{name}.mkv" 173 | elif os.path.isfile(f"{name}.mp4"): 174 | return f"{name}.mp4" 175 | elif os.path.isfile(f"{name}.mp4.webm"): 176 | return f"{name}.mp4.webm" 177 | 178 | return name 179 | except FileNotFoundError as exc: 180 | return os.path.isfile.splitext[0] + "." + "mp4" 181 | 182 | 183 | async def send_doc(bot: Client, m: Message,cc,ka,cc1,prog,count,name): 184 | reply = await m.reply_text(f"Uploading » `{name}`") 185 | time.sleep(1) 186 | start_time = time.time() 187 | await m.reply_document(ka,caption=cc1) 188 | count+=1 189 | await reply.delete (True) 190 | time.sleep(1) 191 | os.remove(ka) 192 | time.sleep(3) 193 | 194 | 195 | async def send_vid(bot: Client, m: Message,cc,filename,thumb,name,prog): 196 | subprocess.run(f'ffmpeg -i "{filename}" -ss 00:01:00 -vframes 1 "{filename}.jpg"', shell=True) 197 | await prog.delete (True) 198 | reply = await m.reply_text(f"**⥣ Uploading ...** » `{name}`") 199 | try: 200 | if thumb == "no": 201 | thumbnail = f"{filename}.jpg" 202 | else: 203 | thumbnail = thumb 204 | except Exception as e: 205 | await m.reply_text(str(e)) 206 | 207 | dur = int(duration(filename)) 208 | 209 | start_time = time.time() 210 | 211 | try: 212 | await m.reply_video(filename,caption=cc, supports_streaming=True,height=720,width=1280,thumb=thumbnail,duration=dur, progress=progress_bar,progress_args=(reply,start_time)) 213 | except Exception: 214 | await m.reply_document(filename,caption=cc, progress=progress_bar,progress_args=(reply,start_time)) 215 | os.remove(filename) 216 | 217 | os.remove(f"{filename}.jpg") 218 | await reply.delete (True) 219 | 220 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | worker: Dockerfile 4 | run: 5 | worker: python3 modules/main.py 6 | -------------------------------------------------------------------------------- /logs.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from logging.handlers import RotatingFileHandler 3 | 4 | logging.basicConfig( 5 | level=logging.ERROR, 6 | format= 7 | "%(asctime)s - %(levelname)s - %(message)s [%(filename)s:%(lineno)d]", 8 | datefmt="%d-%b-%y %H:%M:%S", 9 | handlers=[ 10 | RotatingFileHandler("logs.txt", maxBytes=50000000, backupCount=10), 11 | logging.StreamHandler(), 12 | ], 13 | ) 14 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 15 | 16 | 17 | logging = logging.getLogger() 18 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import sys 4 | import json 5 | import time 6 | import asyncio 7 | import requests 8 | import subprocess 9 | import core as helper 10 | from utils import progress_bar 11 | from vars import api_id, api_hash, bot_token, auth_users, sudo_user, log_channel, txt_channel 12 | from aiohttp import ClientSession 13 | from pyromod import listen 14 | from subprocess import getstatusoutput 15 | from pyrogram import Client, filters 16 | from pyrogram.types import Message 17 | from pyrogram.errors import FloodWait 18 | from pyrogram.errors.exceptions.bad_request_400 import StickerEmojiInvalid 19 | from pyrogram.types.messages_and_media import message 20 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 21 | 22 | bot = Client( 23 | "bot", 24 | api_id=api_id, 25 | api_hash=api_hash, 26 | bot_token=bot_token) 27 | 28 | @bot.on_message(filters.command(["start"])) 29 | async def account_login(bot: Client, m: Message): 30 | editable = await m.reply_text("Hi!\n\nGive /classplus Command and send me Text file to Downlaod.\n") 31 | 32 | @bot.on_message(filters.command("restart")) 33 | async def restart_handler(_, m): 34 | await m.reply_text("**I'm Restarted**🚦", True) 35 | os.execl(sys.executable, sys.executable, *sys.argv) 36 | 37 | @bot.on_message(filters.command("terms")) 38 | async def terms_han(bot: Client, m: Message): 39 | 40 | await m.reply_text("Dear user,\n\nWelcome to our video downloader bot on Telegram. Before you start using our bot, please read these terms and conditions carefully.\n\nBy using our bot, you agree to the following terms and conditions:\n\n1. Our bot is intended for personal, non-commercial use only. You are responsible for any content that you download through our bot and you should ensure that you have the necessary permissions and rights to use and share the content.\n\n2. Downloading copyrighted content through our bot is strictly prohibited. If we receive any complaints of copyright infringement, we reserve the right to take down the infringing content and terminate the user's access to our bot.\n\n3. We do not store any of your personal data or download history. Your privacy and security are important to us, and we have taken all necessary measures to ensure that your information is safe and protected.\n\n4. We reserve the right to suspend or terminate the bot's services at any time and for any reason.\n\n5. By using our bot, you agree to indemnify and hold us harmless from any claims, damages,\nor losses arising from your use of our bot.\n\nIf you have any questions or concerns about our terms and conditions, please contact us.\n\nThank you for using our video downloader bot on Telegram.\n\nBest regards,\nRishav") 41 | 42 | @bot.on_message(filters.command(["classplus"])) 43 | async def account_login(bot: Client, m: Message): 44 | editable = await m.reply_text('Hi\n\nI am Ready to download send me a text file» ') 45 | input: Message = await bot.listen(editable.chat.id) 46 | x = await input.download() 47 | await input.delete(True) 48 | 49 | path = f"./downloads/{m.chat.id}" 50 | 51 | try: 52 | with open(x, "r") as f: 53 | content = f.read() 54 | content = content.split("\n") 55 | links = [] 56 | for i in content: 57 | links.append(i.split("://", 1)) 58 | os.remove(x) 59 | # print(len(links) 60 | except: 61 | await m.reply_text("Invalid file input.") 62 | os.remove(x) 63 | return 64 | 65 | 66 | await editable.edit(f"Total links founds in Text File are **{len(links)}**\n\nSend From where you want to download initial is **1**") 67 | input0: Message = await bot.listen(editable.chat.id) 68 | raw_text = input0.text 69 | await input0.delete(True) 70 | 71 | await editable.edit("**Enter Batch Name**") 72 | input1: Message = await bot.listen(editable.chat.id) 73 | raw_text0 = input1.text 74 | await input1.delete(True) 75 | 76 | 77 | await editable.edit("**Enter resolution**") 78 | input2: Message = await bot.listen(editable.chat.id) 79 | raw_text2 = input2.text 80 | await input2.delete(True) 81 | try: 82 | if raw_text2 == "144": 83 | res = "256x144" 84 | elif raw_text2 == "240": 85 | res = "426x240" 86 | elif raw_text2 == "360": 87 | res = "640x360" 88 | elif raw_text2 == "480": 89 | res = "854x480" 90 | elif raw_text2 == "720": 91 | res = "1280x720" 92 | elif raw_text2 == "1080": 93 | res = "1920x1080" 94 | else: 95 | res = "UN" 96 | except Exception: 97 | res = "UN" 98 | 99 | 100 | 101 | await editable.edit("Enter A Caption or Downloded by to add Otherwise send **no**") 102 | input3: Message = await bot.listen(editable.chat.id) 103 | raw_text3 = input3.text 104 | await input3.delete(True) 105 | highlighter = f"️ " 106 | if raw_text3 == 'no': 107 | MR = highlighter 108 | else: 109 | MR = raw_text3 110 | 111 | await editable.edit("Now send the **Thumb url**\nEg » ```https://telegra.ph/file/0633f8b6a6f110d34f044.jpg```\n\nor Send `no`") 112 | input6 = message = await bot.listen(editable.chat.id) 113 | raw_text6 = input6.text 114 | await input6.delete(True) 115 | await editable.delete() 116 | 117 | thumb = input6.text 118 | if thumb.startswith("http://") or thumb.startswith("https://"): 119 | getstatusoutput(f"wget '{thumb}' -O 'thumb.jpg'") 120 | thumb = "thumb.jpg" 121 | else: 122 | thumb == "no" 123 | 124 | if len(links) == 1: 125 | count = 1 126 | else: 127 | count = int(raw_text) 128 | 129 | try: 130 | for i in range(count - 1, len(links)): 131 | 132 | V = links[i][1].replace("file/d/","uc?export=download&id=").replace("www.youtube-nocookie.com/embed", "youtu.be").replace("?modestbranding=1", "").replace("/view?usp=sharing","") # .replace("mpd","m3u8") 133 | url = "https://" + V 134 | 135 | if "visionias" in url: 136 | async with ClientSession() as session: 137 | async with session.get(url, headers={'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Accept-Language': 'en-US,en;q=0.9', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Referer': 'http://www.visionias.in/', 'Sec-Fetch-Dest': 'iframe', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'cross-site', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Linux; Android 12; RMX2121) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Mobile Safari/537.36', 'sec-ch-ua': '"Chromium";v="107", "Not=A?Brand";v="24"', 'sec-ch-ua-mobile': '?1', 'sec-ch-ua-platform': '"Android"',}) as resp: 138 | text = await resp.text() 139 | url = re.search(r"(https://.*?playlist.m3u8.*?)\"", text).group(1) 140 | 141 | elif "edge.api.brightcove.com" in url: 142 | b ='bcov_auth=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3MjM5ODg5NDQsImNvbiI6eyJpc0FkbWluIjpmYWxzZSwiYXVzZXIiOiJVMFZ6TkdGU2NuQlZjR3h5TkZwV09FYzBURGxOZHowOSIsImlkIjoiYWtOblpHSlVWUzlzUzB0RFpERlJaMUJtTVZwRVVUMDkiLCJmaXJzdF9uYW1lIjoiY2xjck0wWnpaWGhoWkhoemQyMXVVV3hSVlZwc1p6MDkiLCJlbWFpbCI6IlJFOVhVVTV6TWl0eVNXOU5aMDFhVGk5VGRIUmFVbWRhV2pWcVEyTldTa0pNVVZNMUwyMUxlRkpUWnowPSIsInBob25lIjoiYjJsR1UwWkRUakpOYjAxWVVITnBVekVyTDBwWVFUMDkiLCJhdmF0YXIiOiJLM1ZzY1M4elMwcDBRbmxrYms4M1JEbHZla05pVVQwOSIsInJlZmVycmFsX2NvZGUiOiJSVUpVZERSMGEwbDBURXhXZGxwWFYzbHFLelpMVVQwOSIsImRldmljZV90eXBlIjoiYW5kcm9pZCIsImRldmljZV92ZXJzaW9uIjoidXBwZXIgdGhhbiAzMSIsImRldmljZV9tb2RlbCI6IlhpYW9NaSBNMjAwN0oxN0MiLCJyZW1vdGVfYWRkciI6IjQ0LjE5Mi4xMjAuMTU5In19.blaAt5iAFST3RDAuBzXnC9hD6NALfx0Jyuc21J3p-uLUcFXW7gOnE2fNqRENwcTTE62-tsv3xV6OZtA3lj0wf0JPD8GD9umMMoLva45SPaxccFP0vHAfoC0wzc4U_Yr5-FnIBv-S6Qhy7IltO7EnMgxHeNhHlmk782-JGEqphYZV4wkcd_GAIpkRo55J6JoF17hdAAzTe-_DkrTlTUI6xBvbR1RvS5n9PZ5UG6LuQiv9MZqHUkLDOmdSc1OJw3o9-YXGV_98b5ysa66oCXHLW2i9u0C98WDNlDGn0kyBVMLrBMvrzZajmsjsC0jyh9T0eY3LvcNnUIl7HSqJ471asQ' 143 | url = url.split("bcov_auth")[0]+b 144 | # url = url.replace(url.split("/")[-1], res+'.mp4') 145 | elif "apps-s3-jw-prod.utkarshapp.com" in url: 146 | if 'enc_plain_mp4' in url: 147 | url = url.replace(url.split("/")[-1], res+'.mp4') 148 | 149 | elif 'Key-Pair-Id' in url: 150 | url = None 151 | 152 | elif '.m3u8' in url: 153 | q = ((m3u8.loads(requests.get(url).text)).data['playlists'][1]['uri']).split("/")[0] 154 | x = url.split("/")[5] 155 | x = url.replace(x, "") 156 | url = ((m3u8.loads(requests.get(url).text)).data['playlists'][1]['uri']).replace(q+"/", x) 157 | 158 | 159 | elif 'videos.classplusapp' in url: 160 | url = requests.get(f'https://api.classplusapp.com/cams/uploader/video/jw-signed-url?url={url}', headers={'x-access-token': 'eyJjb3Vyc2VJZCI6IjQ1NjY4NyIsInR1dG9ySWQiOm51bGwsIm9yZ0lkIjo0ODA2MTksImNhdGVnb3J5SWQiOm51bGx9'}).json()['url'] 161 | 162 | elif 'tencdn.classplusapp' in url: 163 | url = requests.get(f'https://api.classplusapp.com/cams/uploader/video/jw-signed-url?url={url}', headers={'x-access-token': 'eyJjb3Vyc2VJZCI6IjQ1NjY4NyIsInR1dG9ySWQiOm51bGwsIm9yZ0lkIjo0ODA2MTksImNhdGVnb3J5SWQiOm51bGx9'}).json()['url'] 164 | 165 | elif 'media-cdn' in url or 'webvideos' in url or 'drmcdni' in url: 166 | url = requests.get(f'https://api.classplusapp.com/cams/uploader/video/jw-signed-url?url={url}', headers={'x-access-token': 'eyJjb3Vyc2VJZCI6IjQ1NjY4NyIsInR1dG9ySWQiOm51bGwsIm9yZ0lkIjo0ODA2MTksImNhdGVnb3J5SWQiOm51bGx9'}).json()['url'] 167 | elif '/master.mpd' in url: 168 | id = url.split("/")[-2] 169 | url = "https://d26g5bnklkwsh4.cloudfront.net/" + id + "/master.m3u8" 170 | 171 | name1 = links[i][0].replace("\t", "").replace(":", "").replace("/", "").replace("+", "").replace("#", "").replace("|", "").replace("@", "").replace("*", "").replace(".", "").replace("https", "").replace("http", "").strip() 172 | name = f'{str(count).zfill(3)}) {name1[:60]}' 173 | 174 | if "youtu" in url: 175 | ytf = f"b[height<={raw_text2}][ext=mp4]/bv[height<={raw_text2}][ext=mp4]+ba[ext=m4a]/b[ext=mp4]" 176 | else: 177 | ytf = f"b[height<={raw_text2}]/bv[height<={raw_text2}]+ba/b/bv+ba" 178 | 179 | if "jw-prod" in url: 180 | cmd = f'yt-dlp -o "{name}.mp4" "{url}"' 181 | else: 182 | cmd = f'yt-dlp -f "{ytf}" "{url}" -o "{name}.mp4"' 183 | 184 | try: 185 | 186 | cc = f'** {str(count).zfill(3)}.** {𝗻𝗮𝗺𝗲𝟭}{MR}.mkv\n**Batch »** {raw_text0}\n\n' 187 | cc1 = f'** {str(count).zfill(3)}.** {𝗻𝗮𝗺𝗲𝟭}{MR}.pdf \n**Batch »** {raw_text0}\n\n' 188 | if "drive" in url: 189 | try: 190 | ka = await helper.download(url, name) 191 | copy = await bot.send_document(chat_id=m.chat.id,document=ka, caption=cc1) 192 | count+=1 193 | os.remove(ka) 194 | time.sleep(1) 195 | except FloodWait as e: 196 | await m.reply_text(str(e)) 197 | time.sleep(e.x) 198 | continue 199 | 200 | elif ".pdf" in url: 201 | try: 202 | cmd = f'yt-dlp -o "{name}.pdf" "{url}"' 203 | download_cmd = f"{cmd} -R 25 --fragment-retries 25" 204 | os.system(download_cmd) 205 | copy = await bot.send_document(chat_id=m.chat.id, document=f'{name}.pdf', caption=cc1) 206 | count += 1 207 | os.remove(f'{name}.pdf') 208 | except FloodWait as e: 209 | await m.reply_text(str(e)) 210 | time.sleep(e.x) 211 | continue 212 | else: 213 | Show = f"**⥥ Downloading »**\n\n**Name »** `{name}\nQuality » {raw_text2}`\n\n**Piracy is illegal 🚫**\n\nEnter /terms To know our terms and conditions." 214 | prog = await m.reply_text(Show) 215 | res_file = await helper.download_video(url, cmd, name) 216 | filename = res_file 217 | await prog.delete(True) 218 | await helper.send_vid(bot, m, cc, filename, thumb, name, prog) 219 | count += 1 220 | time.sleep(1) 221 | 222 | except Exception as e: 223 | await m.reply_text( 224 | f"**downloading Interupted **\n{str(e)}\n**Name** » {name}\n**Link** » `{url}`" 225 | ) 226 | continue 227 | 228 | except Exception as e: 229 | await m.reply_text(e) 230 | await m.reply_text("Done") 231 | 232 | 233 | bot.run() 234 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram 2 | pyromod 3 | psutil 4 | PySocks 5 | py-tgcalls==0.6.0 6 | pytz 7 | python-dotenv 8 | pycryptodome 9 | pyaes 10 | tgcrypto 11 | requests 12 | yt-dlp 13 | ffmpeg 14 | beautifulsoup4==4.9.3 15 | bs4==0.0.1 16 | aiohttp 17 | aiofiles 18 | mediainfo 19 | cloudscraper 20 | helper 21 | soupsieve 22 | urllib3 23 | websockets 24 | async-lru 25 | certifi 26 | charset-normalizer 27 | idna 28 | mutagen 29 | -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | import time 2 | import math 3 | import os 4 | from pyrogram.errors import FloodWait 5 | 6 | class Timer: 7 | def __init__(self, time_between=5): 8 | self.start_time = time.time() 9 | self.time_between = time_between 10 | 11 | def can_send(self): 12 | if time.time() > (self.start_time + self.time_between): 13 | self.start_time = time.time() 14 | return True 15 | return False 16 | 17 | from datetime import datetime,timedelta 18 | 19 | 20 | #lets do calculations 21 | def hrb(value, digits= 2, delim= "", postfix=""): 22 | """Return a human-readable file size. 23 | """ 24 | if value is None: 25 | return None 26 | chosen_unit = "B" 27 | for unit in ("KiB", "MiB", "GiB", "TiB"): 28 | if value > 1000: 29 | value /= 1024 30 | chosen_unit = unit 31 | else: 32 | break 33 | return f"{value:.{digits}f}" + delim + chosen_unit + postfix 34 | 35 | def hrt(seconds, precision = 0): 36 | """Return a human-readable time delta as a string. 37 | """ 38 | pieces = [] 39 | value = timedelta(seconds=seconds) 40 | 41 | 42 | if value.days: 43 | pieces.append(f"{value.days}d") 44 | 45 | seconds = value.seconds 46 | 47 | if seconds >= 3600: 48 | hours = int(seconds / 3600) 49 | pieces.append(f"{hours}h") 50 | seconds -= hours * 3600 51 | 52 | if seconds >= 60: 53 | minutes = int(seconds / 60) 54 | pieces.append(f"{minutes}m") 55 | seconds -= minutes * 60 56 | 57 | if seconds > 0 or not pieces: 58 | pieces.append(f"{seconds}s") 59 | 60 | if not precision: 61 | return "".join(pieces) 62 | 63 | return "".join(pieces[:precision]) 64 | 65 | 66 | 67 | timer = Timer() 68 | 69 | async def progress_bar(current, total, reply, start): 70 | if timer.can_send(): 71 | now = time.time() 72 | diff = now - start 73 | if diff < 1: 74 | return 75 | else: 76 | perc = f"{current * 100 / total:.1f}%" 77 | elapsed_time = round(diff) 78 | speed = current / elapsed_time 79 | remaining_bytes = total - current 80 | if speed > 0: 81 | eta_seconds = remaining_bytes / speed 82 | eta = hrt(eta_seconds, precision=1) 83 | else: 84 | eta = "-" 85 | sp = str(hrb(speed)) + "/s" 86 | tot = hrb(total) 87 | cur = hrb(current) 88 | bar_length = 11 89 | completed_length = int(current * bar_length / total) 90 | remaining_length = bar_length - completed_length 91 | progress_bar = "▓" * completed_length + "▒" * remaining_length 92 | 93 | try: 94 | await reply.edit(f'`\n ╭──⌯═════Bot Statics═════⌯───╮ \n├⚡ {progress_bar}|﹝{perc}﹞ \n├🚀 Speed » {sp} \n├📟 Processed » {cur}\n├🧲 Size - ETA » {tot} - {eta} \n╰─═══⌯✪Powered By Rishav✪⌯═══─╯`\n') 95 | except FloodWait as e: 96 | time.sleep(e.x) 97 | 98 | -------------------------------------------------------------------------------- /vars.py: -------------------------------------------------------------------------------- 1 | api_id = 35814071 #change_with_your_Api_id. 2 | api_hash = "80c231f0e8704995b8259d06965n4351" #change_with_your_Api_hash. 3 | bot_token = "7198600769:AAHfVi7qTaMw20HbpvPrF-fnP77-sWdOthI" #change_with_your_bot_token. 4 | auth_users = [999741495] #change_with_your_user_id. 5 | sudo_user = 1713924419 #change_with_your_user_id. 6 | log_channel = -1002154281532 #change_with_your_channel_id. 7 | txt_channel = -1002154281532 #change_with_your_channel_id. 8 | --------------------------------------------------------------------------------