mirror of
https://github.com/anasty17/mirror-leech-telegram-bot.git
synced 2025-01-08 12:07:33 +08:00
Terabox ddl fix
Only videos (file/folders) Signed-off-by: Dawn India <dawn-in@z-mirror.eu.org>
This commit is contained in:
parent
c9c75a65b5
commit
e44d9f82c9
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,5 +16,4 @@ list_drives.txt
|
||||
cookies.txt
|
||||
downloads
|
||||
bot.session*
|
||||
terabox.txt
|
||||
rclone.conf
|
||||
|
@ -159,8 +159,7 @@ programming in Python.
|
||||
> shrdsk.me (
|
||||
> sharedisk.io), akmfiles.com, wetransfer.com, pcloud.link, gofile.io (file/folders), easyupload.io, mdisk.me (with
|
||||
> ytdl),
|
||||
> tmpsend.com, qiwi.gg, berkasdrive.com, mp4upload.com, terabox.com (file/folders) (you need to add cookies txt with
|
||||
> name) [terabox.txt](https://github.com/ytdl-org/youtube-dl#how-do-i-pass-cookies-to-youtube-dl).
|
||||
> tmpsend.com, qiwi.gg, berkasdrive.com, mp4upload.com, terabox.com (videos only file/folders).
|
||||
|
||||
# How to deploy?
|
||||
|
||||
|
@ -134,6 +134,7 @@ def direct_link_generator(link):
|
||||
"terabox.app",
|
||||
"gibibox.com",
|
||||
"goaibox.com",
|
||||
"terasharelink.com",
|
||||
]
|
||||
):
|
||||
return terabox(link)
|
||||
@ -557,88 +558,73 @@ def uploadee(url):
|
||||
|
||||
|
||||
def terabox(url):
|
||||
if not ospath.isfile("terabox.txt"):
|
||||
raise DirectDownloadLinkException("ERROR: terabox.txt not found")
|
||||
try:
|
||||
jar = MozillaCookieJar("terabox.txt")
|
||||
jar.load()
|
||||
except Exception as e:
|
||||
raise DirectDownloadLinkException(f"ERROR: {e.__class__.__name__}")
|
||||
cookies = {}
|
||||
for cookie in jar:
|
||||
cookies[cookie.name] = cookie.value
|
||||
"""Terabox direct link generator
|
||||
By: https://github.com/Dawn-India/Z-Mirror"""
|
||||
|
||||
pattern1 = r"/s/(\w+)"
|
||||
pattern2 = r"surl=(\w+)"
|
||||
|
||||
if not (
|
||||
search(
|
||||
pattern1,
|
||||
url
|
||||
) or search(
|
||||
pattern2,
|
||||
url
|
||||
)
|
||||
):
|
||||
raise DirectDownloadLinkException("ERROR: Invalid terabox URL")
|
||||
|
||||
netloc = urlparse(url).netloc
|
||||
url = url.replace(
|
||||
netloc,
|
||||
"1024tera.com"
|
||||
)
|
||||
response = get(url)
|
||||
if response.status_code != 200:
|
||||
raise DirectDownloadLinkException("ERROR: Unable to fetch the webpage")
|
||||
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0",
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Accept-Language": "en-US,en;q=0.5",
|
||||
"Content-Type": "application/json",
|
||||
"Origin": "https://ytshorts.savetube.me",
|
||||
"Alt-Used": "ytshorts.savetube.me",
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Site": "same-origin"
|
||||
}
|
||||
|
||||
response = post(
|
||||
"https://ytshorts.savetube.me/api/v1/terabox-downloader",
|
||||
headers=headers,
|
||||
json={"url": url}
|
||||
)
|
||||
if response.status_code != 200:
|
||||
raise DirectDownloadLinkException("ERROR: Unable to fetch the JSON data")
|
||||
|
||||
data = response.json()
|
||||
details = {"contents": [], "title": "", "total_size": 0}
|
||||
details["header"] = " ".join(f"{key}: {value}" for key, value in cookies.items())
|
||||
|
||||
def __fetch_links(session, dir_="", folderPath=""):
|
||||
params = {"app_id": "250528", "jsToken": jsToken, "shorturl": shortUrl}
|
||||
if dir_:
|
||||
params["dir"] = dir_
|
||||
else:
|
||||
params["root"] = "1"
|
||||
try:
|
||||
_json = session.get(
|
||||
"https://www.1024tera.com/share/list",
|
||||
params=params,
|
||||
cookies=cookies,
|
||||
).json()
|
||||
except Exception as e:
|
||||
raise DirectDownloadLinkException(f"ERROR: {e.__class__.__name__}")
|
||||
if _json["errno"] not in [0, "0"]:
|
||||
if "errmsg" in _json:
|
||||
raise DirectDownloadLinkException(f"ERROR: {_json['errmsg']}")
|
||||
else:
|
||||
raise DirectDownloadLinkException("ERROR: Something went wrong!")
|
||||
for item in data["response"]:
|
||||
title = item["title"]
|
||||
resolutions = item.get(
|
||||
"resolutions",
|
||||
{}
|
||||
)
|
||||
zlink = resolutions.get("HD Video")
|
||||
if zlink:
|
||||
details["contents"].append({
|
||||
"url": zlink,
|
||||
"filename": title,
|
||||
"path": ospath.join(
|
||||
title,
|
||||
"HD_Video"
|
||||
)
|
||||
})
|
||||
details["title"] = title
|
||||
|
||||
if "list" not in _json:
|
||||
return
|
||||
contents = _json["list"]
|
||||
for content in contents:
|
||||
if content["isdir"] in ["1", 1]:
|
||||
if not folderPath:
|
||||
if not details["title"]:
|
||||
details["title"] = content["server_filename"]
|
||||
newFolderPath = ospath.join(details["title"])
|
||||
else:
|
||||
newFolderPath = ospath.join(
|
||||
details["title"], content["server_filename"]
|
||||
)
|
||||
else:
|
||||
newFolderPath = ospath.join(folderPath, content["server_filename"])
|
||||
__fetch_links(session, content["path"], newFolderPath)
|
||||
else:
|
||||
if not folderPath:
|
||||
if not details["title"]:
|
||||
details["title"] = content["server_filename"]
|
||||
folderPath = details["title"]
|
||||
item = {
|
||||
"url": content["dlink"],
|
||||
"filename": content["server_filename"],
|
||||
"path": ospath.join(folderPath),
|
||||
}
|
||||
if "size" in content:
|
||||
size = content["size"]
|
||||
if isinstance(size, str) and size.isdigit():
|
||||
size = float(size)
|
||||
details["total_size"] += size
|
||||
details["contents"].append(item)
|
||||
|
||||
with Session() as session:
|
||||
try:
|
||||
_res = session.get(url, cookies=cookies)
|
||||
except Exception as e:
|
||||
raise DirectDownloadLinkException(f"ERROR: {e.__class__.__name__}")
|
||||
if jsToken := findall(r"window\.jsToken.*%22(.*)%22", _res.text):
|
||||
jsToken = jsToken[0]
|
||||
else:
|
||||
raise DirectDownloadLinkException("ERROR: jsToken not found!.")
|
||||
shortUrl = parse_qs(urlparse(_res.url).query).get("surl")
|
||||
if not shortUrl:
|
||||
raise DirectDownloadLinkException("ERROR: Could not find surl")
|
||||
try:
|
||||
__fetch_links(session)
|
||||
except Exception as e:
|
||||
raise DirectDownloadLinkException(e)
|
||||
if len(details["contents"]) == 1:
|
||||
return details["contents"][0]["url"]
|
||||
return details
|
||||
|
@ -9,7 +9,7 @@ from tenacity import RetryError
|
||||
from time import time
|
||||
|
||||
from bot import config_dict
|
||||
from bot.helper.ext_utils.bot_utils import new_task, update_user_ldata
|
||||
from bot.helper.ext_utils.bot_utils import update_user_ldata
|
||||
from bot.helper.ext_utils.db_handler import DbManager
|
||||
from bot.helper.ext_utils.status_utils import get_readable_file_size, get_readable_time
|
||||
from bot.helper.mirror_leech_utils.gdrive_utils.helper import GoogleDriveHelper
|
||||
|
@ -155,7 +155,7 @@ async def get_buttons(key=None, edit_type=None):
|
||||
elif key == "private":
|
||||
buttons.ibutton("Back", "botset back")
|
||||
buttons.ibutton("Close", "botset close")
|
||||
msg = """Send private file: config.env, token.pickle, rclone.conf, accounts.zip, list_drives.txt, cookies.txt, terabox.txt, .netrc or any other private file!
|
||||
msg = """Send private file: config.env, token.pickle, rclone.conf, accounts.zip, list_drives.txt, cookies.txt, .netrc or any other private file!
|
||||
To delete private file send only the file name as text message.
|
||||
Note: Changing .netrc will not take effect for aria2c until restart.
|
||||
Timeout: 60 sec"""
|
||||
|
Loading…
Reference in New Issue
Block a user