├── .gitignore ├── screenshot.gif ├── requirements.txt ├── mangadex_dl ├── __main__.py ├── __init__.py ├── instance.py ├── parse.py ├── duplicate.py ├── console.py ├── archive.py ├── download.py ├── utils.py └── gui.py ├── start.py ├── config.toml ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | mangadex_dl/__pycache__/ -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uwuewsky/mangadex-dl/HEAD/screenshot.gif -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests[socks]>=2.28.1 2 | PyMuPDF>=1.25.4 3 | natsort>=8.4.0 4 | tomlkit>=0.13.2 5 | -------------------------------------------------------------------------------- /mangadex_dl/__main__.py: -------------------------------------------------------------------------------- 1 | if __name__ == "__main__": 2 | from mangadex_dl.instance import init 3 | init() 4 | -------------------------------------------------------------------------------- /start.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | if __name__ == "__main__": 4 | from mangadex_dl.instance import init 5 | init() 6 | -------------------------------------------------------------------------------- /mangadex_dl/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.8.0" 2 | __all__ = [ 3 | "instance", "utils", "archive", "download", "duplicate", "parse", "console", "gui" 4 | ] 5 | -------------------------------------------------------------------------------- /config.toml: -------------------------------------------------------------------------------- 1 | ### DEFAULT 2 | # language = "en" # Search for manga in a specified language. (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) 3 | # outdir = "." # Output directory for downloading chapters. Use "/" slash. 4 | # download = false # Download range (see Readme). [ "all" | | false ] 5 | # archive = false # How to archive manga in file. [ "manga" | "volume" | "chapter" | false ] 6 | # ext = "zip" # Archive format/extension. [ "zip" | "cbz" | "pdf" ] 7 | # keep = false # Don't delete original images after archiving. [ true | false ] 8 | # datasaver = false # Download images in lower quality. [ true | false ] 9 | # resolve = "one" # How to display duplicate chapters. [ "all" | "one" | "manual" ] 10 | # gui = true # Runs a program in GUI mode. [ true | false ] 11 | # proxy = false # HTTP/S proxy. [ "user:pass@host:port" | false ] 12 | # socks = false # Socks5 proxy. [ "user:pass@host:port" | false ] 13 | 14 | language = "en" 15 | outdir = "." 16 | download = false 17 | archive = false 18 | ext = "zip" 19 | keep = false 20 | datasaver = false 21 | resolve = "all" 22 | gui = true 23 | 24 | proxy = false 25 | socks = false -------------------------------------------------------------------------------- /mangadex_dl/instance.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: instance.py 3 | """ 4 | 5 | import argparse 6 | import tomllib 7 | import logging 8 | from pathlib import Path 9 | from types import SimpleNamespace 10 | 11 | from requests import Session 12 | 13 | SESSION = Session() 14 | 15 | 16 | def init(): 17 | """Initialize mangadex_dl.""" 18 | 19 | logging.basicConfig(format="[%(levelname)s] (%(filename)s): %(message)s") 20 | config_file = Path("config.toml") 21 | 22 | args_cfg = _parse_config(config_file) 23 | args_cmd = _parse_args() 24 | args_cfg.update(args_cmd) 25 | 26 | args = SimpleNamespace(**args_cfg) 27 | args.outdir = Path(args.outdir).absolute() 28 | 29 | if args.proxy: 30 | SESSION.proxies = { 31 | "http": f"http://{args.proxy}", 32 | "https": f"https://{args.proxy}" 33 | } 34 | elif args.socks: 35 | SESSION.proxies = { 36 | "http": f"socks5://{args.socks}", 37 | "https": f"socks5://{args.socks}" 38 | } 39 | 40 | if args.archive_mode: 41 | from mangadex_dl.archive import init_archive_mode 42 | init_archive_mode(args) 43 | elif args.gui: 44 | from mangadex_dl.gui import init_gui 45 | init_gui(args) 46 | else: 47 | from mangadex_dl.console import init_console 48 | init_console(args) 49 | 50 | 51 | def _parse_config(path): 52 | "Return config file args." 53 | 54 | data = {} 55 | 56 | try: 57 | with open(path, "rb") as f: 58 | data = tomllib.load(f) 59 | except FileNotFoundError: 60 | logging.warning(f"Config file not found: {path.absolute()}") 61 | 62 | return data 63 | 64 | 65 | def _parse_args(): 66 | """Return command-line args.""" 67 | 68 | p = argparse.ArgumentParser() 69 | 70 | p.add_argument("manga_urls", metavar="", nargs="*", 71 | help="specify manga url") 72 | p.add_argument("-a", "--archive-mode", action="store_true", 73 | help="archiving mode") 74 | 75 | return vars(p.parse_args()) 76 | -------------------------------------------------------------------------------- /mangadex_dl/parse.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: parse.py 3 | Parse command-line user input for requested chapters and return a list of them. 4 | """ 5 | 6 | import re 7 | 8 | def parse_range(range_input): 9 | """ 10 | Parse user input in console mode. 11 | """ 12 | range_list = [] 13 | 14 | if range_input == "all": 15 | return "all" 16 | 17 | # split the input string into separate ranges 18 | # ["v1", "v2(1)-v6(8)", ...] 19 | entry_input_list = range_input.split(",") 20 | 21 | # define a start and end point for each range 22 | for entry_input in entry_input_list: 23 | range_object = _parse_entry_input(entry_input) 24 | range_list.append(range_object) 25 | return range_list 26 | 27 | def get_requested_chapters(chapters_list, dl_list): 28 | if dl_list == "all": 29 | return chapters_list 30 | 31 | requested_chapters = [] 32 | for dl_range in dl_list: 33 | requested_chapters += _get_chapters_from_range(chapters_list, dl_range) 34 | 35 | if len(requested_chapters) == 0: 36 | raise ValueError("Empty list of chapters. "\ 37 | "Make sure you enter the correct download range!") 38 | 39 | return requested_chapters 40 | 41 | def _parse_entry_input(entry_input): 42 | range_object = {"start": {"volume": None, "chapter": None}, 43 | "end": {"volume": None, "chapter": None}} 44 | 45 | # "v1(1)-v2(3)" --> ["v1(1)", "v2(3)"] 46 | entry_list = entry_input.split("-") 47 | re_range = r"v(?Pu|\d+)(?:\((?POneshot|\d+.?(?:\d+)?)\))?" 48 | 49 | # compose a range object from points 50 | point = "start" # first write to range_object["start"] 51 | for entry in entry_list: 52 | if entry == "": 53 | break 54 | # parse volume number 55 | entry_re = re.search(re_range, entry) 56 | range_object[point]["volume"] = entry_re.group("volume") 57 | range_object[point]["chapter"] = entry_re.group("chapter") 58 | 59 | point = "end" # switch to range_object["end"] 60 | 61 | # set end point 62 | if not range_object["end"]["volume"]: 63 | range_object["end"] = range_object["start"] 64 | elif not range_object["end"]["chapter"]: 65 | range_object["end"]["chapter"] = range_object["start"]["chapter"] 66 | 67 | return range_object 68 | 69 | def _get_chapters_from_range(chapters_list, dl_range): 70 | requested_chapters = [] 71 | 72 | is_in_range = False # flag to add chapters 73 | 74 | chapter_last = None # flag to add last chapter 75 | volume_last = None # flag to add last volume 76 | 77 | for chapter in chapters_list: 78 | chapter_volume = chapter["attributes"]["volume"] 79 | chapter_name = chapter["attributes"]["chapter"] or "Oneshot" 80 | 81 | # if it was the last volume or chapter 82 | if (volume_last and chapter_volume != volume_last) or \ 83 | (chapter_last and chapter_name != chapter_last): 84 | break 85 | 86 | if not is_in_range: 87 | # range start point check 88 | # if current volume name matches start volume name 89 | if (not chapter_volume and dl_range["start"]["volume"] == "u")\ 90 | or (chapter_volume == dl_range["start"]["volume"]): 91 | 92 | # if the current chapter name is 93 | # same as the target chapter name 94 | # or if no target chapter is specified 95 | if chapter_name == dl_range["start"]["chapter"]\ 96 | or not dl_range["start"]["chapter"]: 97 | 98 | # mark this and subsequent chapters for addition 99 | is_in_range = True 100 | 101 | if is_in_range: 102 | # range end point check 103 | # if the current volume name is same as the target volume name 104 | # or if no target volume is specified 105 | if (not chapter_volume and dl_range["end"]["volume"] == "u")\ 106 | or (chapter_volume == dl_range["end"]["volume"]): 107 | 108 | # this volume is the last 109 | volume_last = chapter_volume 110 | 111 | # if the current chapter name 112 | # same as the target chapter name 113 | if chapter_name == dl_range["end"]["chapter"]: 114 | chapter_last = chapter_name 115 | 116 | requested_chapters.append(chapter) 117 | 118 | return requested_chapters 119 | -------------------------------------------------------------------------------- /mangadex_dl/duplicate.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: duplicate.py 3 | Sometimes chapters are duplicated by several scanlate groups, 4 | these functions allow you to filter out unnecessary ones. 5 | """ 6 | 7 | from functools import lru_cache 8 | 9 | import mangadex_dl.download as dl 10 | 11 | 12 | def resolve_duplicated_chapters(chapters_list, 13 | resolve, 14 | resolve_manual_function): 15 | """ 16 | Returns a list of chapters based on the given argument 'resolve'. 17 | 'resolve_manual_function' is required to manually specify 18 | the priority of groups in the console or in the GUI. 19 | """ 20 | if resolve == "all": 21 | return chapters_list 22 | 23 | duplicates_list = get_duplicated_chapters(chapters_list) 24 | if len(duplicates_list) == 0: 25 | return chapters_list 26 | 27 | if resolve == "one": 28 | for duplicates_set in duplicates_list: 29 | first = True 30 | for duplicate in duplicates_set: 31 | if first: 32 | first = False 33 | else: 34 | if duplicate in chapters_list: 35 | chapters_list.remove(duplicate) 36 | 37 | return chapters_list 38 | 39 | # manually set scanlate groups priority 40 | print("Receiving scanlate groups info...") 41 | scanlation_groups = get_scanlation_groups_from_duplicates(duplicates_list) 42 | print(f"Duplicated chapters have {len(scanlation_groups)} scanlate groups") 43 | 44 | if len(scanlation_groups) == 0: 45 | return 46 | 47 | return resolve_manual_function(chapters_list, 48 | duplicates_list, 49 | scanlation_groups) 50 | 51 | 52 | def get_duplicated_chapters(chapters_list): 53 | """ 54 | Return a nested list of duplicates like: 55 | [[chap1_1, chap1_2], [chap2_1, chap2_2, chap2_3]...] 56 | """ 57 | duplicates_list = [] 58 | duplicates_dict = {} 59 | 60 | for chapter in chapters_list: 61 | index = f"{chapter['attributes']['volume']}-{chapter['attributes']['chapter']}" 62 | 63 | if index not in duplicates_dict: 64 | duplicates_dict[index] = [] 65 | 66 | duplicates_dict[index].append(chapter) 67 | 68 | for v in duplicates_dict.values(): 69 | if len(v) > 1: 70 | duplicates_list.append(v) 71 | 72 | return duplicates_list 73 | 74 | 75 | def get_scanlation_groups_from_duplicates(duplicates_list): 76 | scanlation_groups_id = set() 77 | scanlation_groups = [] 78 | 79 | for duplicates_set in duplicates_list: 80 | for duplicate in duplicates_set: 81 | group_id = get_chapter_scanlation_id(duplicate) 82 | if group_id: 83 | scanlation_groups_id.add(group_id) 84 | 85 | for group_id in scanlation_groups_id: 86 | scanlation_groups.append(get_scanlation_group_info(group_id)) 87 | 88 | return scanlation_groups 89 | 90 | 91 | def resolve_scanlate_priority_function(chapters_list, 92 | duplicates_list, 93 | scanlation_groups): 94 | """ 95 | Filter out duplicate chapters from low priority groups 96 | in favor of higher priority groups. 97 | Note: Every group in list should have ['priority'] parameter. 98 | It should be insert manually in resolve_manual_function. 99 | The function also inserts the JSON scanlate group name 100 | and priority into each duplicated chapter. 101 | """ 102 | scanlation_groups.sort(key=lambda x: x["priority"]) 103 | 104 | for duplicates_set in duplicates_list: 105 | prior_chapter = None 106 | 107 | for duplicate in duplicates_set: 108 | duplicate_group_id = get_chapter_scanlation_id(duplicate) 109 | 110 | for group in scanlation_groups: 111 | if duplicate_group_id == group["id"]: 112 | duplicate["scanlate-name"] = group["attributes"]["name"] 113 | duplicate["scanlate-priority"] = group["priority"] 114 | 115 | if not prior_chapter: 116 | prior_chapter = duplicate 117 | 118 | elif prior_chapter["scanlate-priority"] > duplicate["scanlate-priority"]: 119 | if prior_chapter in chapters_list: 120 | chapters_list.remove(prior_chapter) 121 | prior_chapter = duplicate 122 | 123 | for duplicate in duplicates_set: 124 | if duplicate != prior_chapter and duplicate in chapters_list: 125 | chapters_list.remove(duplicate) 126 | 127 | return chapters_list 128 | 129 | 130 | def get_chapter_scanlation_id(chapter): 131 | for relation in chapter["relationships"]: 132 | if relation["type"] == "scanlation_group": 133 | return relation["id"] 134 | 135 | 136 | @lru_cache(maxsize=16) 137 | def get_scanlation_group_info(group_id): 138 | return dl.get_json(f"https://api.mangadex.org/group/{group_id}")["data"] 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Screenshot](screenshot.gif) 2 | 3 | # mangadex-dl 4 | A Python package to download manga from [MangaDex.org](https://mangadex.org/). 5 | 6 | ## Requirements 7 | * [Python 3.11+](https://www.python.org/downloads/) 8 | * [requests\[socks\] 2.28+](https://pypi.org/project/requests/) 9 | * [PyMuPDF 1.25+](https://pypi.org/project/PyMuPDF/) 10 | * [natsort 8.4+](https://pypi.org/project/natsort/) 11 | * [tomlkit 0.13+](https://pypi.org/project/tomlkit/) 12 | 13 | ## Installation & usage 14 | ```bash 15 | $ git clone https://github.com/Uwuewsky/mangadex-dl 16 | $ cd mangadex-dl/ 17 | $ pip install -r requirements.txt 18 | $ ./start.py 19 | # or 20 | $ python3 -m mangadex_dl [manga_urls] 21 | ``` 22 | 23 | ## Features 24 | 25 | ### Download manga from MangaDex.org 26 | Search for manga by title or by UUID. 27 | 28 | ### Configuration 29 | You can configure the default settings via `config.toml` or via the GUI. 30 | 31 | ### Archiving to ZIP, CBZ or PDF 32 | Your downloaded manga is stored as individual images, but you can optionally make an archive or PDF document after downloading. Specify in the settings in what form you want to archive (individual chapters, individual volumes or the whole manga). Also specify the format/extension (zip, cbz, pdf). A table of contents is also created for PDF. 33 | 34 | The archiving function can be used via `-a` argument: `$ python -m mangadex_dl -a dir1/ dir2/ ...`. The path should be the root directory of the manga, i.e. not the path to an volume or chapter. 35 | 36 | *Note*: this function archives the entire manga directory, not just the chapters you downloaded in this session. Specify a different output directory in the settings before downloading if you don't need it. 37 | 38 | ### Download chapters from a specific scanlate group 39 | If the same chapter is uploaded by multiple groups, you can download all available chapters, download only one version, or manually filter the groups based on priority. Set the desired group to the highest priority, and the chapter from that group will be downloaded if possible. 40 | 41 | ### GUI and console mode 42 | By default, mangadex_dl opens in GUI mode. Set `gui = false` in `config.toml` to open in console mode, which together with `download = all` can be useful for non-interactive downloads. Manga links can be specified as `$ python -m mangadex_dl url1 url2 ...` or via the file `$ python -m mangadex_dl < list.txt`, where `list.txt` contains the URL/UUID on a separate line. 43 | 44 | ## Example usage 45 | 46 | ### Console version: 47 | 48 | Here are some examples of valid downloading range input: 49 | * `v1`: Download all volume 1; 50 | * `v1(3)`: Download chapter 3 from volume 1; 51 | * `v1-v5`: Download volumes 1-5; 52 | * `v1(3)-v5`: Download from chapter 3 to volume 5; 53 | * `v1(3)-v5(66)`: Download from chapter 3 to chapter 66; 54 | * `v1,v4-v5,v8(99)`: Can be combined with a comma; 55 | * `vu`: Some chapters do not have a volume. Therefore, they appear in vu (Volume Unknown); 56 | * `vu(Oneshot)`: Download oneshot; 57 | * `all`: Download whole manga. 58 | 59 | Also some examples of INVALID input: 60 | * `1,2,3`: Obsolete format; 61 | * `v1(1,2,3-6)`: You cannot specify more than one chapter in parentheses, use the example above. 62 | 63 | ``` 64 | $ python3 -m mangadex_dl 65 | 66 | Enter URL or text to search by title. (leave blank to complete) 67 | > yotsuba 68 | 69 | Enter URL or text to search by title. (leave blank to complete) 70 | > 71 | 72 | Receiving manga's info... 73 | The following titles were found on request: 74 | 1. Yotsuba&! (2003) by Azuma Kiyohiko 75 | 2. Mahouka Koukou no Rettousei - Yotsuba Keishou-hen (2020) by Satou Tsutomu 76 | 3. Try! Try! Try! (2001) by Azuma Kiyohiko 77 | 4. Kimi ni, Yotsuba (2018) by Akino Kabocha 78 | 79 | Insert number (leave blank to cancel): 80 | > 1 81 | 82 | [ 1/ 1] TITLE: Yotsuba&! 83 | 84 | Available chapters: (total 119) 85 | Volume 1 : 1 2 3 4 5 6 7 86 | Volume 2 : 8 9 10 11 12 13 14 87 | Volume 3 : 15 16 17 18 19 20 21 88 | Volume 4 : 22 23 24 25 26 27 27.5 89 | Volume 5 : 28 29 30 31 32 33 34 90 | Volume 6 : 35 36 37 38 39 40 41 91 | Volume 7 : 42 43 44 45 46 47 48 92 | Volume 8 : 49 50 51 52 53 54 54.2 55 93 | Volume 9 : 56 57 58 59 60 61 62 94 | Volume 10: 63 64 65 66 67 68 69 69.2 95 | Volume 11: 70 71 72 73 74 75 76 96 | Volume 12: 77 78 79 79.2 80 81 81.2 81.3 82 97 | Volume 13: 83 84 85 86 87 88 89 90 98 | Volume 14: 91 92 93 94 95 96 97 99 | Volume 15: 98 99 100 100.2 101 101.2 102 102.2 103 104 104.2 100 | Volume Unknown: 105 106 107 108 109 101 | 102 | Enter chapters to download: 103 | (see README for examples of valid format) (leave blank to cancel) 104 | > v15(103)-v15(104.2) 105 | 106 | Downloading chapter [ 3/ 3] Ch.104.2 Yotsuba & Backpacks (part 2) 107 | Downloaded images [ 32/ 32]... 108 | Chapters download completed successfully 109 | 110 | Archive downloaded chapters... 111 | Archiving [ 3/ 3]... 112 | Archiving completed successfully 113 | 114 | Manga "Yotsuba&!" was successfully downloaded 115 | ``` 116 | 117 | ## License 118 | [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html) 119 | -------------------------------------------------------------------------------- /mangadex_dl/console.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: console.py 3 | Initializes the console version. 4 | """ 5 | 6 | import traceback 7 | 8 | from mangadex_dl import utils 9 | from mangadex_dl import parse 10 | from mangadex_dl import archive as ar 11 | from mangadex_dl import download as dl 12 | from mangadex_dl import duplicate as dup 13 | 14 | 15 | def init_console(args): 16 | # input urls if they are not given by command line option 17 | if not args.manga_urls: 18 | while True: 19 | try: 20 | manga_input = input("\nEnter URL or text to search " 21 | "by title. (leave blank to complete)\n> ") 22 | except EOFError: 23 | break 24 | if not manga_input: 25 | break 26 | args.manga_urls.append(manga_input) 27 | 28 | # download manga from list 29 | for manga_url in args.manga_urls: 30 | try: 31 | _dl_console(manga_url, args) 32 | except Exception: 33 | print("{}\nSkip download.".format(traceback.format_exc())) 34 | 35 | 36 | def _dl_console(manga_url, args): 37 | print("\nReceiving manga's info...") 38 | manga_info = _search_manga_info(manga_url, args.language) 39 | 40 | print("\n[{:2}/{:2}] TITLE: {}\n".format( 41 | args.manga_urls.index(manga_url)+1, 42 | len(args.manga_urls), manga_info.title)) 43 | 44 | # get available chapters 45 | chapters_list = utils.get_chapters_list(manga_info.uuid, args.language) 46 | 47 | # duplicate check 48 | chapters_list = dup.resolve_duplicated_chapters(chapters_list, 49 | args.resolve, 50 | _resolve_duplicates_manual_console) 51 | 52 | # print chapters list 53 | _print_available_chapters(chapters_list) 54 | 55 | # i/o for chapters to download 56 | if not args.download: 57 | dl_input = input("\nEnter chapters to download:" 58 | "\n(see README for examples of valid format) " 59 | "(leave blank to cancel)" 60 | "\n> ") 61 | if dl_input == "": 62 | return 63 | else: 64 | dl_input = args.download 65 | 66 | dl_list = parse.parse_range(dl_input) 67 | 68 | # requested chapters list in dl_range 69 | requested_chapters = parse.get_requested_chapters(chapters_list, dl_list) 70 | 71 | # download images 72 | manga_directory = utils.create_manga_directory(args.outdir, 73 | manga_info.title_en, 74 | manga_info.uuid) 75 | 76 | dl.download_chapters(requested_chapters, manga_directory, args.datasaver) 77 | print("\nChapters downloaded successfully") 78 | 79 | # archive 80 | if args.archive: 81 | print("\nArchiving downloaded chapters...") 82 | ar.archive_manga(manga_directory, args.archive, args.keep, args.ext) 83 | print("\nArchiving completed successfully") 84 | 85 | print(f"\nManga \"{manga_info.title}\" was successfully downloaded") 86 | 87 | 88 | def _search_manga_info(manga_url, language): 89 | 90 | if utils.get_uuid(manga_url): 91 | manga_info = utils.get_manga_info(manga_url, language) 92 | return manga_info 93 | 94 | manga_list_found = utils.search_manga(manga_url, language) 95 | 96 | if len(manga_list_found) == 0: 97 | raise ValueError("Nothing was found according to your request") 98 | if len(manga_list_found) == 1: 99 | return manga_list_found[0] 100 | 101 | _print_found_manga_list(manga_list_found) 102 | 103 | user_input = input("Enter a number (leave blank to cancel):\n> ") 104 | 105 | if user_input == "": 106 | raise ValueError("Canceled by user") 107 | 108 | return manga_list_found[int(user_input)-1] 109 | 110 | 111 | def _print_found_manga_list(manga_list): 112 | print("The following titles were found on request:") 113 | for i, manga in enumerate(manga_list, start=1): 114 | print("{:2}. {} ({}) by {}".format( 115 | i, manga.title, manga.year, ", ".join(manga.authors))) 116 | 117 | 118 | def _print_available_chapters(chapters_list): 119 | 120 | print(f"Available chapters: (total {len(chapters_list)})", end="") 121 | 122 | volume_number = None 123 | for chapter in chapters_list: 124 | chapter_volume = chapter["attributes"]["volume"] or "Unknown" 125 | chapter_name = chapter["attributes"]["chapter"] or "Oneshot" 126 | 127 | if volume_number != chapter_volume: 128 | volume_number = chapter_volume 129 | print(f"\nVolume {volume_number:2}: ", end="") 130 | 131 | print(f"{chapter_name:>6}", end="") 132 | print() 133 | 134 | 135 | def _resolve_duplicates_manual_console(chapters_list, 136 | duplicates_list, 137 | scanlation_groups): 138 | for group in scanlation_groups: 139 | group_priority = input("Specify priority for " 140 | f"{group['attributes']['name']}. " 141 | "[1-5], highest is 1.\n> ") 142 | group["priority"] = group_priority 143 | print("Groups are prioritized\n") 144 | 145 | chapters_list = dup.resolve_scanlate_priority_function(chapters_list, 146 | duplicates_list, 147 | scanlation_groups) 148 | 149 | return chapters_list 150 | -------------------------------------------------------------------------------- /mangadex_dl/archive.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: archive.py 3 | Functions for archiving the manga directory. 4 | """ 5 | 6 | import shutil 7 | import zipfile 8 | from pathlib import Path 9 | 10 | import pymupdf 11 | from natsort import natsorted 12 | 13 | 14 | def init_archive_mode(args): 15 | """Archiving mode for specified paths""" 16 | print(f"Mode: {args.archive} | " 17 | f"Format: {args.ext} | " 18 | f"Keep original files: {args.keep}") 19 | 20 | if not args.archive: 21 | print("Select the archiving mode:\n" 22 | " 1. Whole manga\n" 23 | " 2. By volumes\n" 24 | " 3. By chapters") 25 | t = int(input("> ")) - 1 26 | args.archive = ["manga", "volume", "chapter"][t] 27 | print(args.archive) 28 | 29 | if not args.manga_urls: 30 | print("Paste the absolute path to the manga directory:\n" 31 | "(leave blank to complete)") 32 | while True: 33 | t = input("> ") 34 | if not t: 35 | break 36 | args.manga_urls.append(t) 37 | 38 | for url in args.manga_urls: 39 | d = Path(url) 40 | if not d.is_dir(): 41 | print(f"'{d}' is not directory. Skipped.") 42 | continue 43 | archive_manga(d, args.archive, args.keep, args.ext) 44 | 45 | print("\nArchived successfully!") 46 | 47 | 48 | def archive_manga(manga_dir: Path, archive_mode: str, is_keep: bool, ext: str, 49 | gui: dict = {}) -> None: 50 | 51 | dir_list = _find_directories(manga_dir, archive_mode, ext) 52 | 53 | dir_archived = 0 54 | dir_max = len(dir_list) 55 | 56 | if dir_max == 0: 57 | print("Looks like there is nothing to archive.", end="", flush=True) 58 | return 59 | 60 | for directory in dir_list: 61 | _archive_directory(directory, ext, archive_mode, is_keep) 62 | dir_archived += 1 63 | 64 | if gui.get("set"): 65 | gui["progress_chapter"].set( 66 | (dir_archived/dir_max)*100) 67 | gui["progress_chapter_text"].set( 68 | f"[ {dir_archived} / {dir_max} ]") 69 | else: 70 | print(f"\r Archiving [{dir_archived:3}/{dir_max:3}]...", end="") 71 | 72 | 73 | def _archive_directory(directory: Path, ext: str, archive_mode: str, 74 | is_keep: bool = True) -> None: 75 | arc_name = directory.with_suffix(directory.suffix + f".{ext}") 76 | 77 | if ext == "pdf": 78 | _pdf_dir(arc_name, directory, archive_mode) 79 | else: 80 | _zip_dir(arc_name, directory) 81 | 82 | if not is_keep: 83 | shutil.rmtree(directory) 84 | 85 | 86 | def _pdf_dir(arc_name: str, directory: Path, archive_mode: str) -> None: 87 | doc = pymupdf.open() 88 | toc = [] # table of content 89 | 90 | page_num = 1 91 | 92 | def chapter2pdf(d: Path, level: int = 1) -> None: 93 | nonlocal page_num 94 | toc.append([level, d.name, page_num]) 95 | for filename in natsorted(d.glob("**/*")): 96 | if not filename.is_file(): 97 | continue 98 | page_num += 1 99 | img = pymupdf.open(filename) 100 | img_info = img[0].get_image_info()[0] 101 | rect = pymupdf.Rect(0.0, 0.0, img_info["width"], img_info["height"]) 102 | img.close() 103 | page = doc.new_page(width=rect.width, height=rect.height) 104 | page.insert_image(rect, filename=filename) 105 | 106 | def volume2pdf(d: Path, level: int = 1) -> None: 107 | for c_dir in natsorted(d.glob("*")): 108 | if not c_dir.is_dir(): 109 | continue 110 | chapter2pdf(c_dir, level) 111 | 112 | def manga2pdf(d: Path) -> None: 113 | l = natsorted(d.glob("*")) 114 | for v_dir in l: 115 | if not v_dir.is_dir(): 116 | continue 117 | if len(l) > 1: 118 | toc.append([1, v_dir.name, page_num]) 119 | volume2pdf(v_dir, 2) 120 | else: 121 | volume2pdf(v_dir, 1) 122 | 123 | if archive_mode == "chapter": 124 | chapter2pdf(directory) 125 | elif archive_mode == "volume": 126 | volume2pdf(directory) 127 | else: 128 | manga2pdf(directory) 129 | 130 | doc.set_toc(toc) 131 | doc.metadata["creator"] = "mangadex_dl" 132 | doc.metadata["creationDate"] = pymupdf.get_pdf_now() 133 | doc.ez_save(arc_name) 134 | doc.close() 135 | 136 | 137 | def _zip_dir(arc_name: str, directory: Path) -> None: 138 | with zipfile.ZipFile(arc_name, mode="w", 139 | compression=zipfile.ZIP_STORED, 140 | allowZip64=True) as zip_file: 141 | for filename in natsorted(directory.glob("**/*")): 142 | zip_file.write(filename, filename.relative_to(directory)) 143 | 144 | 145 | def _find_directories(manga_dir: Path, archive_mode: str, 146 | ext: str) -> list[Path]: 147 | dir_list = [] 148 | 149 | if archive_mode == "manga": 150 | # archive whole manga dir 151 | dir_list.append(manga_dir) 152 | elif archive_mode == "volume": 153 | # archive volume directories 154 | dir_list += manga_dir.glob("*/") 155 | else: 156 | # archive chapter directories 157 | dir_list += manga_dir.glob("*/*/") 158 | 159 | # sort and skip directories that have already been archived before 160 | dir_list = natsorted(list(filter( 161 | lambda f: not (f.with_suffix("."+ext).is_file()), 162 | dir_list))) 163 | return dir_list 164 | -------------------------------------------------------------------------------- /mangadex_dl/download.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: download.py 3 | Handling low-level HTTP requests and loading images. 4 | """ 5 | 6 | import time 7 | import logging 8 | import requests 9 | import concurrent.futures 10 | from pathlib import Path 11 | from collections import deque 12 | 13 | from mangadex_dl.instance import SESSION 14 | 15 | 16 | def url_request(url, params={}, json=False): 17 | error = None 18 | for i in range(5): 19 | try: 20 | _DownloadLimits.check() 21 | 22 | r = SESSION.get(url, timeout=(10, 120), params=params) 23 | 24 | r.raise_for_status() 25 | 26 | if json: 27 | response = r.json() 28 | else: 29 | response = r.content 30 | 31 | if not json: 32 | content_length = r.headers.get("content-length") 33 | received_bytes = len(response) 34 | 35 | if content_length and received_bytes != int(content_length): 36 | raise requests.RequestException( 37 | "IncompleteRead: " 38 | f"{received_bytes} from {content_length}") 39 | 40 | return response 41 | except Exception as err: 42 | error = err 43 | time.sleep(1 if i < 3 else 10) 44 | logging.error(f"URL Request: {error}") 45 | raise error 46 | 47 | 48 | def get_json(url, params={}): 49 | return url_request(url, params=params, json=True) 50 | 51 | 52 | def download_chapters(requested_chapters, 53 | out_directory, 54 | is_datasaver, 55 | gui={}): 56 | 57 | chapter_count = 1 58 | chapter_count_max = len(requested_chapters) 59 | 60 | for chapter in requested_chapters: 61 | chapter_number = chapter["attributes"]["chapter"] or "Oneshot" 62 | chapter_volume = chapter["attributes"]["volume"] or "Unknown" 63 | chapter_name = chapter["attributes"]["title"] or "" 64 | 65 | if gui.get("set"): 66 | # This 'gui' object stores data to 67 | # update progressbars and text in GUI 68 | gui["progress_chapter"].set((chapter_count/chapter_count_max)*100) 69 | gui["progress_chapter_text"].set( 70 | f"[ {chapter_count} / {chapter_count_max} ]") 71 | else: 72 | # Otherwise, print the console output 73 | print("\nDownloading chapter [{:3}/{:3}] " 74 | "Ch.{} {}".format(chapter_count, 75 | chapter_count_max, 76 | chapter_number, 77 | chapter_name)) 78 | 79 | chapter_json = get_json("https://api.mangadex.org/at-home" 80 | f"/server/{chapter['id']}") 81 | 82 | # "https://uploads.mangadex.org/data/3ed5ed7ba35891cc9902f94e8488a51a/" 83 | base_url = "{}/{}/{}/".format(chapter_json["baseUrl"], 84 | "data-saver" if is_datasaver else "data", 85 | chapter_json["chapter"]["hash"]) 86 | 87 | if is_datasaver: 88 | image_url_list = chapter_json["chapter"]["dataSaver"] 89 | else: 90 | image_url_list = chapter_json["chapter"]["data"] 91 | 92 | image_count = 1 93 | image_count_downloaded = 0 94 | image_count_max = len(image_url_list) 95 | 96 | if image_count_max == 0: 97 | print(f" Chapter {chapter_number} is not available on Mangadex.") 98 | continue 99 | 100 | directory_chapter = _create_chapter_directory(out_directory, 101 | chapter_volume, 102 | chapter_number) 103 | 104 | thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=5) 105 | if gui.get("set"): 106 | gui["thread_pool"] = thread_pool 107 | with thread_pool as executor: 108 | future_list = [] 109 | 110 | for image_url in image_url_list: 111 | future_list.append(executor.submit(_download_image, 112 | base_url + image_url, 113 | image_count, 114 | directory_chapter)) 115 | image_count += 1 116 | 117 | for future in concurrent.futures.as_completed(future_list): 118 | image_count_downloaded += 1 119 | if gui.get("set"): 120 | gui["progress_page"].set( 121 | (image_count_downloaded/image_count_max)*100) 122 | gui["progress_page_text"].set( 123 | f"[ {image_count_downloaded} / {image_count_max} ]") 124 | else: 125 | print(f"\r Downloaded images [{image_count_downloaded:3}/" 126 | f"{image_count_max:3}]...", end="") 127 | 128 | if gui.get("set"): 129 | gui["progress_page"].set(0) 130 | gui["progress_page_text"].set("[ - / - ]") 131 | 132 | chapter_count += 1 133 | 134 | 135 | def _download_image(full_url, image_count, directory_chapter): 136 | 137 | image_file_path = directory_chapter / "{:03d}{}".format( 138 | image_count, Path(full_url).suffix) 139 | 140 | try: 141 | data = url_request(full_url) 142 | with open(image_file_path, mode="wb") as image_file: 143 | image_file.write(data) 144 | except Exception as err: 145 | logging.error(f"File download failed ({image_file_path}): {err}") 146 | 147 | 148 | def _create_chapter_directory(out_directory, chapter_volume, chapter_number): 149 | directory_chapter = out_directory / f"Volume {chapter_volume}" / f"Chapter {chapter_number}" 150 | 151 | if directory_chapter.is_dir(): 152 | # name folders like "Chapter 1 (2)" 153 | for i in range(1, 100): 154 | temp_path = Path(f"{directory_chapter} ({i})") 155 | if not temp_path.is_dir(): 156 | directory_chapter = temp_path 157 | break 158 | 159 | directory_chapter.mkdir(parents=True, exist_ok=True) 160 | return directory_chapter 161 | 162 | 163 | class _DownloadLimits: 164 | last_requests = deque(maxlen=5) 165 | 166 | @classmethod 167 | def check(cls): 168 | if len(cls.last_requests) == 5: 169 | interval = time.time() - cls.last_requests[0] 170 | if interval < 1: 171 | time.sleep(1 - interval) 172 | cls.last_requests.append(time.time()) 173 | -------------------------------------------------------------------------------- /mangadex_dl/utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: utils.py 3 | Basic functions for getting information about manga; 4 | """ 5 | 6 | import re 7 | import logging 8 | from pathlib import Path 9 | from functools import lru_cache 10 | from collections import namedtuple 11 | 12 | import mangadex_dl.download as dl 13 | 14 | 15 | def get_uuid(manga_url): 16 | regex = re.compile(r"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}") 17 | manga_uuid_match = re.findall(regex, manga_url) 18 | if manga_uuid_match: 19 | return manga_uuid_match[0] 20 | return None 21 | 22 | 23 | def search_manga(title, language): 24 | res = dl.get_json("https://api.mangadex.org/manga", {"title": title}) 25 | 26 | return [get_manga_info(manga["id"], language) for manga in res["data"]] 27 | 28 | 29 | def get_manga_info(manga_url, language): 30 | manga_info = namedtuple("manga_info", ["uuid", "title", "title_en", 31 | "authors", "artists", 32 | "year", "status", 33 | "last_volume", "last_chapter", 34 | "demographic", "content_rating", 35 | "tags", "description", 36 | "original_language"]) 37 | manga_info.uuid = get_uuid(manga_url) 38 | 39 | res = dl.get_json(f"https://api.mangadex.org/manga/{manga_info.uuid}") 40 | 41 | manga_info.year = res["data"]["attributes"]["year"] 42 | manga_info.status = res["data"]["attributes"]["status"] 43 | manga_info.last_volume = res["data"]["attributes"]["lastVolume"] 44 | manga_info.last_chapter = res["data"]["attributes"]["lastChapter"] 45 | manga_info.content_rating = res["data"]["attributes"]["contentRating"] 46 | manga_info.original_language = res["data"]["attributes"]["originalLanguage"] 47 | manga_info.demographic = res["data"]["attributes"]["publicationDemographic"] 48 | 49 | manga_info.tags = _get_tags(res) 50 | manga_info.description = _get_description(res, language) 51 | manga_info.authors, manga_info.artists = _get_authors(res) 52 | manga_info.title, manga_info.title_en = _get_title(res, language) 53 | 54 | return manga_info 55 | 56 | 57 | def get_chapters_list(manga_uuid, language): 58 | chapters_info = get_chapters_info(manga_uuid, language) 59 | chapters_list = [] 60 | offset = 0 61 | 62 | if chapters_info["total"] == 0: 63 | raise ValueError("No chapters available to download!") 64 | 65 | while offset < chapters_info["total"]: # if more than 500 chapters! 66 | res = dl.get_json(f"https://api.mangadex.org/manga/{manga_uuid}/feed" 67 | "?order[volume]=asc&order[chapter]=asc&limit=500" 68 | f"&translatedLanguage[]={language}&offset={offset}" 69 | "&contentRating[]=safe" 70 | "&contentRating[]=suggestive" 71 | "&contentRating[]=erotica" 72 | "&contentRating[]=pornographic") 73 | chapters_list += res["data"] 74 | offset += 500 75 | 76 | unavailable_list = [] 77 | 78 | for chapter in chapters_list: 79 | if chapter["attributes"]["externalUrl"]: 80 | unavailable_list.append(chapter) 81 | 82 | if len(unavailable_list) != 0: 83 | s = f"{len(unavailable_list)} chapter(s) are not available:\n[" 84 | s += ", ".join(i["attributes"]["chapter"] for i in unavailable_list) 85 | s += "]" 86 | logging.warning(s) 87 | 88 | for chapter in unavailable_list: 89 | chapters_list.remove(chapter) 90 | 91 | return chapters_list 92 | 93 | 94 | def get_chapters_info(manga_uuid, language): 95 | return dl.get_json(f"https://api.mangadex.org/manga/{manga_uuid}/feed" 96 | f"?limit=0&translatedLanguage[]={language}" 97 | "&contentRating[]=safe" 98 | "&contentRating[]=suggestive" 99 | "&contentRating[]=erotica" 100 | "&contentRating[]=pornographic") 101 | 102 | 103 | def create_manga_directory(user_dir, 104 | manga_title: str, 105 | manga_uuid: str) -> Path: 106 | 107 | out_dir = check_output_directory(user_dir) 108 | manga_dir = out_dir / manga_title 109 | 110 | if not manga_dir.is_dir(): 111 | try: 112 | manga_dir.mkdir(parents=True, exist_ok=True) 113 | except OSError: 114 | logging.warning("Cannot create manga directory. " 115 | "Changed name to UUID.") 116 | manga_dir = out_dir / f"Manga {manga_uuid}" 117 | manga_dir.mkdir(parents=True, exist_ok=True) 118 | 119 | return manga_dir 120 | 121 | 122 | def check_output_directory(user_dir): 123 | out_dir = Path(".") 124 | 125 | if user_dir.is_dir(): 126 | out_dir = user_dir.resolve() 127 | 128 | return out_dir 129 | 130 | 131 | def _get_title(res, language): 132 | title_dict = res["data"]["attributes"]["title"] 133 | alt_title_dict = res["data"]["attributes"]["altTitles"] 134 | 135 | if "en" in title_dict: 136 | title_en = title_dict["en"] 137 | elif len(title_dict) != 0: 138 | title_en = next(iter(title_dict.values())) 139 | else: 140 | title_en = res["data"]["id"] 141 | title = title_en 142 | 143 | if language in title_dict: 144 | title = title_dict[language] 145 | else: 146 | for alt_title in alt_title_dict: 147 | if language in alt_title: 148 | title = alt_title[language] 149 | 150 | return title, title_en 151 | 152 | 153 | def _get_description(res, language): 154 | desc_dict = res["data"]["attributes"]["description"] 155 | desc = "Description missing" 156 | 157 | if "en" in desc_dict: 158 | desc = desc_dict["en"] 159 | if language in desc_dict: 160 | desc = desc_dict[language] 161 | 162 | return desc 163 | 164 | 165 | def _get_tags(res): 166 | tags = namedtuple("manga_tags", ["format", "theme", "genre"]) 167 | tags.format = [] 168 | tags.theme = [] 169 | tags.genre = [] 170 | 171 | for tag in res["data"]["attributes"]["tags"]: 172 | tag_group = tag["attributes"]["group"] 173 | 174 | if "en" in tag["attributes"]["name"]: 175 | tag_name = tag["attributes"]["name"]["en"] 176 | else: 177 | tag_name = next(iter(tag["attributes"]["name"].values())) 178 | 179 | if tag_group == "format": 180 | tags.format.append(tag_name) 181 | elif tag_group == "theme": 182 | tags.theme.append(tag_name) 183 | elif tag_group == "genre": 184 | tags.genre.append(tag_name) 185 | 186 | return tags 187 | 188 | 189 | def _get_authors(res): 190 | """ 191 | This function returns a maximum of 3 authors only. 192 | Getting a big list from anthologies is too long. 193 | """ 194 | authors = [] 195 | artists = [] 196 | for relation in res["data"]["relationships"]: 197 | if relation["type"] == "author": 198 | if len(authors) < 3: 199 | authors.append(_get_person_info(relation["id"])) 200 | elif len(authors) == 3: 201 | authors.append("and others...") 202 | continue 203 | 204 | if relation["type"] == "artist": 205 | if len(artists) < 3: 206 | artists.append(_get_person_info(relation["id"])) 207 | elif len(authors) == 3: 208 | artists.append("and others...") 209 | 210 | return authors, artists 211 | 212 | 213 | @lru_cache(maxsize=16) 214 | def _get_person_info(person_id): 215 | res = dl.get_json(f"https://api.mangadex.org/author/{person_id}") 216 | return res["data"]["attributes"]["name"] 217 | -------------------------------------------------------------------------------- /mangadex_dl/gui.py: -------------------------------------------------------------------------------- 1 | """ 2 | Mangadex-dl: gui.py 3 | Initializes GUI version. 4 | """ 5 | 6 | from tkinter import * 7 | from tkinter import ttk 8 | from tkinter import filedialog 9 | from tkinter import messagebox 10 | 11 | import json 12 | import traceback 13 | import concurrent.futures 14 | from pathlib import Path 15 | 16 | from mangadex_dl import utils 17 | from mangadex_dl import parse 18 | from mangadex_dl import archive as ar 19 | from mangadex_dl import download as dl 20 | from mangadex_dl import duplicate as dup 21 | 22 | import tomlkit 23 | 24 | 25 | def init_gui(args): 26 | if args.manga_urls: 27 | for manga_url in args.manga_urls: 28 | _dl_gui(manga_url, args) 29 | else: 30 | _dl_gui("", args) 31 | 32 | 33 | def _dl_gui(manga_url, args): 34 | root = Tk() 35 | root.geometry("850x600") 36 | try: 37 | app = _MangadexDlGui(root, manga_url, args) 38 | root.protocol("WM_DELETE_WINDOW", app.cb_on_closing) 39 | root.mainloop() 40 | except Exception as e: 41 | print(traceback.format_exc()) 42 | messagebox.showinfo(message=f"Error: {e}\n\nSkip download.") 43 | 44 | 45 | class _MangadexDlGui: 46 | 47 | def __init__(self, root, manga_url, args): 48 | # technical elements 49 | self.root = root 50 | self.block = False 51 | self.tree_a = None 52 | self.tree_b = None 53 | self.padding = 5 # i don't see how to add a margin through the global styles, so we add this every time in each widget 54 | self.indicator = None 55 | self.status = StringVar(value="Enter a URL or search query in the searchbar") 56 | self.future = None 57 | self.thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=1) 58 | self.lib_options = {"set": True, "exit": False, "thread_pool": None, 59 | "progress_chapter": DoubleVar(value=0.0), 60 | "progress_page": DoubleVar(value=0.0), 61 | "progress_chapter_text": StringVar(value="[ - / - ]"), 62 | "progress_page_text": StringVar(value="[ - / - ]")} 63 | 64 | # manga-relative vars 65 | self.manga_info = None 66 | self.manga_preview_info = None 67 | self.chapters_list = [] 68 | self.scanlation_groups = [] 69 | self.chapters_list_selected = [] 70 | self.duplicated_chapters_list = [] 71 | self.manga_text_info = StringVar(value="Insert URL and press Search.") 72 | self.manga_url = StringVar(value=manga_url) 73 | self.manga_list_found = [] 74 | self.manga_list_found_var = StringVar(value=self.manga_list_found) 75 | self.chapters_len_available = StringVar(value="Available chapters") 76 | self.chapters_len_download = StringVar(value="Chapters to download") 77 | 78 | # process command-line arguments 79 | args.outdir = utils.check_output_directory(args.outdir) 80 | self.args = args 81 | self.convert_args_to_stringvar(args) 82 | 83 | # init interface 84 | self.root.title("Mangadex-dl") 85 | self.root.columnconfigure(0, weight=1) 86 | self.root.rowconfigure(0, weight=1) 87 | self.root.rowconfigure(1, weight=0) 88 | 89 | mainframe = ttk.Notebook(self.root) 90 | mainframe.grid(column=0, row=0, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 91 | 92 | self.tab_settings = self.init_tab_settings() 93 | self.tab_search = self.init_tab_search() 94 | self.tab_scanlate = self.init_tab_scanlate() 95 | self.tab_download = self.init_tab_download() 96 | 97 | mainframe.add(self.tab_settings, text="Settings") 98 | mainframe.add(self.tab_search, text="Search") 99 | mainframe.add(self.tab_scanlate, text="Group Priority") 100 | mainframe.add(self.tab_download, text="Download") 101 | 102 | statusbar = self.init_statusbar(self.root) 103 | statusbar.grid(column=0, row=1, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 104 | 105 | ########################## 106 | # FUNCTIONS SECTION # 107 | ########################## 108 | 109 | def async_run(self, f, *args): 110 | if not self.block: 111 | self.future = self.thread_pool.submit(lambda: self.async_wrap(f, *args)) 112 | else: 113 | messagebox.showinfo(message="Wait until the current operation completes.") 114 | 115 | def async_wrap(self, f, *args): 116 | try: 117 | self.block = True 118 | self.set_interface_state(False) 119 | self.indicator.start() 120 | f(*args) 121 | except Exception as e: 122 | print(traceback.format_exc()) 123 | self.status.set("Something went wrong! Please try again.") 124 | messagebox.showinfo(message=f"Error: {e}") 125 | finally: 126 | self.future = None 127 | self.block = False 128 | self.set_interface_state(True) 129 | self.indicator.stop() 130 | 131 | def set_interface_state(self, state=True): 132 | frames = [self.tab_settings, self.tab_search, self.tab_scanlate, self.tab_download] 133 | for frame in frames: 134 | self.set_widget_state(frame, state) 135 | 136 | def set_widget_state(self, widget, state): 137 | childrens = widget.winfo_children() 138 | if childrens: 139 | for child in childrens: 140 | self.set_widget_state(child, state) 141 | else: 142 | try: 143 | if widget.winfo_class() == "Listbox": # i cant take it anymore 144 | widget.configure(state="normal" if state else "disable") 145 | else: 146 | widget.configure(state="enable" if state else "disable") 147 | except Exception: 148 | pass 149 | 150 | def update_manga_info(self): 151 | s = f"Title: {self.manga_preview_info.title}\n"\ 152 | f"Author: {', '.join(self.manga_preview_info.authors)}\n"\ 153 | f"Artist: {', '.join(self.manga_preview_info.artists)}\n"\ 154 | f"Year: {self.manga_preview_info.year}\n"\ 155 | f"Status: {self.manga_preview_info.status}\n\n"\ 156 | f"Last Volume: {self.manga_preview_info.last_volume}\n"\ 157 | f"Last Chapter: {self.manga_preview_info.last_chapter}\n\n"\ 158 | f"Original Language: {self.manga_preview_info.original_language}\n"\ 159 | f"Content Rating: {self.manga_preview_info.content_rating}\n"\ 160 | f"Demographic: {self.manga_preview_info.demographic}\n\n"\ 161 | f"Format: {', '.join(self.manga_preview_info.tags.format)}\n"\ 162 | f"Themes: {', '.join(self.manga_preview_info.tags.theme)}\n"\ 163 | f"Genres: {', '.join(self.manga_preview_info.tags.genre)}\n\n"\ 164 | f"Description: {self.manga_preview_info.description}" 165 | self.manga_text_info.set(s) 166 | 167 | def resolve_duplicates_manual_gui(self, chapters_list, duplicated_chapters_list, scanlation_groups): 168 | self.duplicated_chapters_list = duplicated_chapters_list 169 | self.scanlation_groups = scanlation_groups 170 | self.scanlation_groups_priority = [StringVar(value="5") for i in self.scanlation_groups] 171 | 172 | self.destroy_resolve_gui() 173 | 174 | index = 0 175 | for group in self.scanlation_groups: 176 | label = ttk.Label(self.tab_scanlate, text=group["attributes"]["name"]) 177 | label.grid(column=0, row=index + 1, sticky=(E), pady=self.padding, padx=self.padding) 178 | 179 | combobox = ttk.Combobox(self.tab_scanlate, state="readonly", textvariable=self.scanlation_groups_priority[index]) 180 | combobox["values"] = ("1", "2", "3", "4", "5") 181 | combobox.grid(column=1, row=index + 1, sticky=(W), pady=self.padding, padx=self.padding) 182 | 183 | index += 1 184 | 185 | label = ttk.Label(self.tab_scanlate, text="Highest priority: 1.\nLowest priority: 5.") 186 | label.grid(column=0, row=0, sticky=(W), pady=self.padding, padx=self.padding) 187 | 188 | button = ttk.Button(self.tab_scanlate, text="Apply", command=self.cb_resolve_duplicates) 189 | button.grid(column=1, row=0, sticky=(E), pady=self.padding, padx=self.padding) 190 | 191 | return chapters_list 192 | 193 | def destroy_resolve_gui(self): 194 | for widget in self.tab_scanlate.winfo_children(): 195 | widget.destroy() 196 | 197 | def get_chapters_list(self): 198 | return utils.get_chapters_list(self.manga_info.uuid, self.args.language.get()) 199 | 200 | def update_search_results_list(self): 201 | name_list = [f"{manga.title} ({manga.year}) by {', '.join(manga.authors)}" for manga in self.manga_list_found] 202 | self.manga_list_found_var.set(name_list) 203 | 204 | def load_tree_chapters(self): 205 | # Each volume in the tree is open by default. 206 | # Tkinter does not provide a way to automatically update 207 | # the list along with the tree or a way to keep open volumes between trees. 208 | # Doing it manually is fraught with a bunch of synchronization errors and others, 209 | # and is generally not worth the time. 210 | self.chapters_list.sort(key=self.sort_chapters_list_key) 211 | self.chapters_list_selected.sort(key=self.sort_chapters_list_key) 212 | 213 | self.load_tree(self.tree_a, self.chapters_list) 214 | self.load_tree(self.tree_b, self.chapters_list_selected) 215 | 216 | self.chapters_len_available.set(f"Available chapters: {len(self.chapters_list)}") 217 | self.chapters_len_download.set(f"Chapters to download: {len(self.chapters_list_selected)}") 218 | 219 | def load_tree(self, tree, array): 220 | """ 221 | Note: This function modifies the given array. 222 | Adds text value to each chapter dict: 223 | ['volume'], ['chapter'] and ['scanlate_name'] 224 | """ 225 | self.clear_tree(tree) 226 | 227 | volume_name = None 228 | for chapter in array: 229 | c_v = chapter["attributes"]["volume"] or "Unknown" 230 | c_n = chapter["attributes"]["chapter"] or "Oneshot" 231 | c_t = chapter["attributes"]["title"] or "" 232 | 233 | chapter_volume = f"Volume {c_v}" 234 | chapter_name = f"Chapter {c_n}" 235 | chapter_title = f"{chapter_name} {c_t}" 236 | 237 | if self.args.resolve.get() != "one": 238 | if "scanlate_name" not in chapter: 239 | scanlate_id = dup.get_chapter_scanlation_id(chapter) 240 | if scanlate_id: 241 | scanlate_json = dup.get_scanlation_group_info(scanlate_id) 242 | chapter["scanlate_name"] = scanlate_json["attributes"]["name"] 243 | else: 244 | chapter["scanlate_name"] = "No Scanlate Group" 245 | chapter_title += f" [{chapter['scanlate_name']}]" 246 | 247 | chapter["volume"] = chapter_volume 248 | chapter["chapter"] = chapter_name 249 | if volume_name != chapter_volume: 250 | volume_name = chapter_volume 251 | tree.insert("", "end", volume_name, text=volume_name, values=("volume", json.dumps(chapter))) 252 | tree.item(volume_name, open=True) 253 | tree.insert(volume_name, "end", text=chapter_title, values=("chapter", json.dumps(chapter))) 254 | 255 | def tree_item_move(self, tree_a, tree_b, list_a, list_b, item): 256 | item_type = item["values"][0] 257 | item_chap = json.loads(item["values"][1]) 258 | 259 | if item_type == "volume": 260 | target_volume = item_chap["volume"] 261 | selected_list = [] 262 | 263 | for chapter in list_a: 264 | if chapter["volume"] == target_volume: 265 | selected_list.append(chapter) 266 | for chapter in selected_list: 267 | list_a.remove(chapter) 268 | list_b.append(chapter) 269 | 270 | elif item_type == "chapter": 271 | list_a.remove(item_chap) 272 | list_b.append(item_chap) 273 | 274 | self.load_tree_chapters() 275 | 276 | def clear_tree(self, tree): 277 | tree.delete(*tree.get_children()) 278 | 279 | def sort_chapters_list_key(self, chapter): 280 | c_v = chapter["attributes"]["volume"] or 0.0 281 | c_c = chapter["attributes"]["chapter"] or 0.0 282 | option_a = float(c_v) 283 | option_b = float(c_c) 284 | return (option_a, option_b) 285 | 286 | def convert_args_to_stringvar(self, args): 287 | # tk doesnt support python's types like None, so convert to string 288 | self.args.outdir = StringVar(value=args.outdir) 289 | self.args.archive = StringVar(value=str(args.archive)) 290 | self.args.ext = StringVar(value=str(args.ext)) 291 | self.args.download = StringVar(value=str(args.download)) 292 | self.args.language = StringVar(value=args.language) 293 | self.args.keep = BooleanVar(value=args.keep) 294 | self.args.datasaver = BooleanVar(value=args.datasaver) 295 | self.args.resolve = StringVar(value=args.resolve) 296 | 297 | ########################## 298 | # CALLBACKS # 299 | ########################## 300 | 301 | def cb_on_closing(self): 302 | try: 303 | self.thread_pool.shutdown(wait=False, cancel_futures=True) 304 | if self.lib_options["thread_pool"]: 305 | self.lib_options["thread_pool"].shutdown(wait=False, cancel_futures=True) 306 | self.root.destroy() 307 | except Exception: 308 | pass 309 | 310 | def cb_search_result_select(self, e): 311 | if e: 312 | self.manga_preview_info = self.manga_list_found[e[0]] 313 | self.manga_url.set(self.manga_preview_info.uuid) 314 | self.update_manga_info() 315 | 316 | def cb_get_manga_info(self): 317 | if not self.manga_url.get(): 318 | messagebox.showinfo(message="Paste the URL first.\nChange to the English keyboard layout if you cannot paste text.") 319 | return 320 | 321 | # clearing old results 322 | self.destroy_resolve_gui() 323 | self.clear_tree(self.tree_a) 324 | self.clear_tree(self.tree_b) 325 | self.chapters_list = [] 326 | self.chapters_list_selected = [] 327 | self.chapters_len_available.set("Available chapters") 328 | self.chapters_len_download.set("Chapters to download") 329 | 330 | # start downloading 331 | self.status.set("Receiving manga's info...") 332 | 333 | if not utils.get_uuid(self.manga_url.get()): 334 | self.manga_list_found = utils.search_manga(self.manga_url.get(), self.args.language.get()) 335 | if not self.manga_list_found: 336 | self.status.set("Nothing was found according to your request") 337 | else: 338 | self.status.set("Select title and search again") 339 | self.update_search_results_list() 340 | return 341 | 342 | self.manga_info = utils.get_manga_info(self.manga_url.get(), self.args.language.get()) 343 | self.manga_preview_info = self.manga_info 344 | self.update_manga_info() 345 | 346 | self.status.set("Receiving available chapters...") 347 | self.chapters_list = self.get_chapters_list() 348 | 349 | self.status.set("Resolving duplicated chapters...") 350 | self.chapters_list = dup.resolve_duplicated_chapters(self.chapters_list, self.args.resolve.get(), self.resolve_duplicates_manual_gui) 351 | 352 | if self.args.download.get() != "False": 353 | self.status.set("Parsing download range...") 354 | dl_list = parse.parse_range(self.args.download.get()) 355 | self.chapters_list_selected = parse.get_requested_chapters(self.chapters_list, dl_list) 356 | for chapter in self.chapters_list_selected: 357 | if chapter in self.chapters_list: 358 | self.chapters_list.remove(chapter) 359 | 360 | self.status.set("Updating chapters tree...") 361 | self.load_tree_chapters() 362 | 363 | self.status.set("Manga info received") 364 | 365 | def cb_save_settings(self): 366 | with open(Path("config.toml"), "rb") as f: 367 | data = tomlkit.load(f) 368 | data["language"] = self.args.language.get() 369 | data["outdir"] = self.args.outdir.get() 370 | data["archive"] = self.args.archive.get() 371 | data["ext"] = self.args.ext.get() 372 | data["keep"] = self.args.keep.get() 373 | data["datasaver"] = self.args.datasaver.get() 374 | data["resolve"] = self.args.resolve.get() 375 | for k in data: 376 | if data[k] == "False": 377 | data[k] = False 378 | if data[k] == "True": 379 | data[k] = True 380 | with open(Path("config.toml"), "w") as f: 381 | tomlkit.dump(data, f) 382 | 383 | def cb_change_outdir(self): 384 | d = filedialog.askdirectory() 385 | if not d or not Path(d).is_dir(): 386 | d = "." 387 | self.args.outdir.set(d) 388 | 389 | def cb_resolve_duplicates(self): 390 | index = 0 391 | # merge already selected chapters into 392 | self.chapters_list += self.chapters_list_selected 393 | self.chapters_list_selected = [] 394 | for group in self.scanlation_groups: 395 | group["priority"] = self.scanlation_groups_priority[index].get() 396 | index += 1 397 | self.chapters_list = dup.resolve_scanlate_priority_function(self.chapters_list, 398 | self.duplicated_chapters_list, 399 | self.scanlation_groups) 400 | self.load_tree_chapters() 401 | self.status.set("Chapters filtered") 402 | 403 | def cb_tree_item_move(self, tree_a, tree_b, list_a, list_b): 404 | if self.block: 405 | messagebox.showinfo(message="Wait for the download to complete.") 406 | return 407 | item = tree_a.item(tree_a.focus()) 408 | if not isinstance(item["open"], bool) and item["text"] != "": 409 | self.tree_item_move(tree_a, tree_b, list_a, list_b, item) 410 | 411 | def cb_move_all_to_selected(self): 412 | self.chapters_list_selected += self.chapters_list 413 | self.chapters_list = [] 414 | self.load_tree_chapters() 415 | 416 | def cb_download_chapters(self): 417 | if not self.chapters_list_selected: 418 | messagebox.showinfo(message="First click on chapters from the list on the left to move them to the download list.") 419 | return 420 | 421 | self.status.set("Downloading started...") 422 | 423 | manga_directory = utils.create_manga_directory(Path(self.args.outdir.get()), 424 | self.manga_info.title_en, 425 | self.manga_info.uuid) 426 | dl.download_chapters(self.chapters_list_selected, 427 | manga_directory, 428 | self.args.datasaver.get(), 429 | self.lib_options) 430 | 431 | if self.args.archive.get() != "False": 432 | self.lib_options["progress_chapter"].set(0) 433 | self.lib_options["progress_page"].set(0) 434 | self.lib_options["progress_chapter_text"].set("[ - / - ]") 435 | self.lib_options["progress_page_text"].set("[ - / - ]") 436 | self.status.set("Archive downloaded chapters...") 437 | ar.archive_manga(manga_directory, self.args.archive.get(), 438 | self.args.keep.get(), self.args.ext.get(), self.lib_options) 439 | 440 | self.lib_options["progress_chapter"].set(0) 441 | self.lib_options["progress_page"].set(0) 442 | self.lib_options["progress_chapter_text"].set("[ - / - ]") 443 | self.lib_options["progress_page_text"].set("[ - / - ]") 444 | 445 | self.status.set("Manga was downloaded {}successfully".format("and archived " if self.args.archive.get() != "False" else "")) 446 | 447 | def cb_show_help(self): 448 | help_str = "1. Check Settings tab. The settings are applied immediately when changed, but the old search results are preserved.\n"\ 449 | "2. Paste URL or search query in searchbar and press Search. Change to the English keyboard layout if you cannot paste text.\n"\ 450 | "3. Select desired chapters in Download tab, then press Download. Mouse click on individual volumes or chapters entry.\n\n"\ 451 | "If you specify two or more manga links on the command line, close the main window after downloading, the following window should open.\n\n"\ 452 | "The options specified on the command line will be the default values in the current Settings tab." 453 | messagebox.showinfo(message=help_str) 454 | 455 | ########################## 456 | # INIT INTERFACE SECTION # 457 | ########################## 458 | 459 | def init_tab_settings(self): 460 | frame = ttk.Frame() 461 | 462 | # language 463 | label_lang = ttk.Label(frame, text="Language:") 464 | label_lang.grid(column=0, row=0, sticky=(E), pady=self.padding, padx=self.padding) 465 | 466 | combobox_lang = ttk.Combobox(frame, textvariable=self.args.language) 467 | combobox_lang["values"] = ("en", "ru", "fr", "uk", "ja", "zh", "ko", "id") 468 | combobox_lang.grid(column=1, row=0, sticky=(W, E), pady=self.padding, padx=self.padding) 469 | 470 | button_changes = ttk.Button(frame, text="Save settings", command=lambda: self.async_run(self.cb_save_settings)) 471 | button_changes.grid(column=2, row=0, sticky=(W), pady=self.padding, padx=self.padding) 472 | 473 | separator1 = ttk.Separator(frame, orient=HORIZONTAL) 474 | separator1.grid(column=0, row=1, columnspan=5, sticky=(W, E)) 475 | 476 | # out directory 477 | label_dir = ttk.Label(frame, text="Output directory:") 478 | label_dir.grid(column=0, row=2, sticky=(E), pady=self.padding, padx=self.padding) 479 | 480 | label_dir_view = ttk.Label(frame) 481 | label_dir_view["textvariable"] = self.args.outdir 482 | label_dir_view.grid(column=1, row=2, sticky=(W), pady=self.padding, padx=self.padding) 483 | 484 | button_dir = ttk.Button(frame, text="Change", command=self.cb_change_outdir) 485 | button_dir.grid(column=2, row=2, sticky=(W), pady=self.padding, padx=self.padding) 486 | 487 | separator2 = ttk.Separator(frame, orient=HORIZONTAL) 488 | separator2.grid(column=0, row=3, columnspan=5, sticky=(W, E)) 489 | 490 | # archive 491 | label_archive = ttk.Label(frame, text="Archive after\ndownloading:", justify=RIGHT) 492 | label_archive.grid(column=0, row=4, sticky=(E), pady=self.padding, padx=self.padding) 493 | 494 | radio_archive_a = ttk.Radiobutton(frame, text="None", variable=self.args.archive, value="False") 495 | radio_archive_b = ttk.Radiobutton(frame, text="Whole manga", variable=self.args.archive, value="manga") 496 | radio_archive_c = ttk.Radiobutton(frame, text="Volume", variable=self.args.archive, value="volume") 497 | radio_archive_d = ttk.Radiobutton(frame, text="Chapter", variable=self.args.archive, value="chapter") 498 | 499 | radio_archive_a.grid(column=1, row=4, sticky=(W), pady=self.padding, padx=self.padding) 500 | radio_archive_b.grid(column=1, row=5, sticky=(W), pady=self.padding, padx=self.padding) 501 | radio_archive_c.grid(column=2, row=4, sticky=(W), pady=self.padding, padx=self.padding) 502 | radio_archive_d.grid(column=2, row=5, sticky=(W), pady=self.padding, padx=self.padding) 503 | 504 | separator3 = ttk.Separator(frame, orient=HORIZONTAL) 505 | separator3.grid(column=0, row=6, columnspan=5, sticky=(W, E)) 506 | 507 | # extension 508 | label_ext = ttk.Label(frame, text="Extension:") 509 | label_ext.grid(column=0, row=7, sticky=(E), pady=self.padding, padx=self.padding) 510 | 511 | radio_ext_a = ttk.Radiobutton(frame, text="*.zip", variable=self.args.ext, value="zip") 512 | radio_ext_b = ttk.Radiobutton(frame, text="*.cbz", variable=self.args.ext, value="cbz") 513 | radio_ext_c = ttk.Radiobutton(frame, text="*.pdf", variable=self.args.ext, value="pdf") 514 | 515 | radio_ext_a.grid(column=1, row=7, sticky=(W), pady=self.padding, padx=self.padding) 516 | radio_ext_b.grid(column=2, row=7, sticky=(W), pady=self.padding, padx=self.padding) 517 | radio_ext_c.grid(column=1, row=8, sticky=(W), pady=self.padding, padx=self.padding) 518 | 519 | separator4 = ttk.Separator(frame, orient=HORIZONTAL) 520 | separator4.grid(column=0, row=9, columnspan=5, sticky=(W, E)) 521 | 522 | # keep original 523 | label_keep = ttk.Label(frame, text="Keep original\nafter archiving:", justify=RIGHT) 524 | label_keep.grid(column=0, row=10, sticky=(E), pady=self.padding, padx=self.padding) 525 | 526 | check_keep = ttk.Checkbutton(frame, text="", variable=self.args.keep, onvalue="1", offvalue="0") 527 | check_keep.grid(column=1, row=10, sticky=(W), pady=self.padding, padx=self.padding) 528 | 529 | separator5 = ttk.Separator(frame, orient=HORIZONTAL) 530 | separator5.grid(column=0, row=11, columnspan=5, sticky=(W, E)) 531 | 532 | # data saver 533 | label_datasaver = ttk.Label(frame, text="Download images\nin lower quality:", justify=RIGHT) 534 | label_datasaver.grid(column=0, row=12, sticky=(E), pady=self.padding, padx=self.padding) 535 | 536 | check_datasaver = ttk.Checkbutton(frame, text="", variable=self.args.datasaver, onvalue="1", offvalue="0") 537 | check_datasaver.grid(column=1, row=12, sticky=(W), pady=self.padding, padx=self.padding) 538 | 539 | separator6 = ttk.Separator(frame, orient=HORIZONTAL) 540 | separator6.grid(column=0, row=13, columnspan=5, sticky=(W, E)) 541 | 542 | # resolve duplicate 543 | label_resolve = ttk.Label(frame, text="How to resolve\nduplicates:", justify=RIGHT) 544 | label_resolve.grid(column=0, row=14, sticky=(E), pady=self.padding, padx=self.padding) 545 | 546 | radio_resolve_a = ttk.Radiobutton(frame, text="Display all", variable=self.args.resolve, value="all") 547 | radio_resolve_b = ttk.Radiobutton(frame, text="Display only one", variable=self.args.resolve, value="one") 548 | radio_resolve_c = ttk.Radiobutton(frame, text="Filter manually", variable=self.args.resolve, value="manual") 549 | 550 | radio_resolve_a.grid(column=1, row=14, sticky=(W), pady=self.padding, padx=self.padding) 551 | radio_resolve_b.grid(column=1, row=15, sticky=(W), pady=self.padding, padx=self.padding) 552 | radio_resolve_c.grid(column=2, row=14, sticky=(W), pady=self.padding, padx=self.padding) 553 | 554 | separator7 = ttk.Separator(frame, orient=HORIZONTAL) 555 | separator7.grid(column=0, row=16, columnspan=5, sticky=(W, E)) 556 | 557 | # help 558 | label_help = ttk.Label(frame, text="Note: After changing language or duplicate settings reload URL in the Search tab again.") 559 | label_help.grid(column=0, row=17, columnspan=5, sticky=(W, E), pady=self.padding, padx=self.padding) 560 | 561 | return frame 562 | 563 | def init_tab_search(self): 564 | frame = ttk.Frame() 565 | frame.rowconfigure(0, weight=0) 566 | frame.rowconfigure(1, weight=1) 567 | frame.columnconfigure(0, weight=0, minsize=320) 568 | frame.columnconfigure(1, weight=1) 569 | 570 | ### 571 | searchbar_frame = ttk.Frame(frame) 572 | searchbar_frame.grid(column=0, row=0, columnspan=2, sticky=(E, W)) 573 | searchbar_frame.columnconfigure(0, weight=0) 574 | searchbar_frame.columnconfigure(1, weight=1) 575 | searchbar_frame.columnconfigure(2, weight=0) 576 | 577 | label = ttk.Label(searchbar_frame, text="URL or search query:") 578 | label.grid(column=0, row=0, pady=self.padding, padx=self.padding) 579 | 580 | entry = ttk.Entry(searchbar_frame, textvariable=self.manga_url) 581 | entry.grid(column=1, row=0, sticky=(E, W), pady=self.padding, padx=self.padding) 582 | 583 | button = ttk.Button(searchbar_frame, text="Search", command=lambda: self.async_run(self.cb_get_manga_info)) 584 | button.grid(column=2, row=0, pady=self.padding, padx=self.padding) 585 | ### 586 | search_results_frame = ttk.Labelframe(frame, text="Search Results") 587 | search_results_frame.grid(column=0, row=1, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 588 | search_results_frame.rowconfigure(0, weight=1) 589 | search_results_frame.rowconfigure(1, weight=0) 590 | search_results_frame.columnconfigure(0, weight=1) 591 | search_results_frame.columnconfigure(1, weight=0) 592 | 593 | result_listbox = Listbox(search_results_frame, listvariable=self.manga_list_found_var) 594 | result_listbox.grid(column=0, row=0, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 595 | 596 | scrollbar_a = ttk.Scrollbar(search_results_frame, orient=VERTICAL, command=result_listbox.yview) 597 | scrollbar_a.grid(column=1, row=0, sticky=(N, S)) 598 | scrollbar_b = ttk.Scrollbar(search_results_frame, orient=HORIZONTAL, command=result_listbox.xview) 599 | scrollbar_b.grid(column=0, row=1, columnspan=2, sticky=(E, W)) 600 | 601 | result_listbox.configure(yscrollcommand=scrollbar_a.set) 602 | result_listbox.configure(xscrollcommand=scrollbar_b.set) 603 | result_listbox.bind("<>", lambda e: self.cb_search_result_select(result_listbox.curselection())) 604 | ### 605 | frame_info = ttk.Labelframe(frame, text="Info") 606 | frame_info.grid(column=1, row=1, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 607 | 608 | label_info = ttk.Label(frame_info, textvariable=self.manga_text_info, wraplength=500) 609 | label_info.grid(column=0, row=0, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 610 | return frame 611 | 612 | def init_tab_download(self): 613 | frame = ttk.Frame() 614 | frame.rowconfigure(0, weight=0) 615 | frame.rowconfigure(1, weight=1) 616 | frame.rowconfigure(2, weight=0) 617 | frame.columnconfigure(0, weight=1) 618 | frame.columnconfigure(1, weight=0) 619 | frame.columnconfigure(2, weight=1) 620 | frame.columnconfigure(3, weight=0) 621 | 622 | # labels 623 | label_a = ttk.Label(frame, textvariable=self.chapters_len_available) 624 | label_a.grid(column=0, row=0, pady=self.padding, padx=self.padding) 625 | 626 | label_b = ttk.Label(frame, textvariable=self.chapters_len_download) 627 | label_b.grid(column=2, row=0, pady=self.padding, padx=self.padding) 628 | 629 | # trees 630 | self.tree_a = ttk.Treeview(frame) 631 | self.tree_a.grid(column=0, row=1, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 632 | 633 | self.tree_b = ttk.Treeview(frame) 634 | self.tree_b.grid(column=2, row=1, sticky=(N, S, E, W), pady=self.padding, padx=self.padding) 635 | 636 | scrollbar_a = ttk.Scrollbar(frame, orient=VERTICAL, command=self.tree_a.yview) 637 | scrollbar_a.grid(column=1, row=1, sticky=(N, S)) 638 | 639 | scrollbar_b = ttk.Scrollbar(frame, orient=VERTICAL, command=self.tree_b.yview) 640 | scrollbar_b.grid(column=3, row=1, sticky=(N, S)) 641 | 642 | self.tree_a.configure(yscrollcommand=scrollbar_a.set) 643 | self.tree_b.configure(yscrollcommand=scrollbar_b.set) 644 | 645 | self.tree_a.bind("", lambda x: self.cb_tree_item_move(self.tree_a, self.tree_b, 646 | self.chapters_list, self.chapters_list_selected)) 647 | self.tree_b.bind("", lambda x: self.cb_tree_item_move(self.tree_b, self.tree_a, 648 | self.chapters_list_selected, self.chapters_list)) 649 | 650 | # action bar 651 | button_move_all = ttk.Button(frame, text="Move all", command=self.cb_move_all_to_selected) 652 | button_move_all.grid(column=0, row=2, sticky=(W), pady=self.padding, padx=self.padding) 653 | 654 | button_download = ttk.Button(frame, text="Start download", command=lambda: self.async_run(self.cb_download_chapters)) 655 | button_download.grid(column=2, row=2, sticky=(E), pady=self.padding, padx=self.padding) 656 | 657 | return frame 658 | 659 | def init_tab_scanlate(self): 660 | # ok, we can't make scrollbar for frame in tk 661 | frame = ttk.Frame() 662 | 663 | label = ttk.Label(frame, text="You can manually set priorities for scanlate groups to filter duplicate chapters.\n" 664 | "Specify 'Filter manually' in the Settings tab and reload the URL.") 665 | label.grid(column=0, row=0, pady=self.padding, padx=self.padding) 666 | 667 | return frame 668 | 669 | def init_statusbar(self, root): 670 | frame = ttk.Frame(root) 671 | frame.rowconfigure(0, weight=0) # progressbar_chap, indicator 672 | frame.rowconfigure(1, weight=0) # progressbar_page, help button 673 | frame.rowconfigure(2, weight=0) # status text 674 | frame.columnconfigure(0, weight=0) # progressbar labels 675 | frame.columnconfigure(1, weight=1) # progressbar, status 676 | frame.columnconfigure(2, weight=0) # progress numbers 677 | frame.grid_columnconfigure(2, minsize=90) 678 | frame.columnconfigure(3, weight=0) # separator 679 | frame.columnconfigure(4, weight=0) # indicator, help button 680 | 681 | ### 682 | label_a = ttk.Label(frame, text="Chapters: ") 683 | label_a.grid(column=0, row=0, sticky=(E), pady=self.padding, padx=self.padding) 684 | 685 | label_b = ttk.Label(frame, text="Pages: ") 686 | label_b.grid(column=0, row=1, sticky=(E), pady=self.padding, padx=self.padding) 687 | 688 | label_c = ttk.Label(frame, text="Status: ") 689 | label_c.grid(column=0, row=2, sticky=(E), pady=self.padding, padx=self.padding) 690 | ### 691 | progressbar_chap = ttk.Progressbar(frame, orient=HORIZONTAL, mode="determinate", variable=self.lib_options["progress_chapter"]) 692 | progressbar_chap.grid(column=1, row=0, sticky=(E, W), pady=self.padding, padx=self.padding) 693 | 694 | progressbar_page = ttk.Progressbar(frame, orient=HORIZONTAL, mode="determinate", variable=self.lib_options["progress_page"]) 695 | progressbar_page.grid(column=1, row=1, sticky=(E, W), pady=self.padding, padx=self.padding) 696 | 697 | status = ttk.Label(frame, textvariable=self.status) 698 | status.grid(column=1, row=2, sticky=(W), pady=self.padding, padx=self.padding) 699 | ### 700 | progress_chapter_text = ttk.Label(frame, textvariable=self.lib_options["progress_chapter_text"]) 701 | progress_chapter_text.grid(column=2, row=0, sticky=(E, W), pady=self.padding, padx=self.padding) 702 | 703 | progress_page_text = ttk.Label(frame, textvariable=self.lib_options["progress_page_text"]) 704 | progress_page_text.grid(column=2, row=1, sticky=(E, W), pady=self.padding, padx=self.padding) 705 | ### 706 | separator = ttk.Separator(frame, orient=VERTICAL) 707 | separator.grid(column=3, row=0, rowspan=3, sticky=(N, S)) 708 | ### 709 | self.indicator = ttk.Progressbar(frame, orient=HORIZONTAL, mode="indeterminate") 710 | self.indicator.grid(column=4, row=0, sticky=(E, W), pady=self.padding, padx=self.padding) 711 | 712 | button = ttk.Button(frame, text="?", command=self.cb_show_help) 713 | button.grid(column=4, row=1, sticky=(E, W), pady=self.padding, padx=self.padding) 714 | ### 715 | 716 | return frame 717 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------