├── Dockerfile ├── Procfile ├── README.md ├── binaries ├── aria2c ├── aria2c.exe ├── yt-dlp └── yt-dlp.exe ├── config.json ├── docker-compose.yml ├── ffmpeg ├── ffmpeg.zip ├── ffmpeg_L.zip ├── ffprobe.zip ├── ffprobe_L.zip └── qt-faststart ├── main.py ├── mdisk.py ├── mediainfo.py ├── requirements.txt └── split.py /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt /app/ 6 | 7 | RUN pip3 install -r requirements.txt 8 | 9 | COPY . /app 10 | 11 | CMD python3 main.py 12 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python3 main.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mdisk Downloader Bot 2 | 3 | *A Telegram MDisk Video Downloader Bot, You can watch downloaded Videos without MX player (bypass mdisk requirements)* 4 | 5 | _This project is partly possible because of the donations from [𝓐 𝓙𝓪𝓴𝓱𝓪𝓻](https://t.me/Aaajats)_ 6 | 7 | --- 8 | 9 | # Variables 10 | 11 | _You can use [config.json](https://github.com/bipinkrish/Mdisk-Downloader-Bot/blob/master/config.json) instead of ENVs_ 12 | 13 | #### Required 14 | 15 | - `HASH` Your API Hash from my.telegram.org 16 | - `ID` Your API ID from my.telegram.org 17 | - `TOKEN` Your bot token from @BotFather 18 | 19 | #### Control (optionals) 20 | 21 | - `AUTH` List of Authenticated User's ID seperated by a space (everyone can use the bot if it is empty) 22 | - `BAN` List of Banned User's ID seperated by a space (everyone can use the bot if it is empty) 23 | - `OWNER` List of Owner User's ID seperated by a space (no one is owner if it is empty) 24 | 25 | #### Premium Features (optionals) (only use this if you have Premium Account) (both are needed if any one is set) 26 | 27 | - `STRING` Premium User String Session 28 | - `TEMP_CHAT` Username or ID of Chat (Channel or Group, Private, Public), both User account and Bot should have access to messages in that chat (basically a log chat but required not optional) 29 | 30 | #### Force Join (both are needed if any one is set) 31 | 32 | - `TARGET` Chat's ID or Username 33 | - `LINK` Chat's joining Link 34 | 35 | --- 36 | 37 | # Commands 38 | 39 | ### For Normal Users 40 | 41 | ``` 42 | start - Start Message 43 | help - List of Commands 44 | mdisk - Usage 45 | thumb - Reply to a Image of size less than 200KB to set it as Thumbnail 46 | remove - Remove Thumbnail 47 | show - Show Thumbnail 48 | change - Change Upload Mode (Document/Stream) 49 | ``` 50 | 51 | ### For Owners 52 | 53 | _It is temporary, once bot is redoplyed or config file is deleted it will go back to default values_ 54 | 55 | ``` 56 | auth - Auth a user 57 | unauth - UnAuth a user 58 | ban - Ban a user 59 | unban - UnBan a user 60 | members - see the list of Owners,Auths,Bans 61 | ``` 62 | 63 | --- 64 | 65 | # Running Locally 66 | 67 | _Clone the repositary_ 68 | 69 | ``` 70 | git clone https://github.com/bipinkrish/Mdisk-Downloader-Bot.git 71 | cd Mdisk-Downloader-Bot 72 | ``` 73 | 74 | _open `config.json` file and set the variables and start the bot_ 75 | 76 | ``` 77 | python main.py 78 | ``` 79 | 80 | --- -------------------------------------------------------------------------------- /binaries/aria2c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/binaries/aria2c -------------------------------------------------------------------------------- /binaries/aria2c.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/binaries/aria2c.exe -------------------------------------------------------------------------------- /binaries/yt-dlp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/binaries/yt-dlp -------------------------------------------------------------------------------- /binaries/yt-dlp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/binaries/yt-dlp.exe -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "TOKEN": "", 3 | "ID": "", 4 | "HASH": "", 5 | "AUTH": "", 6 | "BAN": "", 7 | "STRING": "", 8 | "TMEP_CHAT": "", 9 | "OWNER": "", 10 | "TARGET": "", 11 | "LINK": "" 12 | } -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | workerdisk: 4 | build: . 5 | environment: 6 | - ID=${ID} 7 | - HASH=${HASH} 8 | - TOKEN=${TOKEN} 9 | -------------------------------------------------------------------------------- /ffmpeg/ffmpeg.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/ffmpeg/ffmpeg.zip -------------------------------------------------------------------------------- /ffmpeg/ffmpeg_L.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/ffmpeg/ffmpeg_L.zip -------------------------------------------------------------------------------- /ffmpeg/ffprobe.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/ffmpeg/ffprobe.zip -------------------------------------------------------------------------------- /ffmpeg/ffprobe_L.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/ffmpeg/ffprobe_L.zip -------------------------------------------------------------------------------- /ffmpeg/qt-faststart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bipinkrish/Mdisk-Downloader-Bot/4e099703254d6794b46facb53131f97235819c2e/ffmpeg/qt-faststart -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import threading 3 | import subprocess 4 | import time 5 | import json 6 | 7 | import pyrogram 8 | from pyrogram import Client, filters 9 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, BotCommand 10 | 11 | from mdisk import iswin, getinfo, mdow, merge 12 | import mediainfo 13 | from split import TG_SPLIT_SIZE, split_file, get_path_size, ss, temp_channel, isPremmium 14 | 15 | # conifg 16 | with open('config.json', 'r') as f: CONFIGDATA = json.load(f) 17 | 18 | # app 19 | TOKEN = os.environ.get("TOKEN") or CONFIGDATA.get("TOKEN", "") 20 | HASH = os.environ.get("HASH") or CONFIGDATA.get("HASH", "") 21 | ID = os.environ.get("ID") or CONFIGDATA.get("ID", "") 22 | app = Client("my_bot", api_id=ID, api_hash=HASH, bot_token=TOKEN) 23 | 24 | # preiumum 25 | if isPremmium: acc = Client("myacc", api_id=ID, api_hash=HASH, session_string=ss) 26 | 27 | # optionals 28 | AUTH = os.environ.get("AUTH") or CONFIGDATA.get("AUTH", "") 29 | AUTHUSERS = AUTH.split() 30 | BAN = os.environ.get("BAN") or CONFIGDATA.get("BAN", "") 31 | BANNEDUSERS = BAN.split() 32 | 33 | # control 34 | OWNER = os.environ.get("OWNER") or CONFIGDATA.get("OWNER", "") 35 | OWNERS = OWNER.split() 36 | TARGET = os.environ.get("TARGET") or CONFIGDATA.get("TARGET", "") 37 | LINK = os.environ.get("LINK") or CONFIGDATA.get("LINK", "") 38 | 39 | 40 | # setting commands 41 | cmds = ["start","help","mdisk","thumb","remove","show","change"] 42 | descs = ["Basic Usage","Help Message","Usage","Reply to a Image of size less than 200KB to set it as Thumbnail","Remove Thumbnail","Show Thumbnail","Change Upload Mode"] 43 | with app: app.set_bot_commands(BotCommand(cmds[i].lower(),descs[i]) for i in range(len(cmds))) 44 | 45 | 46 | # formats data 47 | datalist = {} 48 | def adddata(id,mod): datalist[id] = mod 49 | def getdata(id): return datalist.get(id,"D") 50 | def swap(id): 51 | temp = getdata(id) 52 | if temp == "V": adddata(id,"D") 53 | else: adddata(id,"V") 54 | return getdata(id) 55 | 56 | 57 | # msgs data 58 | msgsdata = {} 59 | def store(message,info,link): msgsdata[str(message.id)] = [message,info,link] 60 | def get(id): return msgsdata.get(str(id), [None,None,None]) 61 | 62 | 63 | # locks 64 | locks = {} 65 | def setlock(uid,mid): locks[str(uid)] = mid 66 | def getlock(uid): return locks.get(str(uid), None) 67 | 68 | 69 | # progress tracker 70 | prev = {} 71 | prevtime = {} 72 | 73 | # Create a progress bar 74 | def progress_bar(progress): 75 | bar_length = 12 76 | filled_length = int(progress / (100/bar_length)) 77 | bar = '█' * filled_length + '░' * (bar_length - filled_length) 78 | return f"[{bar}] {progress:.2f}%" 79 | 80 | # format msgs 81 | def getformatmsg(filename,status,procs,size,firsttime=False): 82 | if firsttime: 83 | previous_progress = 0 84 | previous_time = time.time() 85 | else: 86 | previous_progress = prev[filename] 87 | previous_time = prevtime[filename] 88 | 89 | progress = procs / size * 100 90 | speed = (progress - previous_progress) / (time.time() - previous_time) * 12.4 91 | prev[filename] = progress 92 | prevtime[filename] = time.time() 93 | 94 | return f"**{filename}**\n\n\ 95 | ┌ Status: **{status}**\n\ 96 | ├ {progress_bar(progress)}\n\ 97 | ├ Processed: **{procs/1048000:.2f} MB**\n\ 98 | ├ Total Size: **{size/1048000:.2f} MB**\n\ 99 | └ Speed: **{speed:.2f} MB/s**" 100 | 101 | 102 | # check for user access 103 | def checkuser(message): 104 | if isowner(message): return True 105 | user_id = str(message.from_user.id) 106 | if AUTHUSERS and user_id not in AUTHUSERS: return False 107 | if user_id in BANNEDUSERS: return False 108 | return True 109 | 110 | 111 | # check for owner 112 | def isowner(message): 113 | if str(message.from_user.id) in OWNERS: return True 114 | return False 115 | 116 | 117 | # download status 118 | def status(folder,message,fsize,filename): 119 | 120 | # wait for the folder to create 121 | while True: 122 | if os.path.exists(folder + "/vid.mp4.part-Frag0") or os.path.exists(folder + "/vid.mp4.part"): 123 | break 124 | 125 | time.sleep(3) 126 | while os.path.exists(folder + "/" ): 127 | if "Status: Merging" in app.get_messages(message.chat.id, message.id).text: return 128 | 129 | if iswin == "0": 130 | result = subprocess.run(["du", "-hsb", f"{folder}/"], capture_output=True, text=True) 131 | size = float(str(result.stdout).split()[0]) 132 | else: 133 | os.system(f"dir /a/s {folder} > tempS-{message.id}.txt") 134 | size = float(open(f"tempS-{message.id}.txt","r").readlines()[-2].split()[2].replace(",","")) 135 | 136 | try: 137 | app.edit_message_text(message.chat.id, message.id, getformatmsg(filename,"Downloading",size,fsize)) 138 | time.sleep(10) 139 | except: 140 | time.sleep(5) 141 | 142 | if iswin != "0": os.remove(f"tempS-{message.id}.txt") 143 | 144 | 145 | # upload status 146 | def upstatus(statusfile,message,filename): 147 | while True: 148 | if os.path.exists(statusfile): 149 | break 150 | 151 | time.sleep(3) 152 | while os.path.exists(statusfile): 153 | with open(statusfile,"r") as upread: 154 | txt = upread.read().split() 155 | try: 156 | app.edit_message_text(message.chat.id, message.id, getformatmsg(filename,"Uploading",float(txt[0]),float(txt[1]))) 157 | time.sleep(10) 158 | except: 159 | time.sleep(5) 160 | 161 | 162 | # progress writter 163 | def progress(current, total, message): 164 | with open(f'{message.id}upstatus.txt',"w") as fileup: 165 | fileup.write(f'{current} {total}') 166 | 167 | 168 | # format printter 169 | def formatprint(id,link="",edit=False,call=None, emsg=None): 170 | 171 | message,alldata,link = get(id) 172 | if message is None: 173 | app.edit_message_text(call.message.chat.id,call.message.id,"__Expired__") 174 | return 175 | m, s = divmod(alldata['duration'], 60) 176 | h, m = divmod(m, 60) 177 | format = "Document" if getdata(str(message.from_user.id)) == "D" else "Media/Stream" 178 | thumb,thum = ("Exists","Remove Thumbnail") if os.path.exists(f'{message.from_user.id}-thumb.jpg') else ("Not Exists","Set Thumbnail") 179 | text = f'__Filename:__ `{alldata["filename"]}`\n__Link:__ {link}\n\ 180 | __Size:__ **{alldata["size"]//1048000} MB**\n__Duration:__ **{h}h{m}m{s}s**\n\ 181 | __Resolution:__ **{alldata["width"]}x{alldata["height"]}**\n\ 182 | __Format:__ **{format}**\n__Thumbnail:__ **{thumb}**' 183 | keybord = InlineKeyboardMarkup( 184 | [ 185 | [ 186 | InlineKeyboardButton("Rename", callback_data=f'rename {message.id}'), 187 | InlineKeyboardButton("Change Format", callback_data=f'change {message.id}') 188 | ], 189 | [ 190 | InlineKeyboardButton(thum, callback_data=f'thumb {message.id}'), 191 | InlineKeyboardButton("Download", callback_data=f'down {message.id}') 192 | ] 193 | ]) 194 | 195 | if not edit: 196 | app.send_message(message.chat.id, text, reply_to_message_id=message.id, reply_markup=keybord) 197 | else: 198 | if call: 199 | app.edit_message_text(call.message.chat.id,call.message.id, text, reply_markup=keybord) 200 | else: 201 | app.edit_message_text(emsg.chat.id, emsg.reply_to_message.reply_to_message_id, text, reply_markup=keybord) 202 | 203 | # handler 204 | def handlereq(message,link): 205 | alldata = getinfo(link) 206 | 207 | if alldata.get("size", 0) == 0 or alldata.get("source", None) is None: 208 | app.send_message(message.chat.id,f"__Invalid Link : {link}__", reply_to_message_id=message.id) 209 | return 210 | 211 | store(message,alldata,link) 212 | formatprint(message.id,link) 213 | 214 | 215 | # hanldle rename 216 | def handlereanme(msg,id): 217 | setlock(msg.from_user.id,None) 218 | message,alldata,link = get(id) 219 | alldata['filename'] = msg.text 220 | store(message,alldata,link) 221 | formatprint(id,"",True,None,msg) 222 | app.delete_messages(msg.chat.id,[msg.id,msg.reply_to_message.id]) 223 | 224 | 225 | # handle thumb 226 | def handlethumb(msg,id): 227 | setlock(msg.from_user.id,None) 228 | formatprint(id,"",True,None,msg) 229 | app.delete_messages(msg.chat.id,[msg.id,msg.reply_to_message.id]) 230 | 231 | 232 | # check for memeber present 233 | def ismemberpresent(id): 234 | if TARGET == "" or LINK == "": return True 235 | try: 236 | app.get_chat_member(TARGET,id) 237 | return True 238 | except: return False 239 | 240 | 241 | # start command 242 | @app.on_message(filters.command(["start"])) 243 | def echo(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 244 | 245 | if not checkuser(message): 246 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__', reply_to_message_id=message.id,reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("📦 Source Code", url="https://github.com/bipinkrish/Mdisk-Downloader-Bot")]])) 247 | return 248 | 249 | app.send_message(message.chat.id, f'__Hi {message.from_user.mention}, I am Mdisk Video Downloader, you can watch Downloaded Videos without MX Player.\n\nSend me a link to Start... or click /help to check usage__',reply_to_message_id=message.id, 250 | reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("📦 Source Code", url="https://github.com/bipinkrish/Mdisk-Downloader-Bot")]])) 251 | 252 | 253 | # help command 254 | @app.on_message(filters.command(["help"])) 255 | def help(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 256 | 257 | if not checkuser(message): 258 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 259 | return 260 | 261 | helpmessage = """__**/start** - basic usage 262 | **/help** - 263 | **/mdisk mdisklink** - usage 264 | **/thumb** - reply to a image document of size less than 200KB to set it as Thumbnail ( you can also send image as a photo to set it as Thumbnail automatically ) 265 | **/remove** - remove Thumbnail 266 | **/show** - show Thumbnail 267 | **/change** - change upload mode ( default mode is Document )__""" 268 | app.send_message(message.chat.id, helpmessage, reply_to_message_id=message.id) 269 | 270 | 271 | # auth command 272 | @app.on_message(filters.command(["auth","unauth"])) 273 | def auth(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 274 | 275 | if not isowner(message): 276 | app.send_message(message.chat.id, '__You are not a Owner__', reply_to_message_id=message.id) 277 | return 278 | 279 | try: userid = str(message.reply_to_message.forward_from.id) 280 | except: 281 | try: userid = message.text.split("auth ")[1] 282 | except: 283 | app.send_message(message.chat.id, '__Invalid Format, use like this\n/auth 123456 or just reply command to a forwarded message of a user__',reply_to_message_id=message.id) 284 | return 285 | 286 | if "unauth" in message.text and userid in AUTHUSERS: AUTHUSERS.remove(userid) 287 | elif "unauth" not in message.text and userid not in AUTHUSERS: AUTHUSERS.append(userid) 288 | 289 | CONFIGDATA["AUTH"] = " ".join(AUTHUSERS) 290 | with open("config.json",'w') as f: json.dump(CONFIGDATA,f) 291 | 292 | if "unauth" in message.text: app.send_message(message.chat.id, f'__UnAuth Sucessful for **{userid}**\nuse /members to see the updated list__',reply_to_message_id=message.id) 293 | else: app.send_message(message.chat.id, f'__Auth Sucessful for **{userid}**\nuse /members to see the updated list__',reply_to_message_id=message.id) 294 | 295 | 296 | # ban command 297 | @app.on_message(filters.command(["ban","unban"])) 298 | def ban(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 299 | 300 | if not isowner(message): 301 | app.send_message(message.chat.id, '__You are not a Owner__', reply_to_message_id=message.id) 302 | return 303 | 304 | try: userid = str(message.reply_to_message.forward_from.id) 305 | except: 306 | try: userid = message.text.split("ban ")[1] 307 | except: 308 | app.send_message(message.chat.id, '__Invalid Format, use like this\n/ban 123456 or just reply command to a forwarded message of a user__',reply_to_message_id=message.id) 309 | return 310 | 311 | if "unban" in message.text and userid in BANNEDUSERS: BANNEDUSERS.remove(userid) 312 | elif "unban" not in message.text and userid not in BANNEDUSERS: BANNEDUSERS.append(userid) 313 | 314 | CONFIGDATA["BAN"] = " ".join(BANNEDUSERS) 315 | with open("config.json",'w') as f: json.dump(CONFIGDATA,f) 316 | 317 | if "unban" in message.text: app.send_message(message.chat.id, f'__UnBan Sucessful for **{userid}**\nuse /members to see the updated list__',reply_to_message_id=message.id) 318 | else: app.send_message(message.chat.id, f'__Ban Sucessful for **{userid}**\nuse /members to see the updated list__',reply_to_message_id=message.id) 319 | 320 | 321 | # members command 322 | @app.on_message(filters.command(["members"])) 323 | def members(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 324 | 325 | if not isowner(message): 326 | app.send_message(message.chat.id, '__You are not a Owner__', reply_to_message_id=message.id) 327 | return 328 | 329 | owners = app.get_users(OWNERS) 330 | auths = app.get_users(AUTHUSERS) 331 | bans = app.get_users(BANNEDUSERS) 332 | 333 | app.send_message(message.chat.id, 334 | '**--OWNERS--**\n\n__' + (''.join([f"@{x.username} - `{x.id}`\n" for x in owners]) if len(owners)!= 0 else "__No Owners__") + "__\n" + 335 | '**--AUTH USERS--**\n\n__' + (''.join([f"@{x.username} - `{x.id}`\n" for x in auths]) if len(auths)!= 0 else "__No Auth Users__") + "__\n" + 336 | '**--BANNED USERS--**\n\n__' + (''.join([f"@{x.username} - `{x.id}`\n" for x in bans]) if len(bans)!= 0 else "__No Banned Users__") + "__", 337 | reply_to_message_id=message.id) 338 | 339 | 340 | # callback 341 | @app.on_callback_query() 342 | def handle(client: pyrogram.client.Client, call: pyrogram.types.CallbackQuery): 343 | 344 | if call.from_user.id != call.message.reply_to_message.from_user.id: return 345 | 346 | if not ismemberpresent(call.from_user.id): 347 | app.send_message(call.message.chat.id, '__You are not a member of our Chat\nJoin and Retry__',reply_to_message_id=call.message.id, 348 | reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("Join", url=LINK)]])) 349 | return 350 | 351 | data = call.data.split()[0] 352 | 353 | if data == "down": 354 | downld = threading.Thread(target=lambda:startdown(call),daemon=True) 355 | downld.start() 356 | 357 | elif data == "change": 358 | swap(str(call.from_user.id)) 359 | formatprint(call.data.split()[-1],"",True,call) 360 | 361 | elif data == "rename": 362 | id = int(call.data.split()[-1]) 363 | if get(id)[0] is None: app.edit_message_text(call.message.chat.id,call.message.id,"__Expired__") 364 | else: 365 | setlock(call.from_user.id,id) 366 | app.send_message(call.message.chat.id, f"**{call.from_user.mention}** send me new Filename", reply_to_message_id=call.message.id, reply_markup=ForceReply(selective=True, placeholder="Filename...")) 367 | 368 | elif data == "thumb": 369 | if os.path.exists(f'{call.from_user.id}-thumb.jpg'): 370 | os.remove(f'{call.from_user.id}-thumb.jpg') 371 | formatprint(call.data.split()[-1],"",True,call) 372 | else: 373 | id = int(call.data.split()[-1]) 374 | if get(id)[0] is None: app.edit_message_text(call.message.chat.id,call.message.id,"__Expired__") 375 | else: 376 | setlock(call.from_user.id,id) 377 | app.send_message(call.message.chat.id, f"**{call.from_user.mention}** send a Image", reply_to_message_id=call.message.id, reply_markup=ForceReply(selective=True, placeholder="Image...")) 378 | 379 | 380 | # start process 381 | def startdown(call): 382 | 383 | msg = call.message 384 | message,alldata,link = get(call.data.split()[-1]) 385 | 386 | if message is None: 387 | app.edit_message_text(msg.chat.id, msg.id,"__Expired__") 388 | return 389 | 390 | # checking link and download with progress thread 391 | app.edit_message_text(msg.chat.id, msg.id, getformatmsg(alldata['filename'],"Downloading",0,alldata['size'],True)) 392 | sta = threading.Thread(target=lambda:status(str(message.id),msg,alldata['size'],alldata['filename']),daemon=True) 393 | sta.start() 394 | 395 | # checking link and download 396 | file,check,filename = mdow(alldata,message) 397 | 398 | if file == None: 399 | app.edit_message_text(msg.chat.id, msg.id,f"__Invalid Link : {link}__") 400 | return 401 | 402 | # checking if its a link returned 403 | if check == -1: 404 | app.edit_message_text(msg.chat.id, msg.id,f"__Can't Download File but here is the Download Link : {alldata['download']} \n\n {alldata['source']}__") 405 | os.rmdir(str(message.id)) 406 | return 407 | 408 | # merginig 409 | app.edit_message_text(message.chat.id, msg.id, getformatmsg(filename,"Merging",0,alldata['size'],True)) 410 | file,check,filename = merge(message,file,check,filename) 411 | 412 | # checking size 413 | size = get_path_size(file) 414 | if(size > TG_SPLIT_SIZE): 415 | app.edit_message_text(message.chat.id, msg.id, getformatmsg(filename,"Spliting",0,alldata['size'],True)) 416 | flist = split_file(file,size,file,".", TG_SPLIT_SIZE) 417 | os.remove(file) 418 | else: flist = [file] 419 | 420 | app.edit_message_text(message.chat.id, msg.id, getformatmsg(filename,"Uploading",0,alldata['size'],True)) 421 | i = 1 422 | 423 | # checking thumbline 424 | if not os.path.exists(f'{message.from_user.id}-thumb.jpg'): thumbfile = None 425 | else: thumbfile = f'{message.from_user.id}-thumb.jpg' 426 | 427 | # upload thread 428 | upsta = threading.Thread(target=lambda:upstatus(f'{message.id}upstatus.txt',msg,alldata['filename']),daemon=True) 429 | upsta.start() 430 | info = getdata(str(message.from_user.id)) 431 | 432 | # uploading 433 | for ele in flist: 434 | 435 | # checking file existence 436 | if not os.path.exists(ele): 437 | app.send_message(message.chat.id,"__Error in Merging File__",reply_to_message_id=message.id) 438 | return 439 | 440 | # check if it's multi part 441 | if len(flist) == 1: 442 | partt = "" 443 | else: 444 | partt = f"__**part {i}**__\n" 445 | i = i + 1 446 | 447 | # actuall upload 448 | if info == "V": 449 | thumb,duration,width,height = mediainfo.allinfo(ele,thumbfile) 450 | if not isPremmium : app.send_video(message.chat.id, video=ele, caption=f"{partt}**{filename}**", thumb=thumb, duration=duration, height=height, width=width, reply_to_message_id=message.id, progress=progress, progress_args=[message]) 451 | else: 452 | with acc: tmsg = acc.send_video(temp_channel, video=ele, caption=f"{partt}**{filename}**", thumb=thumb, duration=duration, height=height, width=width, progress=progress, progress_args=[message]) 453 | app.copy_message(message.chat.id, temp_channel, tmsg.id, reply_to_message_id=message.id) 454 | if "-thumb.jpg" not in thumb: os.remove(thumb) 455 | else: 456 | if not isPremmium : app.send_document(message.chat.id, document=ele, caption=f"{partt}**{filename}**", thumb=thumbfile, force_document=True, reply_to_message_id=message.id, progress=progress, progress_args=[message]) 457 | else: 458 | with acc: tmsg = acc.send_document(temp_channel, document=ele, thumb=thumbfile, caption=f"{partt}**{filename}**", force_document=True, progress=progress, progress_args=[message]) 459 | app.copy_message(message.chat.id, temp_channel, tmsg.id, reply_to_message_id=message.id) 460 | 461 | # deleting uploaded file 462 | os.remove(ele) 463 | 464 | # checking if restriction is removed 465 | if check == 0: 466 | app.send_message(message.chat.id,"__Can't remove the **restriction**, you have to use **MX player** to play this **video**\n\nThis happens because either the **file** length is **too small** or **video** doesn't have separate **audio layer**__",reply_to_message_id=message.id) 467 | if os.path.exists(f'{message.id}upstatus.txt'): 468 | os.remove(f'{message.id}upstatus.txt') 469 | app.delete_messages(message.chat.id,message_ids=[msg.id]) 470 | 471 | 472 | # mdisk command 473 | @app.on_message(filters.command(["mdisk"])) 474 | def mdiskdown(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 475 | if not checkuser(message): 476 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 477 | return 478 | 479 | if not ismemberpresent(message.from_user.id): 480 | app.send_message(message.chat.id, '__You are not a member of our Chat\nJoin and Retry__',reply_to_message_id=message.id, 481 | reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("Join", url=LINK)]])) 482 | return 483 | 484 | try: link = message.reply_to_message.text 485 | except: 486 | try: link = message.text.split("mdisk ")[1] 487 | except: 488 | app.send_message(message.chat.id, '__Invalid Format, use like this\n/mdisk https://mdisk.me/xxxxx\nor just send a link without command__',reply_to_message_id=message.id) 489 | return 490 | 491 | if "https://mdisk.me/" in link: handlereq(message,link) 492 | else: app.send_message(message.chat.id, '__Send only MDisk Link with command followed by the link__',reply_to_message_id=message.id) 493 | 494 | 495 | # thumb command 496 | @app.on_message(filters.command(["thumb"])) 497 | def thumb(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 498 | 499 | if not checkuser(message): 500 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 501 | return 502 | 503 | try: 504 | if int(message.reply_to_message.document.file_size) > 200000: 505 | app.send_message(message.chat.id, '__Thumbline size allowed is < 200 KB__',reply_to_message_id=message.id) 506 | return 507 | 508 | msg = app.get_messages(message.chat.id, int(message.reply_to_message.id)) 509 | file = app.download_media(msg) 510 | os.rename(file,f'{message.from_user.id}-thumb.jpg') 511 | app.send_message(message.chat.id, '__Thumbnail is Set__',reply_to_message_id=message.id) 512 | 513 | except: 514 | app.send_message(message.chat.id, '__reply /thumb to a image document of size less than 200KB__',reply_to_message_id=message.id) 515 | 516 | 517 | # show thumb command 518 | @app.on_message(filters.command(["show"])) 519 | def showthumb(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 520 | 521 | if not checkuser(message): 522 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 523 | return 524 | 525 | if os.path.exists(f'{message.from_user.id}-thumb.jpg'): 526 | app.send_photo(message.chat.id,photo=f'{message.from_user.id}-thumb.jpg',reply_to_message_id=message.id) 527 | else: 528 | app.send_message(message.chat.id, '__Thumbnail is not Set__',reply_to_message_id=message.id) 529 | 530 | 531 | # remove thumbline command 532 | @app.on_message(filters.command(["remove"])) 533 | def removethumb(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 534 | 535 | if not checkuser(message): 536 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 537 | return 538 | 539 | if os.path.exists(f'{message.from_user.id}-thumb.jpg'): 540 | os.remove(f'{message.from_user.id}-thumb.jpg') 541 | app.send_message(message.chat.id, '__Thumbnail is Removed__',reply_to_message_id=message.id) 542 | else: 543 | app.send_message(message.chat.id, '__Thumbnail is not Set__',reply_to_message_id=message.id) 544 | 545 | 546 | # thumbline 547 | @app.on_message(filters.photo) 548 | def ptumb(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 549 | 550 | if not checkuser(message): 551 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 552 | return 553 | 554 | file = app.download_media(message) 555 | os.rename(file,f'{message.from_user.id}-thumb.jpg') 556 | 557 | id = getlock(message.from_user.id) 558 | if id: handlethumb(message,id) 559 | else: app.send_message(message.chat.id, '__Thumbnail is Set__',reply_to_message_id=message.id) 560 | 561 | 562 | # change mode 563 | @app.on_message(filters.command(["change"])) 564 | def change(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 565 | 566 | if not checkuser(message): 567 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 568 | return 569 | 570 | info = getdata(str(message.from_user.id)) 571 | swap(str(message.from_user.id)) 572 | if info == "V": 573 | app.send_message(message.chat.id, '__Mode changed from **Video** format to **Document** format__',reply_to_message_id=message.id) 574 | else: 575 | app.send_message(message.chat.id, '__Mode changed from **Document** format to **Video** format__',reply_to_message_id=message.id) 576 | 577 | 578 | # mdisk link in text 579 | @app.on_message(filters.text) 580 | def mdisktext(client: pyrogram.client.Client, message: pyrogram.types.messages_and_media.message.Message): 581 | 582 | if isPremmium and message.chat.id == temp_channel: return 583 | 584 | if not checkuser(message): 585 | app.send_message(message.chat.id, '__You are either not **Authorized** or **Banned**__',reply_to_message_id=message.id) 586 | return 587 | 588 | if not ismemberpresent(message.from_user.id): 589 | app.send_message(message.chat.id, '__You are not a member of our Chat\nJoin and Retry__',reply_to_message_id=message.id, 590 | reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("Join", url=LINK)]])) 591 | return 592 | 593 | if message.text[0] == "/": 594 | app.send_message(message.chat.id, '__see /help__',reply_to_message_id=message.id) 595 | return 596 | 597 | id = getlock(message.from_user.id) 598 | if id: 599 | handlereanme(message,id) 600 | return 601 | 602 | if "https://mdisk.me/" in message.text: 603 | links = message.text.split("\n") 604 | handlereq(message,links[0]) 605 | else: 606 | app.send_message(message.chat.id, '__Send only MDisk Link__',reply_to_message_id=message.id) 607 | 608 | 609 | # polling 610 | app.run() 611 | -------------------------------------------------------------------------------- /mdisk.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import os 4 | import subprocess 5 | import threading 6 | import shutil 7 | import zipfile 8 | 9 | # setting 10 | currentFile = __file__ 11 | realPath = os.path.realpath(currentFile) 12 | dirPath = os.path.dirname(realPath) 13 | dirName = os.path.basename(dirPath) 14 | 15 | # is Windows ? 16 | if os.name == 'nt': iswin = "1" 17 | else: iswin = "0" 18 | 19 | # binary setting 20 | if iswin == "0": 21 | ytdlp = dirPath + "/binaries/yt-dlp" 22 | aria2c = dirPath + "/binaries/aria2c" 23 | ffmpeg = dirPath + "/ffmpeg/ffmpeg" 24 | ffprobe = dirPath + "/ffmpeg/ffprobe" 25 | ffmpeg_Lzip = dirPath + "/ffmpeg/ffmpeg_L.zip" 26 | ffprobe_Lzip = dirPath + "/ffmpeg/ffprobe_L.zip" 27 | 28 | if not os.path.exists(ffmpeg): 29 | with zipfile.ZipFile(ffmpeg_Lzip,"r") as zip_ref: 30 | zip_ref.extractall("ffmpeg") 31 | os.remove(ffmpeg_Lzip) 32 | if not os.path.exists(ffprobe): 33 | with zipfile.ZipFile(ffprobe_Lzip,"r") as zip_ref: 34 | zip_ref.extractall("ffmpeg") 35 | os.remove(ffprobe_Lzip) 36 | 37 | os.system(f"chmod 777 {ytdlp} {aria2c} {ffmpeg} {ffprobe} ffmpeg/qt-faststart") 38 | 39 | else: 40 | 41 | ytdlp = dirPath + "/binaries/yt-dlp.exe" 42 | aria2c = dirPath + "/binaries/aria2c.exe" 43 | ffmpeg = dirPath + "/ffmpeg/ffmpeg.exe" 44 | ffprobe = dirPath + "/ffmpeg/ffprobe.exe" 45 | ffmpeg_Wzip = dirPath + "/ffmpeg/ffmpeg.zip" 46 | ffprobe_Wzip = dirPath + "/ffmpeg/ffprobe.zip" 47 | 48 | if not os.path.exists(ffmpeg): 49 | with zipfile.ZipFile(ffmpeg_Wzip,"r") as zip_ref: 50 | zip_ref.extractall("ffmpeg") 51 | os.remove(ffmpeg_Wzip) 52 | if not os.path.exists(ffprobe): 53 | with zipfile.ZipFile(ffprobe_Wzip,"r") as zip_ref: 54 | zip_ref.extractall("ffmpeg") 55 | os.remove(ffprobe_Wzip) 56 | 57 | 58 | 59 | # header for request 60 | header = { 61 | 'Accept': '*/*', 62 | 'Accept-Language': 'en-US,en;q=0.5', 63 | 'Accept-Encoding': 'gzip, deflate, br', 64 | 'Referer': 'https://mdisk.me/', 65 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36' 66 | } 67 | 68 | # actual function 69 | def mdow(allinfo,message): 70 | 71 | #setting 72 | os.mkdir(str(message.id)) 73 | input_video = dirPath + f'/{message.id}/vid.mp4' 74 | input_audio = dirPath + f'/{message.id}' 75 | 76 | result = subprocess.run([ytdlp, '--no-warning', '-k', '--user-agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36', '--allow-unplayable-formats', '-F', allinfo["source"]], capture_output=True, text=True) 77 | with open(f"{message.id}.txt","w") as temp: 78 | temp.write(result.stdout) 79 | if iswin == "0": os.system(f"sed -i 1,6d {message.id}.txt") 80 | 81 | # getting ids 82 | with open(f"{message.id}.txt", 'r') as file1: 83 | Lines = file1.readlines() 84 | 85 | os.remove(f"{message.id}.txt") 86 | audids = [] 87 | audname = [] 88 | i = 1 89 | vid_format = str(0) 90 | 91 | for line in Lines: 92 | line = line.strip() 93 | if "audio" in line: 94 | audids.append(line.split(" ")[0]) 95 | if "[" in line and "]" in line: 96 | audname.append(line.split("[")[1].split("]")[0]) 97 | i = i + 1 98 | else: 99 | audname.append(f"Track - {i}") 100 | i = i + 1 101 | if "video" in line: 102 | vid_format = line.split(" ")[0] 103 | 104 | # threding audio download 105 | audi = threading.Thread(target=lambda:downaud(input_audio,audids,allinfo["source"]),daemon=True) 106 | audi.start() 107 | 108 | # video download 109 | subprocess.run([ytdlp, '--no-warning', '-k', '-f', vid_format, allinfo["source"], '-o', input_video, '--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36', 110 | '--allow-unplayable-formats', '--external-downloader', aria2c, '--external-downloader-args', '-x 16 -s 16 -k 1M']) 111 | 112 | # check if video downloaded 113 | if not os.path.exists(input_video): 114 | print("Video Not Downloaded") 115 | return allinfo["source"],-1,None 116 | print("Video Downloaded") 117 | 118 | # renaming 119 | output = allinfo['filename'] 120 | filename = output[:1000] 121 | output = output.replace(".mkv", "").replace(".mp4", "") 122 | output = "".join( x for x in output if (x.isalnum() or x in "_ ")) 123 | output = output[:200] 124 | 125 | # check if normal video 126 | if len(audids) == 0: 127 | foutput = f"{output}.mkv" 128 | os.rename(input_video,foutput) 129 | shutil.rmtree(str(message.id)) 130 | return foutput,0,filename 131 | 132 | # merge 133 | audi.join() 134 | cmd = f'{ffmpeg} -y -i "{input_video}" ' 135 | 136 | leng = 0 137 | for ele in audids: 138 | out_audio = input_audio + f'/aud-{ele}.m4a' 139 | cmd = cmd + f'-i "{out_audio}" ' 140 | leng = leng + 1 141 | 142 | cmd = cmd + "-map 0 " 143 | i = 1 144 | while(i<=leng): 145 | cmd = cmd + f"-map {i} " 146 | i = i + 1 147 | 148 | i = 1 149 | for ele in audname: 150 | cmd = cmd + f'-metadata:s:a:{i} language="{ele}" ' 151 | 152 | return cmd,output,filename 153 | 154 | 155 | def merge(message,cmd,output,filename): 156 | 157 | tcmd = cmd 158 | cmd = cmd + f'-c copy "{output}.mkv"' 159 | print(cmd) 160 | subprocess.call(cmd, shell=True) 161 | 162 | # cleaning 163 | if os.path.exists(output + '.mkv'): 164 | print('Cleaning Leftovers...') 165 | shutil.rmtree(str(message.id)) 166 | foutput = f"{output}.mkv" 167 | return foutput,1,filename 168 | 169 | else: 170 | print("Trying with Changes") 171 | ffoutput = f" {output}.mkv" 172 | cmd = f'{tcmd} -c copy "{ffoutput}"' 173 | subprocess.call(cmd, shell=True) 174 | 175 | if os.path.exists(output+'.mkv'): 176 | print('Cleaning Leftovers...') 177 | 178 | shutil.rmtree(str(message.id)) 179 | return ffoutput,1,filename 180 | 181 | 182 | # multi-threding audio download 183 | def downaud(input_audio,audids,resp): 184 | threadlist = [] 185 | for i in range(len(audids)): 186 | threadlist.append(threading.Thread(target=lambda:downaudio(input_audio,audids[i],resp),daemon=True)) 187 | threadlist[i].start() 188 | 189 | for ele in threadlist: 190 | ele.join() 191 | 192 | print("Audio Downloaded") 193 | 194 | 195 | # actual audio download 196 | def downaudio(input_audio,ele,resp): 197 | out_audio = input_audio + f'/aud-{ele}.m4a' 198 | subprocess.run([ytdlp, '--no-warning', '-k', '-f', ele, resp, '-o', out_audio, '--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36', 199 | '--allow-unplayable-formats', '--external-downloader', aria2c, '--external-downloader-args', '-x 16 -s 16 -k 1M']) 200 | 201 | 202 | # getting info 203 | def getinfo(link): 204 | URL = f'https://diskuploader.entertainvideo.com/v1/file/cdnurl?param={link.split("/")[-1]}' 205 | try: return requests.get(url=URL, headers=header).json() 206 | except: return {} 207 | -------------------------------------------------------------------------------- /mediainfo.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | from time import time 4 | from subprocess import run as srun, check_output 5 | from json import loads as jsonloads 6 | from mdisk import ffmpeg,ffprobe 7 | 8 | def take_ss(video_file, duration): 9 | des_dir = 'Thumbnails' 10 | if not os.path.exists(des_dir): 11 | os.mkdir(des_dir) 12 | des_dir = os.path.join(des_dir, f"{time()}.jpg") 13 | if duration is None: 14 | duration = get_media_info(video_file)[0] 15 | if duration == 0: 16 | duration = 3 17 | duration = duration // 2 18 | 19 | status = srun([ffmpeg, "-hide_banner", "-loglevel", "error", "-ss", str(duration), 20 | "-i", video_file, "-frames:v", "1", des_dir]) 21 | 22 | if status.returncode != 0 or not os.path.lexists(des_dir): 23 | return None 24 | with Image.open(des_dir) as img: 25 | img.convert("RGB").save(des_dir, "JPEG") 26 | 27 | return des_dir 28 | 29 | 30 | def get_media_info(path): 31 | try: 32 | result = check_output([ffprobe, "-hide_banner", "-loglevel", "error", "-print_format", 33 | "json", "-show_format", "-show_streams", path]).decode('utf-8') 34 | except Exception as e: 35 | print(f'{e}. Mostly file not found!') 36 | return 0, None, None 37 | 38 | fields = jsonloads(result).get('format') 39 | if fields is None: 40 | print(f"get_media_info: {result}") 41 | return 0, None, None 42 | 43 | duration = round(float(fields.get('duration', 0))) 44 | 45 | return duration 46 | 47 | 48 | def allinfo(file,thumb=None): 49 | duration = get_media_info(file) 50 | if thumb is None: 51 | thumb = take_ss(file, duration) 52 | if thumb is not None: 53 | with Image.open(thumb) as img: 54 | width, height = img.size 55 | else: 56 | width = 480 57 | height = 320 58 | 59 | return thumb,duration,width,height 60 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram 2 | tgcrypto 3 | requests 4 | Pillow 5 | -------------------------------------------------------------------------------- /split.py: -------------------------------------------------------------------------------- 1 | from os import remove as osremove, path as ospath, walk 2 | from json import loads as jsnloads 3 | from subprocess import run as srun, check_output 4 | from math import ceil 5 | import os 6 | import json 7 | 8 | # conifg 9 | with open('config.json', 'r') as f: data = json.load(f) 10 | 11 | # premium account 12 | temp_channel = os.environ.get("TEMP_CHAT") or data.get("TEMP_CHAT", "") 13 | try: temp_channel = int(temp_channel) 14 | except: pass 15 | ss = os.environ.get("STRING") or data.get("STRING", "") 16 | if ss != "" and temp_channel != "": isPremmium = True 17 | else: isPremmium = False 18 | 19 | TG_SPLIT_SIZE = 2097151000 20 | checksize = 2097152000 21 | if isPremmium: 22 | TG_SPLIT_SIZE *= 2 23 | checksize *= 2 24 | 25 | 26 | VIDEO_SUFFIXES = ("M4V", "MP4", "MOV", "FLV", "WMV", "3GP", "MPG", "WEBM", "MKV", "AVI") 27 | 28 | 29 | def get_media_info(path): 30 | try: 31 | result = check_output(["./ffmpeg/ffprobe", "-hide_banner", "-loglevel", "error", "-print_format", 32 | "json", "-show_format", path]).decode('utf-8') 33 | fields = jsnloads(result)['format'] 34 | except Exception as e: 35 | print(f"get_media_info: {e}") 36 | return 0, None, None 37 | try: 38 | duration = round(float(fields['duration'])) 39 | except: 40 | duration = 0 41 | try: 42 | artist = str(fields['tags']['artist']) 43 | except: 44 | artist = None 45 | try: 46 | title = str(fields['tags']['title']) 47 | except: 48 | title = None 49 | return duration, artist, title 50 | 51 | def get_path_size(path: str): 52 | if ospath.isfile(path): 53 | return ospath.getsize(path) 54 | total_size = 0 55 | for root, dirs, files in walk(path): 56 | for f in files: 57 | abs_path = ospath.join(root, f) 58 | total_size += ospath.getsize(abs_path) 59 | return total_size 60 | 61 | def split_file(path, size, file_, dirpath, split_size, start_time=0, i=1): 62 | parts = ceil(size/TG_SPLIT_SIZE) 63 | flist = [] 64 | if file_.upper().endswith(VIDEO_SUFFIXES): 65 | base_name, extension = ospath.splitext(file_) 66 | split_size = split_size - 2500000 67 | while i <= parts : 68 | parted_name = "{}.part{}{}".format(str(base_name), str(i).zfill(3), str(extension)) 69 | out_path = ospath.join(dirpath, parted_name) 70 | srun(["./ffmpeg/ffmpeg", "-hide_banner", "-loglevel", "error", "-i", 71 | path, "-ss", str(start_time), "-fs", str(split_size), 72 | "-async", "1", "-strict", "-2", "-c", "copy", out_path]) 73 | out_size = get_path_size(out_path) 74 | if out_size > checksize: 75 | dif = out_size - checksize 76 | split_size = split_size - dif + 2500000 77 | osremove(out_path) 78 | return split_file(path, size, file_, dirpath, split_size, start_time, i) 79 | lpd = get_media_info(out_path)[0] 80 | if lpd <= 4 or out_size < 1000000: 81 | osremove(out_path) 82 | break 83 | start_time += lpd - 3 84 | i = i + 1 85 | flist.append(out_path) 86 | else: 87 | out_path = ospath.join(dirpath, file_ + ".") 88 | srun(["split", "--numeric-suffixes=1", "--suffix-length=3", f"--bytes={split_size}", path, out_path]) 89 | flist.append(out_path) 90 | print(flist) 91 | return flist 92 | --------------------------------------------------------------------------------