From 476105c82489290a1d9bacbb16aed2b8492006cb Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 12 Jan 2022 16:15:35 +0000 Subject: [PATCH] Fix BABS + cleanup anime-ultime --- .vscode/settings.json | 3 +++ commands/BABS.py | 2 +- commands/anime-ultime.py | 32 +++++++++++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d3def91 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": false +} diff --git a/commands/BABS.py b/commands/BABS.py index 40110ee..75c5b19 100755 --- a/commands/BABS.py +++ b/commands/BABS.py @@ -42,7 +42,7 @@ standalone_episode_regexs = [ '(.*?)( \(([0-9]+)\))?[Ss]([0-9]+)+[Ee]([0-9]+)(-[0-9]+[Xx]([0-9]+))?( - (.*))?' # standard s00e00 ] -season_regex = '.*?(?P[0-9]{1,2})+(?![^\(]*\))' # folder for a season +season_regex = '.*?(?P[0-9]{1,2})+(?![^\(\[]*[\)\]])' # folder for a season just_episode_regexs = [ '(?P[0-9]{1,3})[\. -_]*of[\. -_]*[0-9]{1,3}', # 01 of 08 diff --git a/commands/anime-ultime.py b/commands/anime-ultime.py index 4d7ca66..d79f8f7 100755 --- a/commands/anime-ultime.py +++ b/commands/anime-ultime.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 import argparse import re -import subprocess - import requests +import subprocess import sys import time @@ -17,26 +16,37 @@ root_url = 'http://www.anime-ultime.net' while nextHop: r1 = requests.get(url) - 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'}) + 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'} + ) timeout = 46 while timeout > 0: sys.stdout.write('\r') sys.stdout.flush() - sys.stdout.write('Veuillez attendre ' + str(timeout) + ' secondes') + sys.stdout.write('Waiting ' + str(timeout) + ' seconds ...') timeout = timeout - 1 time.sleep(1) - r2 = requests.post(root_url + '/ddl/authorized_download.php', - data={'idfile': m1.group(1), 'type': 'orig'}) + r2 = requests.post( + root_url + '/ddl/authorized_download.php', + data={'idfile': m1.group(1), 'type': 'orig'} + ) j = r2.json() - subprocess.call('wget -c -t 0 --content-disposition "' + root_url + j['link'] + '"', shell=True) + subprocess.call('wget -c -t 0 --content-disposition "' + + root_url + j['link'] + '"', shell=True) + if m2 is None: nextHop = False sys.stdout.write('\r') sys.stdout.flush() else: - url = root_url + '/' + m2.group(1) + '/' + m2.group(2) + '/' + m2.group(3) + url = root_url + '/' + \ + m2.group(1) + '/' + m2.group(2) + '/' + m2.group(3)