From e805e7728f2c874b50e27abc1fe788ba53c6d830 Mon Sep 17 00:00:00 2001 From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com> Date: Wed, 9 Jun 2021 04:38:17 +0700 Subject: [PATCH] v4.8.4 - Added support for tar.xz - Fix Mega auto canceling if deleted file (#145) - Direct link generator: Addad Naniplay.com, Naniplay.nanime.biz, Sbembed.com, Streamsb.net support Co-authored-by: Ncode2014 Co-authored-by: FA Tulloh <77918734+yourtulloh@users.noreply.github.com> --- README.md | 11 ++--- app.json | 2 +- aria.sh | 2 +- bot/helper/ext_utils/fs_utils.py | 2 + .../download_utils/direct_link_generator.py | 40 ++++++++++--------- .../download_utils/mega_downloader.py | 5 ++- extract | 5 +++ pextract | 5 +++ 8 files changed, 44 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index c2297c66f69..fffc2ad8e8f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ **Slam Mirror Bot** is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive. # Features supported: - ## Additional Features - Get detailed info about replied media (Only for Telegram file) - Nyaa.si and Sukebei Torrent search @@ -25,6 +24,7 @@ - Sudo with Database support - Multiple Trackers support - Check Heroku dynos stats +- Extracting **tar.xz** support - Custom image support - Counting file/folder - Shell and Executor @@ -32,9 +32,10 @@ - View Link button (Not all Index support, recommended using [Bhadoo Index](https://github.com/ParveenBhadooOfficial/Google-Drive-Index)) - Direct links supported: ``` -Racaty, Hxfile, Anonfiles, Fembed, Femax20, Layarkacaxxi, -Uptobox (Uptobox account must be premium), -Onedrive (Only works for file not folder or busines account) +Racaty.net, Hxfile.co, Anonfiles.com, Fembed.com, Femax20.com, Layarkacaxxi.icu, +Naniplay.com, Naniplay.nanime.in, Naniplay.nanime.biz, Sbembed.com, Streamsb.net, +Uptobox.com (Uptobox account must be premium), +Onedrive/1drv.ms (Only works for file not folder or busines account) ``` ## From Original Repos - Mirroring direct download links, Torrent, and Telegram files to Google Drive @@ -139,7 +140,7 @@ Fill up rest of the fields. Meaning of each fields are discussed below: - **BLOCK_MEGA_FOLDER**: (Optional field) If you want to remove mega.nz folder support, set it to `True`. - **BLOCK_MEGA_LINKS**: (Optional field) If you want to remove mega.nz mirror support, set it to `True`. - **STOP_DUPLICATE_MIRROR**: (Optional field) (Leave empty if unsure) if this field is set to `True`, bot will check file in drive, if it is present in Drive, downloading will be stopped. (**Note**: File will be checked using filename, not using filehash, so this feature is not perfect yet) -- **CLONE_LIMIT**: To limit cloning Google Drive (leave space between number and unit (tb or gb only)), examples: if you fill `1 gb` it will limit `1gb`. +- **CLONE_LIMIT**: To limit cloning Google Drive (leave space between number and unit, **tb or gb only**), examples: if you fill `1 gb` it will limit `1gb`. - **ENABLE_FILESIZE_LIMIT**: Set it to `True` if you want to use `MAX_TORRENT_SIZE`. - **MAX_TORRENT_SIZE**: To limit the Torrent mirror size, Fill The amount you want to limit, examples: if you fill `15` it will limit `15gb`. - **IMAGE_URL**: (Optional field) Show Image/Logo in /start message. Fill value of image your link image, use telegra.ph or any direct link image. diff --git a/app.json b/app.json index af4945127fb..57a01674027 100644 --- a/app.json +++ b/app.json @@ -109,7 +109,7 @@ "required": false }, "CLONE_LIMIT": { - "description": "To limit cloning Google Drive (leave space between number and unit (tb or gb only)), examples: if you fill 1 gb it will limit 1gb.", + "description": "To limit cloning Google Drive (leave space between number and unit, tb or gb only), examples: if you fill 1 gb it will limit 1gb.", "required": false }, "STOP_DUPLICATE_MIRROR": { diff --git a/aria.sh b/aria.sh index 9afb653c71b..148a4b044e8 100755 --- a/aria.sh +++ b/aria.sh @@ -8,7 +8,7 @@ aria2c --enable-rpc --rpc-listen-all=false --rpc-listen-port 6800 --check-certif --follow-torrent=mem --split=10 \ --daemon=true --allow-overwrite=true --max-overall-download-limit=$MAX_DOWNLOAD_SPEED \ --max-overall-upload-limit=1K --max-concurrent-downloads=$MAX_CONCURRENT_DOWNLOADS \ - --peer-id-prefix=-qB4250- --user-agent=qBittorrent/4.2.5 \ + --peer-id-prefix=-qB4350- --user-agent=qBittorrent/4.3.5 --peer-agent=qBittorrent/4.3.5 \ --disk-cache=64M --file-allocation=prealloc --continue=true \ --max-file-not-found=5 --max-tries=20 --auto-file-renaming=true \ --bt-enable-lpd=true --seed-time=0.01 --seed-ratio=1.0 \ diff --git a/bot/helper/ext_utils/fs_utils.py b/bot/helper/ext_utils/fs_utils.py index af89947dc31..ce54ac0819e 100644 --- a/bot/helper/ext_utils/fs_utils.py +++ b/bot/helper/ext_utils/fs_utils.py @@ -69,6 +69,8 @@ def get_base_name(orig_path: str): return orig_path.replace(".bz2", "") elif orig_path.endswith(".gz"): return orig_path.replace(".gz", "") + elif orig_path.endswith(".tar.xz"): + return orig_path.replace(".tar.xz", "") elif orig_path.endswith(".tar"): return orig_path.replace(".tar", "") elif orig_path.endswith(".tbz2"): diff --git a/bot/helper/mirror_utils/download_utils/direct_link_generator.py b/bot/helper/mirror_utils/download_utils/direct_link_generator.py index ed66ac0b06c..1bc8141696a 100644 --- a/bot/helper/mirror_utils/download_utils/direct_link_generator.py +++ b/bot/helper/mirror_utils/download_utils/direct_link_generator.py @@ -52,10 +52,22 @@ def direct_link_generator(link: str): return hxfile(link) elif 'anonfiles.com' in link: return anon(link) + elif 'fembed.com' in link: + return fembed(link) elif 'femax20.com' in link: - return femax20(link) + return fembed(link) + elif 'naniplay.nanime.in' in link: + return fembed(link) + elif 'naniplay.nanime.biz' in link: + return fembed(link) + elif 'naniplay.com' in link: + return fembed(link) elif 'layarkacaxxi.icu' in link: - return layarkacaxxi(link) + return fembed(link) + elif 'sbembed.com' in link: + return sbembed(link) + elif 'streamsb.net' in link: + return sbembed(link) elif '1drv.ms' in link: return onedrive(link) else: @@ -235,14 +247,9 @@ def anon(url: str) -> str: return dl_url -def femax20(url: str) -> str: - """ Fembed direct links generator - based on https://github.com/breakdowns/slam-mirrorbot """ - dl_url = '' - try: - link = re.findall(r'\bhttps?://.*femax20\.com\S+', url)[0] - except IndexError: - raise DirectDownloadLinkException("`No Fembed links found`\n") +def fembed(link: str) -> str: + """ Fembed direct link generator + Based on https://github.com/breakdowns/slam-mirrorbot """ bypasser = lk21.Bypass() dl_url=bypasser.bypass_fembed(link) lst_link = [] @@ -252,16 +259,11 @@ def femax20(url: str) -> str: return lst_link[count-1] -def layarkacaxxi(url: str) -> str: - """ Fembed direct links generator - based on https://github.com/breakdowns/slam-mirrorbot """ - dl_url = '' - try: - link = re.findall(r'\bhttps?://.*layarkacaxxi\.icu\S+', url)[0] - except IndexError: - raise DirectDownloadLinkException("No Fembed links found\n") +def sbembed(link: str) -> str: + """ Sbembed direct link generator + Based on https://github.com/breakdowns/slam-mirrorbot """ bypasser = lk21.Bypass() - dl_url=bypasser.bypass_fembed(link) + dl_url=bypasser.bypass_sbembed(link) lst_link = [] count = len(dl_url) for i in dl_url: diff --git a/bot/helper/mirror_utils/download_utils/mega_downloader.py b/bot/helper/mirror_utils/download_utils/mega_downloader.py index e1f43a5b764..a0c8ee61595 100644 --- a/bot/helper/mirror_utils/download_utils/mega_downloader.py +++ b/bot/helper/mirror_utils/download_utils/mega_downloader.py @@ -63,6 +63,8 @@ def onRequestFinish(self, api, request, error): .format(request, error)) if str(error).lower() != "no error": self.error = error.copy() + self.is_cancelled = True + self.listener.onDownloadError("\nMEGA Link you are trying to download is no longer available.") return request_type = request.getType() if request_type == MegaRequest.TYPE_LOGIN: @@ -165,8 +167,7 @@ def add_download(mega_link: str, path: str, listener): folder_api.addListener(mega_listener) executor.do(folder_api.loginToFolder, (mega_link,)) node = folder_api.authorizeNode(mega_listener.node) - if mega_listener.error is not None: - return listener.onDownloadError(str(mega_listener.error)) + gid = ''.join(random.SystemRandom().choices(string.ascii_letters + string.digits, k=8)) mega_listener.setValues(node.getName(), api.getSize(node), gid) executor.do(api.startDownload,(node,path)) diff --git a/extract b/extract index bd05693c6a5..7500a407d92 100755 --- a/extract +++ b/extract @@ -37,6 +37,11 @@ extract() { tar xzf "$arg" --one-top-level local code=$? ;; + *.tar.xz) + a_dir=$(expr "$arg" : '\(.*\).tar.xz') + 7z x "$arg" -o"$a_dir" + local code=$? + ;; *.zip) a_dir=$(expr "$arg" : '\(.*\).zip') 7z x "$arg" -o"$a_dir" diff --git a/pextract b/pextract index 43949680c6b..7c53e08a846 100644 --- a/pextract +++ b/pextract @@ -38,6 +38,11 @@ extract() { tar xzf "$arg" --one-top-level local code=$? ;; + *.tar.xz) + a_dir=$(expr "$arg" : '\(.*\).tar.xz') + 7z x "$arg" -o"$a_dir" -p"$pswd" + local code=$? + ;; *.zip) a_dir=$(expr "$arg" : '\(.*\).zip') 7z x "$arg" -o"$a_dir" -p"$pswd"