Skip to content

Commit a0932a9

Browse files
committed
minor change
Signed-off-by: anasty17 <e.anastayyar@gmail.com>
1 parent 30b3cc4 commit a0932a9

2 files changed

Lines changed: 40 additions & 25 deletions

File tree

bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0"
2424
)
2525

26+
2627
def direct_link_generator(link):
2728
"""direct links generator"""
2829
domain = urlparse(link).hostname
@@ -236,9 +237,10 @@ def buzzheavier(url):
236237
@param link: URL from buzzheavier
237238
@return: Direct download link
238239
"""
239-
pattern = r'^https?://buzzheavier\.com/[a-zA-Z0-9]+$'
240+
pattern = r"^https?://buzzheavier\.com/[a-zA-Z0-9]+$"
240241
if not match(pattern, url):
241242
return url
243+
242244
def _bhscraper(url, folder=False):
243245
session = Session()
244246
if "/download" not in url:
@@ -262,10 +264,12 @@ def _bhscraper(url, folder=False):
262264
return d_url
263265
except Exception as e:
264266
raise DirectDownloadLinkException(f"ERROR: {str(e)}") from e
265-
267+
266268
with Session() as session:
267269
tree = HTML(session.get(url).text)
268-
if link := tree.xpath("//a[contains(@class, 'link-button') and contains(@class, 'gay-button')]/@hx-get"):
270+
if link := tree.xpath(
271+
"//a[contains(@class, 'link-button') and contains(@class, 'gay-button')]/@hx-get"
272+
):
269273
return _bhscraper("https://buzzheavier.com" + link[0])
270274
elif folders := tree.xpath("//tbody[@id='tbody']/tr"):
271275
details = {"contents": [], "title": "", "total_size": 0}
@@ -279,8 +283,8 @@ def _bhscraper(url, folder=False):
279283
"path": "",
280284
"filename": filename,
281285
"url": url,
282-
}
283-
details["contents"].append(item)
286+
}
287+
details["contents"].append(item)
284288
size = speed_string_to_bytes(size)
285289
details["total_size"] += size
286290
except:
@@ -377,28 +381,33 @@ def devuploads(url):
377381
direct_link = html.xpath("//input[@name='orilink']/@value")
378382
return direct_link[0]
379383

384+
380385
def uploadhaven(url):
381386
"""
382387
Generate a direct download link for uploadhaven.com URLs.
383388
@param url: URL from uploadhaven.com
384389
@return: Direct download link
385390
"""
386391
try:
387-
res = get(url,headers={'Referer':'http://steamunlocked.net/'})
392+
res = get(url, headers={"Referer": "http://steamunlocked.net/"})
388393
html = HTML(res.text)
389394
if not html.xpath('//form[@method="POST"]//input'):
390-
raise DirectDownloadLinkException("ERROR: Unable to find link data")
391-
data = {i.get("name"): i.get("value") for i in html.xpath('//form[@method="POST"]//input')}
395+
raise DirectDownloadLinkException("ERROR: Unable to find link data")
396+
data = {
397+
i.get("name"): i.get("value")
398+
for i in html.xpath('//form[@method="POST"]//input')
399+
}
392400
sleep(15)
393-
res = post(url, data=data, headers={'Referer': url}, cookies=res.cookies)
401+
res = post(url, data=data, headers={"Referer": url}, cookies=res.cookies)
394402
html = HTML(res.text)
395403
if not html.xpath('//div[@class="alert alert-success mb-0"]//a'):
396404
raise DirectDownloadLinkException("ERROR: Unable to find link data")
397405
a = html.xpath('//div[@class="alert alert-success mb-0"]//a')[0]
398-
return a.get('href')
406+
return a.get("href")
399407
except Exception as e:
400408
raise DirectDownloadLinkException(f"ERROR: {str(e)}") from e
401409

410+
402411
def mediafile(url):
403412
"""
404413
Generate a direct download link for mediafile.cc URLs.
@@ -409,20 +418,27 @@ def mediafile(url):
409418
res = get(url, allow_redirects=True)
410419
match = search(r"href='([^']+)'", res.text)
411420
if not match:
412-
raise DirectDownloadLinkException("ERROR: Unable to find link data")
421+
raise DirectDownloadLinkException("ERROR: Unable to find link data")
413422
download_url = match.group(1)
414423
sleep(60)
415-
res = get(download_url, headers={'Referer': url}, cookies=res.cookies)
416-
postvalue = search(r'showFileInformation(.*);', res.text)
424+
res = get(download_url, headers={"Referer": url}, cookies=res.cookies)
425+
postvalue = search(r"showFileInformation(.*);", res.text)
417426
if not postvalue:
418-
raise DirectDownloadLinkException("ERROR: Unable to find post value")
419-
postid = postvalue.group(1).replace('(','').replace(')','')
420-
response = post('https://mediafile.cc/account/ajax/file_details',data={"u": postid}, headers={"X-Requested-With": "XMLHttpRequest"})
421-
html = response.json()['html']
422-
return [i for i in findall(r'https://[^\s"\']+', html) if 'download_token' in i][1]
427+
raise DirectDownloadLinkException("ERROR: Unable to find post value")
428+
postid = postvalue.group(1).replace("(", "").replace(")", "")
429+
response = post(
430+
"https://mediafile.cc/account/ajax/file_details",
431+
data={"u": postid},
432+
headers={"X-Requested-With": "XMLHttpRequest"},
433+
)
434+
html = response.json()["html"]
435+
return [
436+
i for i in findall(r'https://[^\s"\']+', html) if "download_token" in i
437+
][1]
423438
except Exception as e:
424439
raise DirectDownloadLinkException(f"ERROR: {str(e)}") from e
425440

