diff options
| author | Fuwn <[email protected]> | 2023-07-26 19:44:05 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-07-26 19:44:05 -0700 |
| commit | 29691c1b7149014b62f3e2fe3cafa32148191260 (patch) | |
| tree | 8514ab86640385ca649081cb2f268cd0e76a9997 /src | |
| parent | fix(html): chapter over track not due (diff) | |
| download | old.due.moe-29691c1b7149014b62f3e2fe3cafa32148191260.tar.xz old.due.moe-29691c1b7149014b62f3e2fe3cafa32148191260.zip | |
feat(html): sort by available
Diffstat (limited to 'src')
| -rw-r--r-- | src/due/html.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/due/html.py b/src/due/html.py index eed686e..7bd32ed 100644 --- a/src/due/html.py +++ b/src/due/html.py @@ -7,11 +7,21 @@ import re import os -def seen(element): - match = re.search(r"\s(\d+)\s", element) +def seen(element, manga=False): + matches = re.findall(r"\d+\]|\[\d+", element) - if match: - return int(match.group(1)) + if manga: + matches = re.search(r"\[<a.*?>(\d+)<\/a>\]", element) + + if matches: + return int(matches.group(1)) + else: + return 0 + + if len(matches) > 1: + return int(matches[1].strip("[]")) + elif len(matches) == 1: + return int(matches[0].strip("[]")) else: return 0 @@ -189,7 +199,7 @@ def manga_to_html(releasing_outdated_manga, show_missing): joblib.delayed(process)(media) for media in releasing_outdated_manga ) - current_html = sorted(current_html, key=seen, reverse=True) + current_html = sorted(current_html, key=lambda x: seen(x, manga=True), reverse=True) current_html.insert(0, "<ul>") current_html.append("</ul>") |