diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-08-25 23:40:09 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-08-25 23:40:09 +0200 |
commit | 8281c612b425709c33267623f4f29744b0c01896 (patch) | |
tree | d03c0617148fe6add6b735412f64c57368112a20 /plugins | |
parent | 8d921bf0faf884bdcc9eb11370ce5597e63ce58e (diff) |
Mangakatana: fix pages after website update
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/mangakatana.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/mangakatana.py b/plugins/mangakatana.py index 5a4ec1c..ef50db0 100755 --- a/plugins/mangakatana.py +++ b/plugins/mangakatana.py @@ -73,6 +73,18 @@ def list_chapters(url, chapter_list_input): print(json.dumps(chapters)) +def get_javascript_array_string(html_source, var_name): + sources_start = html_source.find(var_name + "=[") + if sources_start == -1: + return [] + + sources_start += len(var_name) + 2 + sources_end = html_source.find("]", sources_start) + if sources_end == -1: + return [] + + return html_source[sources_start:sources_end].replace("'", "").split(",") + def download_chapter(url, download_dir): response = requests.get(url, timeout=30) response.raise_for_status() @@ -82,20 +94,10 @@ def download_chapter(url, download_dir): file.write(url) response_text = response.text - sources_start = response_text.find("htnc=[") - if sources_start == -1: - print("Failed to find images for chapter") - os.remove(in_progress_filepath) - exit(2) - - sources_start += 6 - sources_end = response_text.find("]", sources_start) - if sources_end == -1: - print("Failed to find images for chapter") - os.remove(in_progress_filepath) - exit(2) + urls_ytaw = get_javascript_array_string(response_text, "ytaw") + urls_htnc = get_javascript_array_string(response_text, "htnc") + image_sources = urls_ytaw if len(urls_ytaw) >= len(urls_htnc) else urls_htnc - image_sources = response_text[sources_start:sources_end].replace("'", "").split(",") img_number = 1 for image_source in image_sources: image_source = image_source.strip() |