Skip to content

Commit 70a8627

Browse files
committed
Mediafire password support
1 parent acfab96 commit 70a8627

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py

+17
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ def get_captcha_token(session, params):
218218
def mediafire(url, session=None):
219219
if "/folder/" in url:
220220
return mediafireFolder(url)
221+
if "::" in url:
222+
_password = url.split("::")[-1]
223+
url = url.split("::")[-2]
224+
else:
225+
_password = ""
221226
if final_link := findall(
222227
r"https?:\/\/download\d+\.mediafire\.com\/\S+\/\S+\/\S+", url
223228
):
@@ -234,6 +239,18 @@ def mediafire(url, session=None):
234239
if error := html.xpath('//p[@class="notranslate"]/text()'):
235240
session.close()
236241
raise DirectDownloadLinkException(f"ERROR: {error[0]}")
242+
if html.xpath("//div[@class='passwordPrompt']"):
243+
if not _password:
244+
session.close()
245+
raise DirectDownloadLinkException(f"ERROR: {PASSWORD_ERROR_MESSAGE}".format(url))
246+
try:
247+
html = HTML(session.post(url, data={"downloadp": _password}).text)
248+
except Exception as e:
249+
session.close()
250+
raise DirectDownloadLinkException(f"ERROR: {e.__class__.__name__}") from e
251+
if html.xpath("//div[@class='passwordPrompt']"):
252+
session.close()
253+
raise DirectDownloadLinkException("ERROR: Wrong password.")
237254
if not (final_link := html.xpath("//a[@id='downloadButton']/@href")):
238255
session.close()
239256
raise DirectDownloadLinkException(

0 commit comments

Comments
 (0)