From c884bda61cbfad850676fe9c248c69e037f555e2 Mon Sep 17 00:00:00 2001 From: 4amparaboy <76533278+4amparaboy@users.noreply.github.com> Date: Mon, 19 Jul 2021 03:40:55 +0700 Subject: [PATCH] Direct link generator: Add racaty support again --- .../download_utils/direct_link_generator.py | 21 ++++++++++++++++++- requirements.txt | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) 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 1a4a0a37e10..589a7226f5a 100644 --- a/bot/helper/mirror_utils/download_utils/direct_link_generator.py +++ b/bot/helper/mirror_utils/download_utils/direct_link_generator.py @@ -18,7 +18,7 @@ from urllib.parse import urlparse import lk21 -import requests +import requests, cfscrape from bs4 import BeautifulSoup from js2py import EvalJs from lk21.extractors.bypasser import Bypass @@ -87,6 +87,8 @@ def direct_link_generator(link: str): return streamtape(link) elif 'bayfiles.com' in link: return anonfiles(link) + elif 'racaty.net' in link: + return racaty(link) else: raise DirectDownloadLinkException(f'No Direct link function found for {link}') @@ -317,6 +319,23 @@ def streamtape(url: str) -> str: dl_url=bypasser.bypass_streamtape(url) return dl_url +def racaty(url: str) -> str: + """ Racaty direct links generator + based on https://github.com/breakdowns/slam-mirrorbot """ + dl_url = '' + try: + link = re.findall(r'\bhttps?://.*racaty\.net\S+', url)[0] + except IndexError: + raise DirectDownloadLinkException("`No Racaty links found`\n") + scraper = cfscrape.create_scraper() + r = scraper.get(url) + soup = BeautifulSoup(r.text, "lxml") + op = soup.find("input", {"name": "op"})["value"] + ids = soup.find("input", {"name": "id"})["value"] + rpost = scraper.post(url, data = {"op": op, "id": ids}) + rsoup = BeautifulSoup(rpost.text, "lxml") + dl_url = rsoup.find("a", {"id": "uniqueExpirylink"})["href"].replace(" ", "%20") + return dl_url def useragent(): """ diff --git a/requirements.txt b/requirements.txt index 76114b34a4b..d491a11b75a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ aiohttp aria2p appdirs beautifulsoup4 +cloudscrape==0.4.2 feedparser gitpython google-api-python-client