# from asobistage using standard CENC from subprocess import Popen as start_process from subprocess import run as run_process from subprocess import DEVNULL from os import remove as del_file from os.path import getsize as get_file_size from os.path import exists as file_exist from datetime import datetime from time import sleep import re # Formatting from os import system system("") sleep(0.5) ''' grey = \33[90m black = \33[30m red = \33[31m green = \33[92m blue = \33[34m cyan = \33[96m magenta = \33[95m light yellow = \33[93m light red = \33[91m purple blue = \33[94m bright blue = \33[36m orange = \33[33m dark green = \33[32m purple = \33[35m bold = \33[1m underline = \33[4m highlighted = \33[7m reset = \33[0m ''' # Init the log file with open('DL.log','w') as fh: fh.write("") # Define the logging function def log(cat,msg): msg = msg.format(**locals().get('kwargs', {})) if cat == "d": cat = "DEBUG" if cat == "i": cat = "INFO" if cat == "s": cat = "SUCCESS" if cat == "w": cat = "WARNING" if cat == "e": cat = "ERROR" with open('DL.log','a') as fh: fh.write(f"{datetime.now()} [{cat}] {msg}\n") version = "v2.1.5" ################################################################ #### Required: Manual Fill Data #### simul_dl = 32 cURL_master = 'curl "https://dce1j8lyafk9e.cloudfront.net/lalabit/mc/694553d7-d7fb-4ee4-a70f-4d69ef617a47/index_6m_00018.ts" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0" -H "Accept: */*" -H "Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate, br, zstd" -H "Referer: https://asobistage.asobistore.jp/" -H "Origin: https://asobistage.asobistore.jp" -H "DNT: 1" -H "Sec-GPC: 1" -H "Connection: keep-alive" -H "Sec-Fetch-Dest: empty" -H "Sec-Fetch-Mode: cors" -H "Sec-Fetch-Site: cross-site" -H "TE: trailers"' ################################################################ print("================================================================") print(f"\33[36mAsobistage Downloader {version} by Wizongod\33[0m\n", flush=True) log("i",f"Asobistage Downloader {version} by Wizongod launched") cURL_head = re.split("\/[a-z0-9_]+\.ts", cURL_master,1)[0] + '/' cURL_tail = re.split("\/[a-z0-9_]+\.ts", cURL_master,1)[1] # Download the m3u8 list first print("Downloading m3u8 list...", end="") run_process(cURL_head + "index_6m.m3u8" + cURL_tail + ' --ssl-no-revoke>' + "playlist.m3u8", stdout=DEVNULL, stderr=DEVNULL, shell=True) print("\33[92mdone!\33[0m") log("s","playlist.m3u8 downloaded") # Download the key print("Downloading decryption key...", end="") run_process(cURL_head + "aes128.key" + cURL_tail + ' --ssl-no-revoke>' + "aes128.key", stdout=DEVNULL, stderr=DEVNULL, shell=True) if get_file_size("aes128.key") != 16: with open('DL.log','a') as fh: fh.write(f"{datetime.now()} [ERROR] Failed to get decryption key!\n") raise Exception("[ERROR] Unable to get decryption key!") print("\33[92mdone!\33[0m") log("s","Decryption key downloaded") # Count total number of files total_files = 0 with open ('playlist.m3u8','r') as fh: lines = fh.readlines() for line in lines: if line[0] != '#': total_files = total_files + 1 # Start the main downloads dl_threads = [start_process(" ", shell=True) for _ in range(simul_dl)] print(f"\nStarting \33[93m{simul_dl}\33[0m simultaneous download threads...") count = 0 with open('playlist.m3u8','r') as fh: lines = fh.readlines() for line in lines: if line[0] != '#': line = line.rstrip() command = cURL_head + line + cURL_tail + ' --ssl-no-revoke>' + line while all(thread.poll() is None for thread in dl_threads): sleep(0.2) for tid,thread in enumerate(dl_threads): if thread.poll() is not None: dl_threads[tid].wait() dl_threads[tid] = start_process(command, stdout=DEVNULL, stderr=DEVNULL, shell=True) count = count + 1 print(f"\rDownloading \33[93m{count}\33[0m/{total_files} ({round(count/total_files * 100)}%) files...", end="") break for thread in dl_threads: thread.wait() print("\33[92mdone!\33[0m") print("\n\33[92mAll downloads have finished!\33[0m") log("s","Media fully downloaded") # Call FFMPEG to do the rest print("\nBeginning ffmpeg decryption and compilation...\33[93m", flush=True) if file_exist("________________.mkv"): del_file("________________.mkv") run_process('ffmpeg -loglevel warning -stats -allowed_extensions ALL -i "playlist.m3u8" -c copy ________________.mkv', shell=True) if file_exist("________________.mkv"): log("s","Media compiled and decrypted") else: print("\33[31m[ERROR]\33[0m ffmpeg failed to execute! Stopping...") log("e","ffmpeg compilation failed") quit() print("\n\33[92mCompilation complete!\33[0m\n") print("================================================================\n\n") log("i","Script finished")