mirror of
https://github.com/anasty17/mirror-leech-telegram-bot.git
synced 2025-01-07 03:26:46 +08:00
Fix ffmpeg cmd run for mirror
- use raw config parser for rclone - fix use user token/config by default Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
parent
1638241153
commit
f0205ef78e
@ -129,10 +129,6 @@ class TaskConfig:
|
||||
self.is_super_chat = self.message.chat.type.name in ["SUPERGROUP", "CHANNEL"]
|
||||
|
||||
def get_token_path(self, dest):
|
||||
if not dest.startswith(("mtp:", "tp:", "sa:")) and self.user_dict.get(
|
||||
"user_tokens", False
|
||||
):
|
||||
return f"tokens/{self.user_id}.pickle"
|
||||
if dest.startswith("mtp:"):
|
||||
return f"tokens/{self.user_id}.pickle"
|
||||
elif (
|
||||
@ -145,8 +141,6 @@ class TaskConfig:
|
||||
return "token.pickle"
|
||||
|
||||
def get_config_path(self, dest):
|
||||
if not dest.startswith("mrcc:") and self.user_dict.get("user_tokens", False):
|
||||
return f"rclone/{self.user_id}.conf"
|
||||
return (
|
||||
f"rclone/{self.user_id}.conf" if dest.startswith("mrcc:") else "rclone.conf"
|
||||
)
|
||||
@ -189,12 +183,19 @@ class TaskConfig:
|
||||
else ["aria2", "!qB"]
|
||||
)
|
||||
if self.link not in ["rcl", "gdl"]:
|
||||
if (
|
||||
not self.is_jd
|
||||
and is_rclone_path(self.link)
|
||||
or is_gdrive_link(self.link)
|
||||
):
|
||||
await self.is_token_exists(self.link, "dl")
|
||||
if not self.is_jd:
|
||||
if is_rclone_path(self.link):
|
||||
if not self.link.startswith("mrcc:") and self.user_dict.get(
|
||||
"user_tokens", False
|
||||
):
|
||||
self.link = f"mrcc:{self.link}"
|
||||
await self.is_token_exists(self.link, "dl")
|
||||
elif is_gdrive_link(self.link):
|
||||
if not self.link.startswith(
|
||||
("mtp:", "tp:", "sa:")
|
||||
) and self.user_dict.get("user_tokens", False):
|
||||
self.link = f"mtp:{self.link}"
|
||||
await self.is_token_exists(self.link, "dl")
|
||||
elif self.link == "rcl":
|
||||
if not self.is_ytdlp and not self.is_jd:
|
||||
self.link = await RcloneList(self).get_rclone_path("rcd")
|
||||
@ -219,6 +220,18 @@ class TaskConfig:
|
||||
):
|
||||
self.up_dest = self.user_dict["upload_paths"][self.up_dest]
|
||||
|
||||
self.ffmpeg_cmds = (
|
||||
self.ffmpeg_cmds
|
||||
or self.user_dict.get("ffmpeg_cmds", None)
|
||||
or (
|
||||
config_dict["FFMPEG_CMDS"]
|
||||
if "ffmpeg_cmds" not in self.user_dict
|
||||
else None
|
||||
)
|
||||
)
|
||||
if self.ffmpeg_cmds:
|
||||
self.seed = False
|
||||
|
||||
if not self.is_leech:
|
||||
self.stop_duplicate = (
|
||||
self.user_dict.get("stop_duplicate")
|
||||
@ -239,8 +252,19 @@ class TaskConfig:
|
||||
)
|
||||
if not self.up_dest:
|
||||
raise ValueError("No Upload Destination!")
|
||||
if not is_gdrive_id(self.up_dest) and not is_rclone_path(self.up_dest):
|
||||
if is_gdrive_id(self.up_dest):
|
||||
if not self.up_dest.startswith(
|
||||
("mtp:", "tp:", "sa:")
|
||||
) and self.user_dict.get("user_tokens", False):
|
||||
self.up_dest = f"mtp:{self.up_dest}"
|
||||
elif is_rclone_path(self.up_dest):
|
||||
if not self.up_dest.startswith("mrcc:") and self.user_dict.get(
|
||||
"user_tokens", False
|
||||
):
|
||||
self.up_dest = f"mrcc:{self.up_dest}"
|
||||
else:
|
||||
raise ValueError("Wrong Upload Destination!")
|
||||
|
||||
if self.up_dest not in ["rcl", "gdl"]:
|
||||
await self.is_token_exists(self.up_dest, "up")
|
||||
|
||||
@ -395,18 +419,6 @@ class TaskConfig:
|
||||
await create_thumb(msg) if msg.photo or msg.document else ""
|
||||
)
|
||||
|
||||
self.ffmpeg_cmds = (
|
||||
self.ffmpeg_cmds
|
||||
or self.user_dict.get("ffmpeg_cmds", None)
|
||||
or (
|
||||
config_dict["FFMPEG_CMDS"]
|
||||
if "ffmpeg_cmds" not in self.user_dict
|
||||
else None
|
||||
)
|
||||
)
|
||||
if self.ffmpeg_cmds:
|
||||
self.seed = False
|
||||
|
||||
async def get_tag(self, text: list):
|
||||
if len(text) > 1 and text[1].startswith("Tag: "):
|
||||
user_info = text[1].split("Tag: ")
|
||||
|
@ -1,7 +1,7 @@
|
||||
from aiofiles import open as aiopen
|
||||
from aiofiles.os import path as aiopath
|
||||
from asyncio import wait_for, Event, gather
|
||||
from configparser import ConfigParser
|
||||
from configparser import RawConfigParser
|
||||
from functools import partial
|
||||
from json import loads
|
||||
from pyrogram.filters import regex, user
|
||||
@ -292,7 +292,7 @@ class RcloneList:
|
||||
await self.get_path_buttons()
|
||||
|
||||
async def list_remotes(self):
|
||||
config = ConfigParser()
|
||||
config = RawConfigParser()
|
||||
async with aiopen(self.config_path, "r") as f:
|
||||
contents = await f.read()
|
||||
config.read_string(contents)
|
||||
|
@ -1,7 +1,7 @@
|
||||
from aiofiles import open as aiopen
|
||||
from aiofiles.os import path as aiopath
|
||||
from asyncio import create_subprocess_exec
|
||||
from configparser import ConfigParser
|
||||
from configparser import RawConfigParser
|
||||
|
||||
from bot import config_dict
|
||||
|
||||
@ -17,7 +17,7 @@ async def rclone_serve_booter():
|
||||
except:
|
||||
pass
|
||||
return
|
||||
config = ConfigParser()
|
||||
config = RawConfigParser()
|
||||
async with aiopen("rclone.conf", "r") as f:
|
||||
contents = await f.read()
|
||||
config.read_string(contents)
|
||||
|
@ -2,7 +2,7 @@ from aiofiles import open as aiopen
|
||||
from aiofiles.os import path as aiopath, makedirs, listdir
|
||||
from asyncio import create_subprocess_exec, gather
|
||||
from asyncio.subprocess import PIPE
|
||||
from configparser import ConfigParser
|
||||
from configparser import RawConfigParser
|
||||
from json import loads
|
||||
from logging import getLogger
|
||||
from random import randrange
|
||||
@ -484,7 +484,7 @@ class RcloneTransferHelper:
|
||||
|
||||
@staticmethod
|
||||
async def _get_remote_options(config_path, remote):
|
||||
config = ConfigParser()
|
||||
config = RawConfigParser()
|
||||
async with aiopen(config_path, "r") as f:
|
||||
contents = await f.read()
|
||||
config.read_string(contents)
|
||||
|
@ -655,9 +655,11 @@ Check all yt-dlp api options from this <a href='https://github.com/yt-dlp/yt-dlp
|
||||
elif data[2] == "ffc":
|
||||
await query.answer()
|
||||
buttons = ButtonMaker()
|
||||
if user_dict.get("ffmpeg_cmds", False) or config_dict["YT_DLP_OPTIONS"]:
|
||||
if user_dict.get("ffmpeg_cmds", False) or config_dict["FFMPEG_CMDS"]:
|
||||
buttons.data_button(
|
||||
"Remove YT-DLP Options", f"userset {user_id} ffmpeg_cmds", "header"
|
||||
"Remove FFMPEG Commands",
|
||||
f"userset {user_id} ffmpeg_cmds",
|
||||
"header",
|
||||
)
|
||||
buttons.data_button("Back", f"userset {user_id} back")
|
||||
buttons.data_button("Close", f"userset {user_id} close")
|
||||
|
Loading…
Reference in New Issue
Block a user