def gdrive(url: str) -> str: """ GDrive direct links generator """ drive = 'https://drive.google.com' try: link = re.findall(r'\bhttps?://drive\.google\.com\S+', url)[0] except IndexError: reply = "`No Google drive links found`\n" return reply file_id = '' if link.find("view") != -1: file_id = link.split('/')[-2] elif link.find("open?id=") != -1: file_id = link.split("open?id=")[1].strip() elif link.find("uc?id=") != -1: file_id = link.split("uc?id=")[1].strip() url = f'{drive}/uc?export=download&id={file_id}' download = requests.get(url, stream=True, allow_redirects=False) cookies = download.cookies try: # In case of small file size, Google downloads directly dl_url = download.headers["location"] if 'accounts.google.com' in dl_url: # non-public file raise DirectDownloadLinkException('`Link not public`') except KeyError: # In case of download warning page page = BeautifulSoup(download.content, 'lxml') export = drive + page.find('a', {'id': 'uc-download-link'}).get('href') response = requests.get(export, stream=True, allow_redirects=False, cookies=cookies) dl_url = response.headers['location'] if 'accounts.google.com' in dl_url: raise DirectDownloadLinkException('`Link not public`') return dl_url
def zippy_share(url: str) -> str: """ ZippyShare direct links generator Based on https://github.com/KenHV/Mirror-Bot https://github.com/jovanzers/WinTenCermin """ try: link = re.findall(r'\bhttps?://.*zippyshare\.com\S+', url)[0] except IndexError: raise DirectDownloadLinkException("No Zippyshare links found") try: base_url = re.search('http.+.zippyshare.com', link).group() response = requests.get(link).content pages = BeautifulSoup(response, "lxml") try: js_script = pages.find("div", {"class": "center"}).find_all("script")[1] except IndexError: js_script = pages.find("div", {"class": "right"}).find_all("script")[0] js_content = re.findall(r'\.href.=."/(.*?)";', str(js_script)) js_content = 'var x = "/' + js_content[0] + '"' evaljs = EvalJs() setattr(evaljs, "x", None) evaljs.execute(js_content) js_content = getattr(evaljs, "x") return base_url + js_content except IndexError: raise DirectDownloadLinkException("ERROR: Can't find download button")
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`No links found!`") if 'drive.google.com' in link: return gdrive(link) elif 'zippyshare.com' in link: return zippy_share(link) elif 'mega.' in link: return mega_dl(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif 'sourceforge.net' in link: return sourceforge(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'androidfilehost.com' in link: return androidfilehost(link) else: raise DirectDownloadLinkException( re.findall(r"\bhttps?://(.*?[^/]+)", link)[0] + 'is not supported')
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`No links found!`") if 'drive.google.com' in link: return gdrive(link) elif 'zippyshare.com' in link: return zippy_share(link) elif 'mega.' in link: return mega_dl(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'androidfilehost.com' in link: return androidfilehost(link) else: raise DirectDownloadLinkException( f'No Direct link function found for {link}')
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`No links found!`") elif 'zippyshare.com' in link: return zippy_share(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif 'uptobox.com' in link: return uptobox(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'fembed.com' in link: return fembed(link) elif 'femax20.com' in link: return fembed(link) elif 'feurl.com' in link: return fembed(link) else: raise DirectDownloadLinkException(f'No Direct link function found for {link}')
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`No links found!`") elif 'zippyshare.com' in link: return zippy_share(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif 'uptobox.com' in link: return uptobox(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'racaty.net' in link: return racaty(link) elif 'hxfile.co' in link: return hxfile(link) elif 'anonfiles.com' in link: return anon(link) elif 'femax20.com' in link: return femax20(link) elif 'layarkacaxxi.icu' in link: return layarkacaxxi(link) elif '1drv.ms' in link: return onedrive(link) else: raise DirectDownloadLinkException( f'No Direct link function found for {link}')
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`No links found!`") elif 'youtube.com' in link or 'youtu.be' in link: raise DirectDownloadLinkException( f"Youtube Link use /{BotCommands.WatchCommand} or /{BotCommands.TarWatchCommand}" ) elif 'zippyshare.com' in link: return zippy_share(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif '1fichier.com' in link: raise DirectDownloadLinkException( f"ERROR: 1fichier tidak bisa digunakan, alternatifnya gunakan mirror mega file / mirror racaty." ) elif 'uptobox.com' in link: raise DirectDownloadLinkException( f"ERROR: Mohon maaf, Uptobox tidak support karena admin belum mempunyai key. Silahkan berdonasi key UTB agar bisa digunakan atau gunakan mirror mega file/ mirror racaty." ) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'hxfile.co' in link: return hxfile(link) elif 'anonfiles.com' in link: return anon(link) elif 'letsupload.io' in link: return letsupload(link) elif 'fembed.com' in link: return fembed(link) elif 'femax20.com' in link: return fembed(link) elif 'feurl.com' in link: return fembed(link) elif 'naniplay.nanime.in' in link: return fembed(link) elif 'naniplay.nanime.biz' in link: return fembed(link) elif 'naniplay.com' in link: return fembed(link) elif 'layarkacaxxi.icu' in link: return fembed(link) elif 'sbembed.com' in link: return sbembed(link) elif 'streamsb.net' in link: return sbembed(link) elif '1drv.ms' in link: return onedrive(link) elif 'pixeldrain.com' in link: return pixeldrain(link) else: raise DirectDownloadLinkException( f'No Direct link function found for {link}')
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`No links found!`") elif 'youtube.com' in link or 'youtu.be' in link: raise DirectDownloadLinkException( f"Use /{BotCommands.WatchCommand} to mirror Youtube link\nUse /{BotCommands.TarWatchCommand} to make tar of Youtube playlist" ) elif 'zippyshare.com' in link: return zippy_share(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif 'uptobox.com' in link: return uptobox(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'hxfile.co' in link: return hxfile(link) elif 'anonfiles.com' in link: return anon(link) elif 'letsupload.io' in link: return letsupload(link) elif 'fembed.net' in link: return fembed(link) elif 'fembed.com' in link: return fembed(link) elif 'femax20.com' in link: return fembed(link) elif 'fcdn.stream' in link: return fembed(link) elif 'feurl.com' in link: return fembed(link) elif 'naniplay.nanime.in' in link: return fembed(link) elif 'naniplay.nanime.biz' in link: return fembed(link) elif 'naniplay.com' in link: return fembed(link) elif 'layarkacaxxi.icu' in link: return fembed(link) elif 'sbembed.com' in link: return sbembed(link) elif 'streamsb.net' in link: return sbembed(link) elif 'sbplay.org' in link: return sbembed(link) elif '1drv.ms' in link: return onedrive(link) elif 'pixeldrain.com' in link: return pixeldrain(link) else: raise DirectDownloadLinkException( f'No Direct link function found for {link}')
def github(url: str) -> str: """ GitHub direct links generator """ try: re.findall(r'\bhttps?://.*github\.com.*releases\S+', url)[0] except IndexError: raise DirectDownloadLinkException("No GitHub Releases links found\n") download = requests.get(url, stream=True, allow_redirects=False) try: return download.headers["location"] except KeyError: raise DirectDownloadLinkException("ERROR: Can't extract the link\n")
def github(url: str) -> str: """ GitHub direct links generator """ try: re.findall(r'\bhttps?://.*github\.com.*releases\S+', url)[0] except IndexError: raise DirectDownloadLinkException("`Link githubnya gk bisa nih`\n") download = requests.get(url, stream=True, allow_redirects=False) try: dl_url = download.headers["location"] return dl_url except KeyError: raise DirectDownloadLinkException("`Error: Can't extract the link`\n")
def direct_link_generator(link: str): """ direct links generator """ if 'youtube.com' in link or 'youtu.be' in link: raise DirectDownloadLinkException( f"ERROR: Use /{BotCommands.WatchCommand} to mirror Youtube link\nUse /{BotCommands.ZipWatchCommand} to make zip of Youtube playlist" ) elif 'zippyshare.com' in link: return zippy_share(link) elif 'yadi.sk' in link or 'disk.yandex.com' in link: return yandex_disk(link) elif 'mediafire.com' in link: return mediafire(link) elif 'uptobox.com' in link: return uptobox(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) elif 'hxfile.co' in link: return hxfile(link) elif 'anonfiles.com' in link: return anonfiles(link) elif 'letsupload.io' in link: return letsupload(link) elif '1drv.ms' in link: return onedrive(link) elif 'pixeldrain.com' in link: return pixeldrain(link) elif 'antfiles.com' in link: return antfiles(link) elif 'streamtape.com' in link: return streamtape(link) elif 'bayfiles.com' in link: return anonfiles(link) elif 'racaty.net' in link: return racaty(link) elif '1fichier.com' in link: return fichier(link) elif 'solidfiles.com' in link: return solidfiles(link) elif 'krakenfiles.com' in link: return krakenfiles(link) elif is_gdtot_link(link): return gdtot(link) elif any(x in link for x in fmed_list): return fembed(link) elif any(x in link for x in ['sbembed.com', 'watchsb.com', 'streamsb.net', 'sbplay.org']): return sbembed(link) else: raise DirectDownloadLinkException( f'No Direct link function found for {link}')
def yandex_disk(url: str) -> str: """ Yandex.Disk direct links generator Based on https://github.com/wldhx/yadisk-direct""" try: link = re.findall(r'\bhttps?://.*yadi\.sk\S+', url)[0] except IndexError: raise DirectDownloadLinkException("No Yandex.Disk links found") api = 'https://cloud-api.yandex.net/v1/disk/public/resources/download?public_key={}' try: return requests.get(api.format(link)).json()['href'] except KeyError: raise DirectDownloadLinkException( "Error: File not found / Download limit reached")
def cm_ru(url: str) -> str: """cloud.mail.ru direct links generator Using https://github.com/JrMasterModelBuilder/cmrudl.py""" try: link = re.findall(r"\bhttps?://.*cloud\.mail\.ru\S+", url)[0] except IndexError: raise DirectDownloadLinkException("`No cloud.mail.ru links found`\n") command = f"vendor/cmrudl/cmrudl -s {link}" result = popen(command).read() result = result.splitlines()[-1] try: data = json.loads(result) except json.decoder.JSONDecodeError: raise DirectDownloadLinkException("`Error: Can't extract the link`\n") return data["download"]
def mega_dl(url: str) -> str: """ MEGA.nz direct links generator Using https://github.com/tonikelope/megadown""" try: link = re.findall(r'\bhttps?://.*mega.*\.nz\S+', url)[0] except IndexError: raise DirectDownloadLinkException("`No MEGA.nz links found`\n") command = f'vendor/megadown/megadown -q -m {link}' result = popen(command).read() try: data = json.loads(result) except json.JSONDecodeError: raise DirectDownloadLinkException("`Error: Can't extract the link`\n") dl_url = data['url'] return dl_url
def gdtot(url: str) -> str: """ Gdtot google drive link generator By https://github.com/oxosec """ if CRYPT is None: raise DirectDownloadLinkException( "ERROR: PHPSESSID and CRYPT variables not provided") headers = { 'upgrade-insecure-requests': '1', 'save-data': 'on', 'user-agent': 'Mozilla/5.0 (Linux; Android 10; Redmi 8A Dual) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'sec-fetch-site': 'same-origin', 'sec-fetch-mode': 'navigate', 'sec-fetch-dest': 'document', 'referer': '', 'prefetchAd_3621940': 'true', 'accept-language': 'en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7' } r1 = requests.get(url, headers=headers, cookies=cookies).content s1 = BeautifulSoup(r1, 'html.parser').find('button', id="down") if s1 is not None: s1 = s1.get('onclick').split("'")[1] else: raise DirectDownloadLinkException( "ERROR: Check Your GDTot Link Maybe Not Found !") headers['referer'] = url s2 = BeautifulSoup( requests.get(s1, headers=headers, cookies=cookies).content, 'html.parser').find('meta').get('content').split('=', 1)[1] headers['referer'] = s1 s3 = BeautifulSoup( requests.get(s2, headers=headers, cookies=cookies).content, 'html.parser').find('div', align="center") if s3 is not None: return s3.find( 'a', class_="btn btn-outline-light btn-user font-weight-bold").get( 'href') s3 = BeautifulSoup( requests.get(s2, headers=headers, cookies=cookies).content, 'html.parser') status = s3.find('h4').text raise DirectDownloadLinkException(f"ERROR: {status}")
def zippy_share(url: str) -> str: """ ZippyShare direct links generator Based on https://github.com/LameLemon/ziggy""" dl_url = '' try: link = re.findall(r'\bhttps?://.*zippyshare\.com\S+', url)[0] except IndexError: raise DirectDownloadLinkException( "`link ZippySharenya ngk ada/hangus`\n") session = requests.Session() base_url = re.search('http.+.com', link).group() response = session.get(link) page_soup = BeautifulSoup(response.content, "lxml") scripts = page_soup.find_all("script", {"type": "text/javascript"}) for script in scripts: if "getElementById('dlbutton')" in script.text: url_raw = re.search(r'= (?P<url>\".+\" \+ (?P<math>\(.+\)) .+);', script.text).group('url') math = re.search(r'= (?P<url>\".+\" \+ (?P<math>\(.+\)) .+);', script.text).group('math') dl_url = url_raw.replace(math, '"' + str(eval(math)) + '"') break dl_url = base_url + eval(dl_url) name = urllib.parse.unquote(dl_url.split('/')[-1]) return dl_url
def cm_ru(url: str) -> str: """ cloud.mail.ru direct links generator Using https://github.com/JrMasterModelBuilder/cmrudl.py""" reply = '' try: link = re.findall(r'\bhttps?://.*cloud\.mail\.ru\S+', url)[0] except IndexError: raise DirectDownloadLinkException( "`cloud.mail.ru nya hangus/gk ada`\n") command = f'vendor/cmrudl.py/cmrudl -s {link}' result = popen(command).read() result = result.splitlines()[-1] try: data = json.loads(result) except json.decoder.JSONDecodeError: raise DirectDownloadLinkException("`Error: gk bisa ekstrak link`\n") dl_url = data['download'] return dl_url
def mediafire(url: str) -> str: """ MediaFire direct links generator """ try: link = re.findall(r'\bhttps?://.*mediafire\.com\S+', url)[0] except IndexError: raise DirectDownloadLinkException("No MediaFire links found\n") page = BeautifulSoup(requests.get(link).content, 'lxml') info = page.find('a', {'aria-label': 'Download file'}) return info.get('href')
def direct_link_generator(link: str): """ direct links generator """ if not link: raise DirectDownloadLinkException("`Link gk ditemukan`") elif 'zippyshare.com' in link: return zippy_share(link) elif 'yadi.sk' in link: return yandex_disk(link) elif 'cloud.mail.ru' in link: return cm_ru(link) elif 'mediafire.com' in link: return mediafire(link) elif 'osdn.net' in link: return osdn(link) elif 'github.com' in link: return github(link) else: raise DirectDownloadLinkException(f'Linknya rusak/hangus {link}')
def mediafire(url: str) -> str: """MediaFire direct links generator""" try: link = re.findall(r"\bhttps?://.*mediafire\.com\S+", url)[0] except IndexError: raise DirectDownloadLinkException("`No MediaFire links found`\n") page = BeautifulSoup(requests.get(link).content, "lxml") info = page.find("a", {"aria-label": "Download file"}) return info.get("href")
def pixel_drain(url: str) -> str: dl_url = '' try: link = re.findall(r'\bhttps?://.*pixeldrain\.com\S+', url)[0] except IndexError: raise DirectDownloadLinkException("`No Pixeldrain links found`\n") pixel_drain_link = urlparse(url) file_id = pixel_drain_link.path[3:] dl_url = 'https://pixeldrain.com/api/file/%s' % (file_id) return dl_url
def letsupload(url: str) -> str: """ Letsupload direct link generator Based on https://github.com/zevtyardt/lk21 """ dl_url = '' try: link = re.findall(r'\bhttps?://.*letsupload\.io\S+', url)[0] except IndexError: raise DirectDownloadLinkException("No Letsupload links found\n") return Bypass().bypass_url(link)
def anon(url: str) -> str: """ Anonfiles direct links generator based on https://github.com/breakdowns/slam-mirrorbot """ dl_url = '' try: link = re.findall(r'\bhttps?://.*anonfiles\.com\S+', url)[0] except IndexError: raise DirectDownloadLinkException("`No Anonfiles links found`\n") bypasser = lk21.Bypass() dl_url = bypasser.bypass_url(link) return dl_url
def letsupload(url: str) -> str: """ Letsupload direct link generator Based on https://github.com/breakdowns/slam-mirrorbot """ dl_url = '' try: link = re.findall(r'\bhttps?://.*letsupload\.io\S+', url)[0] except IndexError: raise DirectDownloadLinkException("No Letsupload links found\n") bypasser = lk21.Bypass() dl_url = bypasser.bypass_url(link) return dl_url
def pixeldrain(url: str) -> str: """ Based on https://github.com/yash-dk/TorToolkit-Telegram """ url = url.strip("/ ") file_id = url.split("/")[-1] info_link = f"https://pixeldrain.com/api/file/{file_id}/info" dl_link = f"https://pixeldrain.com/api/file/{file_id}" resp = requests.get(info_link).json() if resp["success"]: return dl_link else: raise DirectDownloadLinkException("ERROR: Cant't download due {}.".format(resp.text["value"]))
def direct_link_generator(link: str): """direct links generator""" if not link: raise DirectDownloadLinkException("`No links found!`") elif "zippyshare.com" in link: return zippy_share(link) elif "yadi.sk" in link: return yandex_disk(link) elif "cloud.mail.ru" in link: return cm_ru(link) elif "mediafire.com" in link: return mediafire(link) elif "osdn.net" in link: return osdn(link) elif "github.com" in link: return github(link) elif "racaty.net" in link: return racaty(link) else: raise DirectDownloadLinkException(f"No Direct link function found for {link}")
def androidfilehost(url: str) -> str: """ AFH direct links generator """ try: link = re.findall(r'\bhttps?://.*androidfilehost.*fid.*\S+', url)[0] except IndexError: raise DirectDownloadLinkException("`No AFH links found`\n") fid = re.findall(r'\?fid=(.*)', link)[0] session = requests.Session() user_agent = useragent() headers = {'user-agent': user_agent} res = session.get(link, headers=headers, allow_redirects=True) headers = { 'origin': 'https://androidfilehost.com', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': user_agent, 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'x-mod-sbb-ctype': 'xhr', 'accept': '*/*', 'referer': f'https://androidfilehost.com/?fid={fid}', 'authority': 'androidfilehost.com', 'x-requested-with': 'XMLHttpRequest', } data = { 'submit': 'submit', 'action': 'getdownloadmirrors', 'fid': f'{fid}' } error = "`Error: Can't find Mirrors for the link`\n" try: req = session.post( 'https://androidfilehost.com/libs/otf/mirrors.otf.php', headers=headers, data=data, cookies=res.cookies) mirrors = req.json()['MIRRORS'] except (json.decoder.JSONDecodeError, TypeError): raise DirectDownloadLinkException(error) if not mirrors: raise DirectDownloadLinkException(error) return mirrors[0]
def racaty(url: str) -> str: try: link = re.findall(r"\bhttps?://.*racaty\.net\S+", url)[0] except IndexError: raise DirectDownloadLinkException("`No Racaty links found`\n") reqs = requests.get(link) bss = BeautifulSoup(reqs.text, "html.parser") op = bss.find("input", {"name": "op"})["value"] id = bss.find("input", {"name": "id"})["value"] rep = requests.post(link, data={"op": op, "id": id}) bss2 = BeautifulSoup(rep.text, "html.parser") return bss2.find("a", {"id": "uniqueExpirylink"})["href"]
def krakenfiles(page_link: str) -> str: """ krakenfiles direct link generator Based on https://github.com/tha23rd/py-kraken By https://github.com/junedkh """ page_resp = requests.session().get(page_link) soup = BeautifulSoup(page_resp.text, "lxml") try: token = soup.find("input", id="dl-token")["value"] except: raise DirectDownloadLinkException(f"Page link is wrong: {page_link}") hashes = [ item["data-file-hash"] for item in soup.find_all("div", attrs={"data-file-hash": True}) ] if not hashes: raise DirectDownloadLinkException(f"Hash not found for : {page_link}") dl_hash = hashes[0] payload = f'------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name="token"\r\n\r\n{token}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--' headers = { "content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "cache-control": "no-cache", "hash": dl_hash, } dl_link_resp = requests.session().post( f"https://krakenfiles.com/download/{hash}", data=payload, headers=headers) dl_link_json = dl_link_resp.json() if "url" in dl_link_json: return dl_link_json["url"] else: raise DirectDownloadLinkException( f"Failed to acquire download URL from kraken for : {page_link}")
def gdtot(url: str) -> str: """ Gdtot google drive link generator By https://github.com/xcscxr """ if CRYPT is None: raise DirectDownloadLinkException("ERROR: CRYPT cookie not provided") match = re.findall(r'https?://(.+)\.gdtot\.(.+)\/\S+\/\S+', url)[0] with requests.Session() as client: client.cookies.update({'crypt': CRYPT}) res = client.get(url) res = client.get( f"https://{match[0]}.gdtot.{match[1]}/dld?id={url.split('/')[-1]}") matches = re.findall('gd=(.*?)&', res.text) try: decoded_id = b64decode(str(matches[0])).decode('utf-8') except: raise DirectDownloadLinkException( "ERROR: Try in your broswer, mostly file not found or user limit exceeded!" ) return f'https://drive.google.com/open?id={decoded_id}'