dl/commands/anime-ultime.py

53 lines
1.3 KiB
Python
Raw Normal View History

2021-05-13 15:26:05 +00:00
#!/usr/bin/env python3
import argparse
import re
import requests
2022-01-12 16:15:35 +00:00
import subprocess
2021-05-13 15:26:05 +00:00
import sys
import time
parser = argparse.ArgumentParser()
parser.add_argument('url', help="url from anime-ultime.net")
args = parser.parse_args()
nextHop = True
url = args.url
root_url = 'http://www.anime-ultime.net'
while nextHop:
r1 = requests.get(url)
2022-01-12 16:15:35 +00:00
m1 = re.search(
"javascript:open_ddlbox\('dl_orig', '([0-9]+)', 'orig'\)", r1.text
)
m2 = re.search(
'submit.*:right;.*(info-0-1)/([0-9]+)/([^"]+)', r1.text
)
requests.post(
root_url + '/ddl/authorized_download.php',
data={'idfile': m1.group(1), 'type': 'orig'}
)
2021-05-13 15:26:05 +00:00
timeout = 46
while timeout > 0:
sys.stdout.write('\r')
sys.stdout.flush()
2022-01-12 16:15:35 +00:00
sys.stdout.write('Waiting ' + str(timeout) + ' seconds ...')
2021-05-13 15:26:05 +00:00
timeout = timeout - 1
time.sleep(1)
2022-01-12 16:15:35 +00:00
r2 = requests.post(
root_url + '/ddl/authorized_download.php',
data={'idfile': m1.group(1), 'type': 'orig'}
)
2021-05-13 15:26:05 +00:00
j = r2.json()
2022-01-12 16:15:35 +00:00
subprocess.call('wget -c -t 0 --content-disposition "' +
root_url + j['link'] + '"', shell=True)
2021-05-13 15:26:05 +00:00
if m2 is None:
nextHop = False
sys.stdout.write('\r')
sys.stdout.flush()
else:
2022-01-12 16:15:35 +00:00
url = root_url + '/' + \
m2.group(1) + '/' + m2.group(2) + '/' + m2.group(3)