Skip to content

Commit

Permalink
Direct link generator: Add racaty support again
Browse files Browse the repository at this point in the history
  • Loading branch information
4amparaboy authored Jul 18, 2021
1 parent 211d799 commit c884bda
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bot/helper/mirror_utils/download_utils/direct_link_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}')

Expand Down Expand Up @@ -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():
"""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ aiohttp
aria2p
appdirs
beautifulsoup4
cloudscrape==0.4.2
feedparser
gitpython
google-api-python-client
Expand Down

0 comments on commit c884bda

Please sign in to comment.