441+
426442
def mediafire(url, session=None):
427443
if "/folder/" in url:
428444
return mediafireFolder(url)
@@ -779,7 +795,7 @@ def terabox(url):
779795
"path": "",
780796
"filename": data["📂 Title"],
781797
"url": data["🔽 Direct Download Link"],
782-
}
798+
}
783799
details["contents"].append(item)
784800
size = (data["📏 Size"]).replace(" ", "")
785801
size = speed_string_to_bytes(size)
@@ -794,7 +810,7 @@ def terabox(url):
794810

795811
def filepress(url):
796812
try:
797-
url = get(f"https://filebee.xyz/file/{url.split('/')[-1]}").url
813+
url = get(f"https://filebee.xyz/file/{url.split('/')[-1]}").url
798814
raw = urlparse(url)
799815
json_data = {
800816
"id": raw.path.split("/")[-1],

bot/helper/mirror_leech_utils/rclone_utils/transfer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async def _progress(self):
7979
self._speed,
8080
self._eta,
8181
) = data[0]
82-
await sleep(0.05)
82+
await sleep(0.5)
8383

8484
def _switch_service_account(self):
8585
if self._sa_index == self._sa_number - 1:
@@ -310,17 +310,16 @@ async def upload(self, path):
310310
fremote = f"sa{self._sa_index:03}"
311311
LOGGER.info(f"Upload with service account {fremote}")
312312

313-
method = "move"
314313
cmd = self._get_updated_command(
315-
fconfig_path, path, f"{fremote}:{rc_path}", method
314+
fconfig_path, path, f"{fremote}:{rc_path}", "move"
316315
)
317316
if remote_type == "drive" and not self._listener.rc_flags:
318317
cmd.extend(
319318
(
320319
"--drive-chunk-size",
321-
"128M",
320+
"64M",
322321
"--drive-upload-cutoff",
323-
"128M",
322+
"64M",
324323
"--tpslimit",
325324
"1",
326325
"--tpslimit-burst",

0 commit comments

Comments
 (0)