Skip to content

Commit

Permalink
Mediafire password support
Browse files Browse the repository at this point in the history
  • Loading branch information
junedkh committed Jul 20, 2024
1 parent acfab96 commit 70a8627
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ def get_captcha_token(session, params):
def mediafire(url, session=None):
if "/folder/" in url:
return mediafireFolder(url)
if "::" in url:
_password = url.split("::")[-1]
url = url.split("::")[-2]
else:
_password = ""
if final_link := findall(
r"https?:\/\/download\d+\.mediafire\.com\/\S+\/\S+\/\S+", url
):
Expand All @@ -234,6 +239,18 @@ def mediafire(url, session=None):
if error := html.xpath('//p[@class="notranslate"]/text()'):
session.close()
raise DirectDownloadLinkException(f"ERROR: {error[0]}")
if html.xpath("//div[@class='passwordPrompt']"):
if not _password:
session.close()
raise DirectDownloadLinkException(f"ERROR: {PASSWORD_ERROR_MESSAGE}".format(url))
try:
html = HTML(session.post(url, data={"downloadp": _password}).text)
except Exception as e:
session.close()
raise DirectDownloadLinkException(f"ERROR: {e.__class__.__name__}") from e
if html.xpath("//div[@class='passwordPrompt']"):
session.close()
raise DirectDownloadLinkException("ERROR: Wrong password.")
if not (final_link := html.xpath("//a[@id='downloadButton']/@href")):
session.close()
raise DirectDownloadLinkException(
Expand Down

0 comments on commit 70a8627

Please sign in to comment.