mirror of
https://github.com/anasty17/mirror-leech-telegram-bot.git
synced 2025-01-09 04:47:34 +08:00
Minor fixes
Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
parent
b56f8e5cdd
commit
f37b0743c4
@ -223,7 +223,7 @@ Fill up rest of the fields. Meaning of each field is discussed below. **NOTE**:
|
||||
- `EXTENSION_FILTER`: File extensions that won't upload/clone. Separate them by space. `Str`
|
||||
- `INCOMPLETE_TASK_NOTIFIER`: Get incomplete task messages after restart. Require database and superGroup. Default is `False`. `Bool`
|
||||
- `UPTOBOX_TOKEN`: Uptobox token to mirror uptobox links. Get it from [Uptobox Premium Account](https://uptobox.com/my_account). `str`
|
||||
- `YT_DLP_OPTIONS`: Default yt-dlp options. Check all possible options [HERE](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L184) or use this [script](https://t.me/mltb_official/177) to convert cli arguments to api options. Format: key:value|key:value|key:value. Add `^` before integer or float, some numbers must be numeric and some string. `str`
|
||||
- `YT_DLP_OPTIONS`: Default yt-dlp options. Check all possible options [HERE](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L184) or use this [script](https://t.me/mltb_official_channel/177) to convert cli arguments to api options. Format: key:value|key:value|key:value. Add `^` before integer or float, some numbers must be numeric and some string. `str`
|
||||
- Example: "format:bv*+mergeall[vcodec=none]|nocheckcertificate:True"
|
||||
- `USE_SERVICE_ACCOUNTS`: Whether to use Service Accounts or not, with google-api-python-client. For this to work see [Using Service Accounts](https://github.com/anasty17/mirror-leech-telegram-bot#generate-service-accounts-what-is-service-account) section below. Default is `False`. `Bool`
|
||||
|
||||
|
@ -24,7 +24,8 @@ async def add_rclone_download(rc_path, config_path, path, name, listener):
|
||||
res1, res2 = await gather(cmd_exec(cmd1), cmd_exec(cmd2))
|
||||
if res1[2] != res2[2] != 0:
|
||||
if res1[2] != -9:
|
||||
msg = f'Error: While getting rclone stat/size. Path: {remote}:{rc_path}. Stderr: {res1[1][:4000]}'
|
||||
err = res1[1] or res2[1]
|
||||
msg = f'Error: While getting rclone stat/size. Path: {remote}:{rc_path}. Stderr: {err[:4000]}'
|
||||
await sendMessage(listener.message, msg)
|
||||
return
|
||||
rstat = loads(res1[0])
|
||||
|
@ -65,7 +65,11 @@ class YoutubeDLHelper:
|
||||
'allow_playlist_files': True,
|
||||
'overwrites': True,
|
||||
'writethumbnail': True,
|
||||
'trim_file_name': 230}
|
||||
'trim_file_name': 230,
|
||||
'retry_sleep_functions': {'http': lambda x: 2,
|
||||
'fragment': lambda x: 2,
|
||||
'file_access': lambda x: 2,
|
||||
'extractor': lambda x: 2}}
|
||||
|
||||
@property
|
||||
def download_speed(self):
|
||||
@ -222,11 +226,11 @@ class YoutubeDLHelper:
|
||||
if self.is_playlist:
|
||||
self.opts['outtmpl'] = {'default': f"{path}/{self.name}/%(title,fulltitle,alt_title)s%(season_number& |)s%(season_number&S|)s%(season_number|)02d%(episode_number&E|)s%(episode_number|)02d%(height& |)s%(height|)s%(height&p|)s%(fps|)s%(fps&fps|)s%(tbr& |)s%(tbr|)d.%(ext)s",
|
||||
'thumbnail': f"{path}/yt-dlp-thumb/%(title,fulltitle,alt_title)s%(season_number& |)s%(season_number&S|)s%(season_number|)02d%(episode_number&E|)s%(episode_number|)02d%(height& |)s%(height|)s%(height&p|)s%(fps|)s%(fps&fps|)s%(tbr& |)s%(tbr|)d.%(ext)s"}
|
||||
elif not options:
|
||||
self.opts['outtmpl'] = {'default': f"{path}/{self.name}",
|
||||
elif any(key in options for key in ['writedescription', 'writeinfojson', 'writeannotations', 'writedesktoplink', 'writewebloclink', 'writeurllink', 'writesubtitles', 'writeautomaticsub']):
|
||||
self.opts['outtmpl'] = {'default': f"{path}/{base_name}/{self.name}",
|
||||
'thumbnail': f"{path}/yt-dlp-thumb/{base_name}.%(ext)s"}
|
||||
else:
|
||||
self.opts['outtmpl'] = {'default': f"{path}/{base_name}/{self.name}",
|
||||
self.opts['outtmpl'] = {'default': f"{path}/{self.name}",
|
||||
'thumbnail': f"{path}/yt-dlp-thumb/{base_name}.%(ext)s"}
|
||||
self.name = base_name
|
||||
|
||||
|
@ -109,10 +109,12 @@ class RcloneTransferHelper:
|
||||
await self.__listener.onDownloadComplete()
|
||||
elif return_code != -9:
|
||||
error = (await self.__proc.stderr.read()).decode().strip()
|
||||
if not error and remote_type == 'drive' and config_dict['USE_SERVICE_ACCOUNTS']:
|
||||
error = "Mostly your service accounts don't have acces to this drive!"
|
||||
LOGGER.error(error)
|
||||
|
||||
if remote_type == 'drive' and 'RATE_LIMIT_EXCEEDED' in error and config_dict['USE_SERVICE_ACCOUNTS']:
|
||||
if self.__sa_number != 0 and self.__sa_count < self.__sa_number:
|
||||
if self.__sa_number != 0 and remote_type == 'drive' and 'RATE_LIMIT_EXCEEDED' in error and config_dict['USE_SERVICE_ACCOUNTS']:
|
||||
if self.__sa_count < self.__sa_number:
|
||||
remote = self.__switchServiceAccount()
|
||||
cmd[6] = f"{remote}:{cmd[6].split(':', 1)[1]}"
|
||||
if self.__is_cancelled:
|
||||
@ -126,7 +128,11 @@ class RcloneTransferHelper:
|
||||
|
||||
async def download(self, remote, rc_path, config_path, path):
|
||||
self.__is_download = True
|
||||
remote_opts = await self.__get_remote_options(config_path, remote)
|
||||
try:
|
||||
remote_opts = await self.__get_remote_options(config_path, remote)
|
||||
except Exception as err:
|
||||
await self.__listener.onDownloadError(str(err))
|
||||
return
|
||||
remote_type = remote_opts['type']
|
||||
|
||||
if remote_type == 'drive' and config_dict['USE_SERVICE_ACCOUNTS'] and config_path == 'rclone.conf' \
|
||||
@ -188,9 +194,11 @@ class RcloneTransferHelper:
|
||||
return False
|
||||
elif return_code != 0:
|
||||
error = (await self.__proc.stderr.read()).decode().strip()
|
||||
if not error and remote_type == 'drive' and config_dict['USE_SERVICE_ACCOUNTS']:
|
||||
error = "Mostly your service accounts don't have acces to this drive!"
|
||||
LOGGER.error(error)
|
||||
if remote_type == 'drive' and 'RATE_LIMIT_EXCEEDED' in error and config_dict['USE_SERVICE_ACCOUNTS']:
|
||||
if self.__sa_number != 0 and self.__sa_count < self.__sa_number:
|
||||
if self.__sa_number != 0 and remote_type == 'drive' and 'RATE_LIMIT_EXCEEDED' in error and config_dict['USE_SERVICE_ACCOUNTS']:
|
||||
if self.__sa_count < self.__sa_number:
|
||||
remote = self.__switchServiceAccount()
|
||||
cmd[7] = f"{remote}:{cmd[7].split(':', 1)[1]}"
|
||||
return False if self.__is_cancelled else await self.__start_upload(cmd, remote_type)
|
||||
@ -218,11 +226,18 @@ class RcloneTransferHelper:
|
||||
folders, files = await count_files_and_folders(path)
|
||||
rc_path += f"/{self.name}" if rc_path else self.name
|
||||
else:
|
||||
if path.lower().endswith(tuple(GLOBAL_EXTENSION_FILTER)):
|
||||
await self.__listener.onUploadError('This file extension is excluded by extension filter!')
|
||||
return
|
||||
mime_type = await sync_to_async(get_mime_type, path)
|
||||
folders = 0
|
||||
files = 1
|
||||
|
||||
remote_opts = await self.__get_remote_options(oconfig_path, oremote)
|
||||
try:
|
||||
remote_opts = await self.__get_remote_options(oconfig_path, oremote)
|
||||
except Exception as err:
|
||||
await self.__listener.onUploadError(str(err))
|
||||
return
|
||||
remote_type = remote_opts['type']
|
||||
|
||||
fremote = oremote
|
||||
@ -277,8 +292,12 @@ class RcloneTransferHelper:
|
||||
async def clone(self, config_path, src_remote, src_path, destination, rcflags, mime_type):
|
||||
dst_remote, dst_path = destination.split(':', 1)
|
||||
|
||||
src_remote_opts, dst_remote_opt = await gather(self.__get_remote_options(config_path, src_remote),
|
||||
self.__get_remote_options(config_path, dst_remote))
|
||||
try:
|
||||
src_remote_opts, dst_remote_opt = await gather(self.__get_remote_options(config_path, src_remote),
|
||||
self.__get_remote_options(config_path, dst_remote))
|
||||
except Exception as err:
|
||||
await self.__listener.onUploadError(str(err))
|
||||
return None, None
|
||||
|
||||
src_remote_type, dst_remote_type = src_remote_opts['type'], dst_remote_opt['type']
|
||||
|
||||
|
@ -187,6 +187,8 @@ class GoogleDriveHelper:
|
||||
self.__updater = setInterval(self.__update_interval, self.__progress)
|
||||
try:
|
||||
if ospath.isfile(item_path):
|
||||
if item_path.lower().endswith(tuple(GLOBAL_EXTENSION_FILTER)):
|
||||
raise Exception('This file extension is excluded by extension filter!')
|
||||
mime_type = get_mime_type(item_path)
|
||||
link = self.__upload_file(
|
||||
item_path, file_name, mime_type, config_dict['GDRIVE_ID'], is_dir=False)
|
||||
|
@ -116,7 +116,7 @@ async def get_tg_link_content(link):
|
||||
if not user:
|
||||
raise e
|
||||
|
||||
if private:
|
||||
if private and user:
|
||||
try:
|
||||
user_message = await user.get_messages(chat_id=chat, message_ids=msg_id)
|
||||
except:
|
||||
@ -125,7 +125,7 @@ async def get_tg_link_content(link):
|
||||
return user_message, 'user'
|
||||
else:
|
||||
raise Exception("Private: Please report!")
|
||||
elif message:
|
||||
elif not private:
|
||||
return message, 'bot'
|
||||
else:
|
||||
raise Exception("Bot can't download from GROUPS without joining!")
|
||||
|
@ -48,6 +48,9 @@ async def rcloneNode(client, message, link, dst_path, rcf, tag):
|
||||
return
|
||||
|
||||
dst_path = (dst_path or config_dict['RCLONE_PATH']).strip('/')
|
||||
if not is_rclone_path(dst_path):
|
||||
await sendMessage(message, 'Wrong Rclone Clone Destination!')
|
||||
return
|
||||
if dst_path.startswith('mrcc:'):
|
||||
if config_path != f'rclone/{message.from_user.id}.conf':
|
||||
await sendMessage(message, 'You should use same rclone.conf to clone between pathies!')
|
||||
|
@ -241,6 +241,9 @@ async def _mirror_leech(client, message, isZip=False, extract=False, isQbit=Fals
|
||||
if not await aiopath.exists(config_path):
|
||||
await sendMessage(message, f"Rclone Config: {config_path} not Exists!")
|
||||
return
|
||||
if up != 'gd' and not is_rclone_path(up):
|
||||
await sendMessage(message, 'Wrong Rclone Upload Destination!')
|
||||
return
|
||||
|
||||
if link == 'rcl':
|
||||
link = await RcloneList(client, message).get_rclone_path('rcd')
|
||||
|
@ -426,7 +426,7 @@ async def rssListener(client, query):
|
||||
buttons.ibutton("Back", f"rss back {user_id}")
|
||||
buttons.ibutton("Close", f"rss close {user_id}")
|
||||
button = buttons.build_menu(2)
|
||||
await editMessage(message, 'Send one title with vlaue separated by space get last X items.\nTitle Value\nTimeout: 60 sec.', button)
|
||||
await editMessage(message, 'Send one title with value separated by space get last X items.\nTitle Value\nTimeout: 60 sec.', button)
|
||||
pfunc = partial(rssGet, pre_event=query)
|
||||
await event_handler(client, query, pfunc)
|
||||
elif data[1] in ['unsubscribe', 'pause', 'resume']:
|
||||
|
@ -388,6 +388,9 @@ async def _ytdl(client, message, isZip=False, isLeech=False, sameDir=None, bulk=
|
||||
if not await aiopath.exists(config_path):
|
||||
await sendMessage(message, f'Rclone Config: {config_path} not Exists!')
|
||||
return
|
||||
if up != 'gd' and not is_rclone_path(up):
|
||||
await sendMessage(message, 'Wrong Rclone Upload Destination!')
|
||||
return
|
||||
|
||||
if up == 'rcl' and not isLeech:
|
||||
up = await RcloneList(client, message).get_rclone_path('rcu')
|
||||
|
Loading…
Reference in New Issue
Block a user