└── hubdrive_dl.py /hubdrive_dl.py: -------------------------------------------------------------------------------- 1 | import re 2 | import requests 3 | from urllib.parse import urlparse 4 | 5 | url = "" # hubdrive url 6 | 7 | crypt = "" # crypt cookie 8 | 9 | ''' 10 | NOTE: [UNSTABLE] Needs more exception handling -_- 11 | ''' 12 | 13 | # ================================== 14 | 15 | def parse_info(res): 16 | info_parsed = {} 17 | title = re.findall('>(.*?)<\/h4>', res.text)[0] 18 | info_chunks = re.findall('>(.*?)<\/td>', res.text) 19 | info_parsed['title'] = title 20 | for i in range(0, len(info_chunks), 2): 21 | info_parsed[info_chunks[i]] = info_chunks[i+1] 22 | return info_parsed 23 | 24 | def hubdrive_dl(url): 25 | client = requests.Session() 26 | client.cookies.update({'crypt': crypt}) 27 | 28 | res = client.get(url) 29 | info_parsed = parse_info(res) 30 | info_parsed['error'] = False 31 | 32 | up = urlparse(url) 33 | req_url = f"{up.scheme}://{up.netloc}/ajax.php?ajax=download" 34 | 35 | file_id = url.split('/')[-1] 36 | 37 | data = { 'id': file_id } 38 | 39 | headers = { 40 | 'x-requested-with': 'XMLHttpRequest' 41 | } 42 | 43 | try: 44 | res = client.post(req_url, headers=headers, data=data).json()['file'] 45 | except: return {'error': True, 'src_url': url} 46 | 47 | gd_id = re.findall('gd=(.*)', res, re.DOTALL)[0] 48 | 49 | info_parsed['gdrive_url'] = f"https://drive.google.com/open?id={gd_id}" 50 | info_parsed['src_url'] = url 51 | 52 | return info_parsed 53 | 54 | # ================================== 55 | 56 | print(hubdrive_dl(url)) 57 | --------------------------------------------------------------------------------