Direct link generator: Added 1fichier support

Co-authored-by: Maujar <Maujar@users.noreply.github.com>
Co-authored-by: Ncode2014 <Ncode2014@users.noreply.github.com>
Signed-off-by: breakdowns <hafitz666@outlook.co.id>
This commit is contained in:
Hafitz Setya 2021-07-19 19:39:25 +07:00 committed by GitHub
parent fddfa89ad8
commit 63e0ba8eff
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,6 +89,8 @@ def direct_link_generator(link: str):
return anonfiles(link)
elif 'racaty.net' in link:
return racaty(link)
elif '1fichier.com' in link:
return fichier(link)
else:
raise DirectDownloadLinkException(f'No Direct link function found for {link}')
@ -337,6 +339,65 @@ def racaty(url: str) -> str:
dl_url = rsoup.find("a", {"id": "uniqueExpirylink"})["href"].replace(" ", "%20")
return dl_url
def fichier(link: str) -> str:
regex = r"^([http:\/\/|https:\/\/]+)?.*1fichier\.com\/\?.+"
gan = re.match(regex, link)
if not gan:
raise DirectDownloadLinkException("ERROR: The link you entered is wrong!")
if "::" in link:
pswd = link.split("::")[-1]
url = link.split("::")[-2]
else:
pswd = None
url = link
try:
if pswd is None:
req = requests.post(url)
else:
pw = {"pass": pswd}
req = requests.post(url, data=pe)
except:
raise DirectDownloadLinkException("ERROR: Unable to reach 1fichier server!")
if req.status_code == 404:
raise DirectDownloadLinkException("ERROR: File not found / The link you entered is wrong!")
soup = BeautifulSoup(req.content, 'lxml')
if soup.find("a", {"class": "ok btn-general btn-orange"}) is not None:
dl_url = soup.find("a", {"class": "ok btn-general btn-orange"})["href"]
if dl_url is None:
raise DirectDownloadLinkException("ERROR: Unable to generate Direct Link 1fichier!")
else:
return dl_url
else:
if len(soup.find_all("div", {"class": "ct_warn"})) == 2:
str_2 = soup.find_all("div", {"class": "ct_warn"})[-1]
if "you must wait" in str(str_2).lower():
numbers = [int(word) for word in str(str_2).split() if word.isdigit()]
if len(numbers) == 0:
raise DirectDownloadLinkException("ERROR: 1fichier is on a limit. Please wait a few minutes/hour.")
else:
raise DirectDownloadLinkException(f"ERROR: 1fichier is on a limit. Please wait {numbers[0]} minute.")
elif "protect access" in str(str_2).lower():
raise DirectDownloadLinkException("ERROR: This link requires a password!\n\n<b>This link requires a password!</b>\n- Insert sign <b>::</b> after the link and write the password after the sign.\n\n<b>Example:</b>\n<code>/mirror https://1fichier.com/?smmtd8twfpm66awbqz04::love you</code>\n\n* No spaces between the signs <b>::</b>\n* For the password, you can use a space!")
else:
raise DirectDownloadLinkException("ERROR: Error trying to generate Direct Link from 1fichier!")
elif len(soup.find_all("div", {"class": "ct_warn"})) == 3:
str_1 = soup.find_all("div", {"class": "ct_warn"})[-2]
str_3 = soup.find_all("div", {"class": "ct_warn"})[-1]
if "you must wait" in str(str_1).lower():
numbers = [int(word) for word in str(str_1).split() if word.isdigit()]
if len(numbers) == 0:
raise DirectDownloadLinkException("ERROR: 1fichier is on a limit. Please wait a few minutes/hour.")
else:
raise DirectDownloadLinkException(f"ERROR: 1fichier is on a limit. Please wait {numbers[0]} minute.")
elif "bad password" in str(str_3).lower():
raise DirectDownloadLinkException("ERROR: The password you entered is wrong!")
else:
raise DirectDownloadLinkException("ERROR: Error trying to generate Direct Link from 1fichier!")
else:
raise DirectDownloadLinkException("ERROR: Error trying to generate Direct Link from 1fichier!")
def useragent():
"""
useragent random setter