diff --git a/bot/core/config_manager.py b/bot/core/config_manager.py index f12ef0889..074d1906c 100644 --- a/bot/core/config_manager.py +++ b/bot/core/config_manager.py @@ -56,7 +56,7 @@ class Config: USE_SERVICE_ACCOUNTS = False WEB_PINCODE = False YT_DLP_OPTIONS = "" - + # INKYPINKY METADATA_KEY = "" SET_COMMANDS = True @@ -65,7 +65,7 @@ class Config: PAID_CHANNEL_LINK = "" DELETE_LINKS = False FSUB_IDS = "" - + @classmethod def get(cls, key): if hasattr(cls, key): diff --git a/bot/helper/aeon_utils/metadata_editor.py b/bot/helper/aeon_utils/metadata_editor.py index 3f3b98cb8..982d2f943 100644 --- a/bot/helper/aeon_utils/metadata_editor.py +++ b/bot/helper/aeon_utils/metadata_editor.py @@ -27,7 +27,9 @@ async def get_streams(file): try: return json.loads(stdout)["streams"] except KeyError: - LOGGER.error(f"No streams found in the ffprobe output: {stdout.decode().strip()}") + LOGGER.error( + f"No streams found in the ffprobe output: {stdout.decode().strip()}" + ) return None @@ -182,4 +184,4 @@ async def add_attachment(file, attachment_path): os.replace(temp_file, file) LOGGER.info(f"Photo attachment added successfully to file: {file}") - return \ No newline at end of file + return diff --git a/bot/helper/common.py b/bot/helper/common.py index ec441853e..08b90e22b 100644 --- a/bot/helper/common.py +++ b/bot/helper/common.py @@ -23,6 +23,7 @@ ) from bot.core.aeon_client import TgClient from bot.core.config_manager import Config +from bot.helper.aeon_utils.metadata_editor import get_streams from .ext_utils.bot_utils import get_size_bytes, new_task, sync_to_async from .ext_utils.bulk_links import extract_bulk_links @@ -47,14 +48,12 @@ create_sample_video, create_thumb, get_document_type, + is_mkv, run_ffmpeg_cmd, run_metadata_cmd, split_file, take_ss, - is_mkv, ) -from bot.helper.aeon_utils.metadata_editor import change_metadata, get_streams - from .mirror_leech_utils.gdrive_utils.list import GoogleDriveList from .mirror_leech_utils.rclone_utils.list import RcloneList from .mirror_leech_utils.status_utils.ffmpeg_status import FFmpegStatus @@ -211,7 +210,8 @@ async def before_start(self): if self.ffmpeg_cmds and not isinstance(self.ffmpeg_cmds, list): if self.user_dict.get("ffmpeg_cmds", None): self.ffmpeg_cmds = self.user_dict["ffmpeg_cmds"].get( - self.ffmpeg_cmds, None + self.ffmpeg_cmds, + None, ) elif "ffmpeg_cmds" not in self.user_dict and Config.FFMPEG_CMDS: self.ffmpeg_cmds = Config.FFMPEG_CMDS.get(self.ffmpeg_cmds, None) @@ -801,7 +801,9 @@ async def proceed_compress(self, dl_path, gid, o_files, ft_delete): return "" async with self.subprocess_lock: self.subproc = await create_subprocess_exec( - *cmd, stdout=PIPE, stderr=PIPE + *cmd, + stdout=PIPE, + stderr=PIPE, ) code = await self.subproc.wait() if self.is_cancelled: @@ -1373,7 +1375,7 @@ async def process_file(file_path, key): [ f"-metadata:s:v:{stream_index}", f"language={languages[stream_index]}", - ] + ], ) elif stream_type == "audio": cmd.extend( @@ -1382,21 +1384,21 @@ async def process_file(file_path, key): f"0:{stream_index}", f"-metadata:s:a:{audio_index}", f"title={key}", - ] + ], ) if stream_index in languages: cmd.extend( [ f"-metadata:s:a:{audio_index}", f"language={languages[stream_index]}", - ] + ], ) audio_index += 1 elif stream_type == "subtitle": codec_name = stream.get("codec_name", "unknown") if codec_name in ["webvtt", "unknown"]: LOGGER.warning( - f"Skipping unsupported subtitle metadata modification: {codec_name} for stream {stream_index}" + f"Skipping unsupported subtitle metadata modification: {codec_name} for stream {stream_index}", ) else: cmd.extend( @@ -1405,14 +1407,14 @@ async def process_file(file_path, key): f"0:{stream_index}", f"-metadata:s:s:{subtitle_index}", f"title={key}", - ] + ], ) if stream_index in languages: cmd.extend( [ f"-metadata:s:s:{subtitle_index}", f"language={languages[stream_index]}", - ] + ], ) subtitle_index += 1 else: @@ -1423,7 +1425,9 @@ async def process_file(file_path, key): async def process_directory(directory, key): """Processes all MKV files in a directory.""" - for dirpath, _, files in await sync_to_async(walk, directory, topdown=False): + for dirpath, _, files in await sync_to_async( + walk, directory, topdown=False + ): for file_ in files: file_path = ospath.join(dirpath, file_) if is_mkv(file_path): @@ -1437,7 +1441,7 @@ async def process_directory(directory, key): return "" await run_metadata_cmd(self, cmd) os.replace(temp_file, file_path) - + return None if self.is_file: if is_mkv(up_dir): @@ -1453,4 +1457,4 @@ async def process_directory(directory, key): if checked: cpu_eater_lock.release() - return up_dir \ No newline at end of file + return up_dir diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py index dc3b4787b..0e70edf8c 100644 --- a/bot/helper/ext_utils/media_utils.py +++ b/bot/helper/ext_utils/media_utils.py @@ -70,7 +70,9 @@ async def convert_video(listener, video_file, ext, retry=False): return False async with listener.subprocess_lock: listener.subproc = await create_subprocess_exec( - *cmd, stdout=PIPE, stderr=PIPE + *cmd, + stdout=PIPE, + stderr=PIPE, ) code = await listener.subproc.wait() async with listener.subprocess_lock: @@ -115,7 +117,9 @@ async def convert_audio(listener, audio_file, ext): return False async with listener.subprocess_lock: listener.subproc = await create_subprocess_exec( - *cmd, stdout=PIPE, stderr=PIPE + *cmd, + stdout=PIPE, + stderr=PIPE, ) code = await listener.subproc.wait() async with listener.subprocess_lock: @@ -649,7 +653,9 @@ async def create_sample_video(listener, video_file, sample_duration, part_durati return False async with listener.subprocess_lock: listener.subproc = await create_subprocess_exec( - *cmd, stdout=PIPE, stderr=PIPE + *cmd, + stdout=PIPE, + stderr=PIPE, ) code = await listener.subproc.wait() async with listener.subprocess_lock: @@ -784,7 +790,9 @@ async def run_ffmpeg_cmd(listener, cmd, path): return False async with listener.subprocess_lock: listener.subproc = await create_subprocess_exec( - *cmd, stdout=PIPE, stderr=PIPE + *cmd, + stdout=PIPE, + stderr=PIPE, ) code = await listener.subproc.wait() async with listener.subprocess_lock: @@ -808,16 +816,16 @@ async def run_ffmpeg_cmd(listener, cmd, path): async def run_metadata_cmd(listener, cmd): - #base_name, ext = ospath.splitext(path) - #dir, base_name = base_name.rsplit("/", 1) - #output_file = cmd[-1] - #if output_file != "mltb" and output_file.startswith("mltb"): + # base_name, ext = ospath.splitext(path) + # dir, base_name = base_name.rsplit("/", 1) + # output_file = cmd[-1] + # if output_file != "mltb" and output_file.startswith("mltb"): # oext = ospath.splitext(output_file)[-1] # if ext == oext: # base_name = f"ffmpeg.{base_name}" # else: # ext = oext - #else: + # else: # base_name = f"ffmpeg.{base_name}" # output = f"{dir}/{base_name}{ext}" # cmd[-1] = output @@ -825,7 +833,9 @@ async def run_metadata_cmd(listener, cmd): return False async with listener.subprocess_lock: listener.subproc = await create_subprocess_exec( - *cmd, stdout=PIPE, stderr=PIPE + *cmd, + stdout=PIPE, + stderr=PIPE, ) code = await listener.subproc.wait() async with listener.subprocess_lock: @@ -847,5 +857,6 @@ async def run_metadata_cmd(listener, cmd): # await remove(output) return False + def is_mkv(file): return file.lower().endswith(".mkv")