diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-08-21 14:36:01 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-08-21 14:36:01 +0200 |
commit | b0063175acc61ea09bb1e6db62263bc18908de78 (patch) | |
tree | e342dc9408b7ddf86c8737d7e1cd581f109f7a54 | |
parent | 03d49c498fb6e781dcb80e4e01ef81dab37b8cf6 (diff) |
Remove dead site: mangawindow
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | plugins/mangawindow.py | 129 |
2 files changed, 2 insertions, 131 deletions
@@ -1,5 +1,5 @@ # AutoMedia -Automatically track new releases of media and download them. Currently works with rss for torrent sites (`nyaa.si`) and a for these manga sites: `manganelo.com`, `manganelos.com`, `mangatown.com`, `mangakakalot.com`, `mangakatana.com`, `lhtranslation.net`, `mangawindow.net`, `readm.org`, `mangaplus.shueisha.co.jp` and `mangadex.org`. +Automatically track new releases of media and download them. Currently works with rss for torrent sites (`nyaa.si`) and a for these manga sites: `manganelo.com`, `manganelos.com`, `mangatown.com`, `mangakakalot.com`, `mangakatana.com`, `lhtranslation.net`, `readm.org`, `mangaplus.shueisha.co.jp` and `mangadex.org`. A notification is shown on the screen when a download finishes (if notify-send is installed). ## Installation @@ -23,4 +23,4 @@ dmenu, sxiv (for manga), mpv (for anime) Do not move files inside the download directory. If you want to move them, move the whole download directory when automedia is not running and then set the download directory to the new location when using sync command. # Dev info -titles of manga need to be stripped of spaces on both ends and replace all `/` with `_`.
\ No newline at end of file +titles of manga need to be stripped of spaces on both ends and replace all `/` with `_`. diff --git a/plugins/mangawindow.py b/plugins/mangawindow.py deleted file mode 100755 index 2ff950e..0000000 --- a/plugins/mangawindow.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python3 - -import os -import time -import sys -import requests -import json -import re - -from lxml import etree - -def usage(): - print("mangawindow.py command") - print("commands:") - print(" download") - print(" list") - exit(1) - -def usage_list(): - print("mangawindow.py list <url>") - exit(1) - -def usage_download(): - print("mangawindow.py download <url> <download_dir>") - print("examples:") - print(" mangawindow.py download \"https://mangawindow.net/chapter/1430298\" /home/adam/Manga/MangaName") - print("") - print("Note: The manga directory has to exist.") - exit(1) - -if len(sys.argv) < 2: - usage() - -def download_file(url, save_path): - with requests.get(url, stream=True) as response: - if not response.ok: - return False - with open(save_path, "wb") as file: - for chunk in response.iter_content(chunk_size=8192): - if chunk: - file.write(chunk) - return True - -def list_chapters(url, chapter_list_input): - response = requests.get(url) - if response.status_code != 200: - print("Failed to list chapters, server responded with status code %d" % response.status_code) - exit(2) - - seen_titles = set() - for item in chapter_list_input: - title = item.get("title") - if title and len(title) > 0: - seen_titles.add(title.lower().replace(" ", "").replace("/", "_")) - - seen_urls = set() - for item in chapter_list_input: - chapter_url = item.get("url") - if chapter_url and len(chapter_url) > 0: - seen_urls.add(chapter_url) - - tree = etree.HTML(response.text) - chapters = [] - for element in tree.xpath("//a[@class='chapt']"): - title = element.findtext('b') - if title is None: - print("Failed to get title for chapter") - exit(2) - title = title.strip().replace("/", "_") - url = "https://mangawindow.net" + element.attrib.get("href").strip() - if title.lower().replace(" ", "") in seen_titles or url in seen_urls: - break - chapters.append({ "name": title, "url": url }) - print(json.dumps(chapters)) - -def download_chapter(url, download_dir): - response = requests.get(url) - if response.status_code != 200: - print("Failed to list chapter images, server responded with status code %d" % response.status_code) - exit(2) - - in_progress_filepath = os.path.join(download_dir, ".in_progress") - with open(in_progress_filepath, "w") as file: - file.write(url) - - img_number = 1 - image_urls = re.findall(r'mangawindow\.net/images[^"]+', response.text) - for image_url in image_urls: - image_url = "https://z-img-04." + image_url - ext = image_url[image_url.rfind("."):] - image_name = str(img_number) + ext - image_path = os.path.join(download_dir, image_name) - print("Downloading {} to {}".format(image_url, image_path)) - if not download_file(image_url, image_path): - print("Failed to download image: %s" % image_url) - os.remove(in_progress_filepath) - exit(2) - img_number += 1 - - if img_number == 1: - print("Failed to find images for chapter") - os.remove(in_progress_filepath) - exit(2) - - with open(os.path.join(download_dir, ".finished"), "w") as file: - file.write("1") - - os.remove(in_progress_filepath) - -command = sys.argv[1] -if command == "list": - if len(sys.argv) < 3: - usage_list() - - url = sys.argv[2] - chapter_list_input = sys.stdin.read() - if len(chapter_list_input) == 0: - chapter_list_input = [] - else: - chapter_list_input = json.loads(chapter_list_input) - list_chapters(url, chapter_list_input) -elif command == "download": - if len(sys.argv) < 4: - usage_download() - url = sys.argv[2] - download_dir = sys.argv[3] - download_chapter(url, download_dir) -else: - usage() |