add --lean flag and change verbosity configuration
This commit is contained in:
parent
6b3eceae93
commit
26d8043fe4
8 changed files with 119 additions and 82 deletions
|
@ -15,12 +15,12 @@ class Mangadex:
|
||||||
img_base_url = "https://uploads.mangadex.org"
|
img_base_url = "https://uploads.mangadex.org"
|
||||||
|
|
||||||
# get infos to initiate class
|
# get infos to initiate class
|
||||||
def __init__(self, url_uuid: str, language: str, forcevol: bool, verbose: bool):
|
def __init__(self, url_uuid: str, language: str, forcevol: bool, verbosity: int):
|
||||||
# static info
|
# static info
|
||||||
self.url_uuid = url_uuid
|
self.url_uuid = url_uuid
|
||||||
self.language = language
|
self.language = language
|
||||||
self.forcevol = forcevol
|
self.forcevol = forcevol
|
||||||
self.verbose = verbose
|
self.verbosity = verbosity
|
||||||
|
|
||||||
# api stuff
|
# api stuff
|
||||||
self.api_content_ratings = "contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic"
|
self.api_content_ratings = "contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic"
|
||||||
|
@ -36,7 +36,7 @@ class Mangadex:
|
||||||
|
|
||||||
# make initial request
|
# make initial request
|
||||||
def get_manga_data(self) -> requests.Response:
|
def get_manga_data(self) -> requests.Response:
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(f"INFO: Getting manga data for: {self.manga_uuid}")
|
print(f"INFO: Getting manga data for: {self.manga_uuid}")
|
||||||
counter = 1
|
counter = 1
|
||||||
while counter <= 3:
|
while counter <= 3:
|
||||||
|
@ -76,7 +76,7 @@ class Mangadex:
|
||||||
|
|
||||||
# get the title of the manga (and fix the filename)
|
# get the title of the manga (and fix the filename)
|
||||||
def get_manga_title(self) -> str:
|
def get_manga_title(self) -> str:
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(f"INFO: Getting manga title for: {self.manga_uuid}")
|
print(f"INFO: Getting manga title for: {self.manga_uuid}")
|
||||||
manga_data = self.manga_data.json()
|
manga_data = self.manga_data.json()
|
||||||
try:
|
try:
|
||||||
|
@ -95,7 +95,7 @@ class Mangadex:
|
||||||
|
|
||||||
# check if chapters are available in requested language
|
# check if chapters are available in requested language
|
||||||
def check_chapter_lang(self) -> int:
|
def check_chapter_lang(self) -> int:
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(
|
print(
|
||||||
f"INFO: Checking for chapters in specified language for: {self.manga_uuid}"
|
f"INFO: Checking for chapters in specified language for: {self.manga_uuid}"
|
||||||
)
|
)
|
||||||
|
@ -118,7 +118,7 @@ class Mangadex:
|
||||||
|
|
||||||
# get chapter data like name, uuid etc
|
# get chapter data like name, uuid etc
|
||||||
def get_chapter_data(self) -> dict:
|
def get_chapter_data(self) -> dict:
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(f"INFO: Getting chapter data for: {self.manga_uuid}")
|
print(f"INFO: Getting chapter data for: {self.manga_uuid}")
|
||||||
api_sorting = "order[chapter]=asc&order[volume]=asc"
|
api_sorting = "order[chapter]=asc&order[volume]=asc"
|
||||||
# check for chapters in specified lang
|
# check for chapters in specified lang
|
||||||
|
@ -177,7 +177,7 @@ class Mangadex:
|
||||||
|
|
||||||
# get images for the chapter (mangadex@home)
|
# get images for the chapter (mangadex@home)
|
||||||
def get_chapter_images(self, chapter: str, wait_time: float) -> list:
|
def get_chapter_images(self, chapter: str, wait_time: float) -> list:
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(f"INFO: Getting chapter images for: {self.manga_uuid}")
|
print(f"INFO: Getting chapter images for: {self.manga_uuid}")
|
||||||
athome_url = f"{self.api_base_url}/at-home/server"
|
athome_url = f"{self.api_base_url}/at-home/server"
|
||||||
chapter_uuid = self.manga_chapter_data[chapter][0]
|
chapter_uuid = self.manga_chapter_data[chapter][0]
|
||||||
|
@ -224,7 +224,7 @@ class Mangadex:
|
||||||
|
|
||||||
# create list of chapters
|
# create list of chapters
|
||||||
def create_chapter_list(self) -> list:
|
def create_chapter_list(self) -> list:
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(f"INFO: Creating chapter list for: {self.manga_uuid}")
|
print(f"INFO: Creating chapter list for: {self.manga_uuid}")
|
||||||
chapter_list = []
|
chapter_list = []
|
||||||
for chapter in self.manga_chapter_data.items():
|
for chapter in self.manga_chapter_data.items():
|
||||||
|
@ -240,7 +240,7 @@ class Mangadex:
|
||||||
|
|
||||||
# create easy to access chapter infos
|
# create easy to access chapter infos
|
||||||
def get_chapter_infos(self, chapter: str) -> dict:
|
def get_chapter_infos(self, chapter: str) -> dict:
|
||||||
if self.verbose:
|
if self.verbosity >= 3:
|
||||||
print(
|
print(
|
||||||
f"INFO: Getting chapter infos for: {self.manga_chapter_data[chapter][0]}"
|
f"INFO: Getting chapter infos for: {self.manga_chapter_data[chapter][0]}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class MangaDLP:
|
||||||
:param forcevol: Force naming of volumes. Useful for mangas where chapters reset each volume
|
:param forcevol: Force naming of volumes. Useful for mangas where chapters reset each volume
|
||||||
:param download_path: Download path. Defaults to '<script_dir>/downloads'
|
:param download_path: Download path. Defaults to '<script_dir>/downloads'
|
||||||
:param download_wait: Time to wait for each picture to download in seconds
|
:param download_wait: Time to wait for each picture to download in seconds
|
||||||
:param verbose: If verbose logging is enabled
|
:param verbosity: Verbosity of the output
|
||||||
|
|
||||||
:return: Nothing. Just the files
|
:return: Nothing. Just the files
|
||||||
"""
|
"""
|
||||||
|
@ -38,7 +38,7 @@ class MangaDLP:
|
||||||
forcevol: bool = False,
|
forcevol: bool = False,
|
||||||
download_path: str = "downloads",
|
download_path: str = "downloads",
|
||||||
download_wait: float = 0.5,
|
download_wait: float = 0.5,
|
||||||
verbose: bool = False,
|
verbosity: int = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
# init parameters
|
# init parameters
|
||||||
self.url_uuid = url_uuid
|
self.url_uuid = url_uuid
|
||||||
|
@ -49,7 +49,7 @@ class MangaDLP:
|
||||||
self.forcevol = forcevol
|
self.forcevol = forcevol
|
||||||
self.download_path = download_path
|
self.download_path = download_path
|
||||||
self.download_wait = download_wait
|
self.download_wait = download_wait
|
||||||
self.verbose = verbose
|
self.verbosity = verbosity
|
||||||
# prepare everything
|
# prepare everything
|
||||||
self._prepare()
|
self._prepare()
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class MangaDLP:
|
||||||
# init api
|
# init api
|
||||||
self.api_used = self.check_api(self.url_uuid)
|
self.api_used = self.check_api(self.url_uuid)
|
||||||
self.api = self.api_used(
|
self.api = self.api_used(
|
||||||
self.url_uuid, self.language, self.forcevol, self.verbose
|
self.url_uuid, self.language, self.forcevol, self.verbosity
|
||||||
)
|
)
|
||||||
# get manga title and uuid
|
# get manga title and uuid
|
||||||
self.manga_uuid = self.api.manga_uuid
|
self.manga_uuid = self.api.manga_uuid
|
||||||
|
@ -125,9 +125,12 @@ class MangaDLP:
|
||||||
skipped_chapters: list[Any] = []
|
skipped_chapters: list[Any] = []
|
||||||
error_chapters: list[Any] = []
|
error_chapters: list[Any] = []
|
||||||
|
|
||||||
# show infos
|
|
||||||
print_divider = "========================================="
|
print_divider = "========================================="
|
||||||
print(f"\n{print_divider}")
|
# show infos
|
||||||
|
if self.verbosity == 1:
|
||||||
|
print(f"INFO: Manga Name: {self.manga_title}")
|
||||||
|
else:
|
||||||
|
print(f"{print_divider}")
|
||||||
print(f"INFO: Manga Name: {self.manga_title}")
|
print(f"INFO: Manga Name: {self.manga_title}")
|
||||||
print(f"INFO: Manga UUID: {self.manga_uuid}")
|
print(f"INFO: Manga UUID: {self.manga_uuid}")
|
||||||
print(f"INFO: Total chapters: {len(self.manga_chapter_list)}")
|
print(f"INFO: Total chapters: {len(self.manga_chapter_list)}")
|
||||||
|
@ -147,8 +150,11 @@ class MangaDLP:
|
||||||
)
|
)
|
||||||
|
|
||||||
# show chapters to download
|
# show chapters to download
|
||||||
|
if self.verbosity == 1:
|
||||||
|
print(f"INFO: Chapters selected: {', '.join(chapters_to_download)}")
|
||||||
|
else:
|
||||||
print(f"INFO: Chapters selected:\n{', '.join(chapters_to_download)}")
|
print(f"INFO: Chapters selected:\n{', '.join(chapters_to_download)}")
|
||||||
print(f"{print_divider}\n")
|
print(f"{print_divider}")
|
||||||
|
|
||||||
# create manga folder
|
# create manga folder
|
||||||
self.manga_path.mkdir(parents=True, exist_ok=True)
|
self.manga_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
@ -171,16 +177,24 @@ class MangaDLP:
|
||||||
print("INFO: Done with chapter\n")
|
print("INFO: Done with chapter\n")
|
||||||
|
|
||||||
# done with manga
|
# done with manga
|
||||||
|
if self.verbosity != 1:
|
||||||
print(f"{print_divider}")
|
print(f"{print_divider}")
|
||||||
print(f"INFO: Done with manga: {self.manga_title}")
|
print(f"INFO: Done with manga: {self.manga_title}")
|
||||||
# filter skipped list
|
# filter skipped list
|
||||||
skipped_chapters = list(filter(None, skipped_chapters))
|
skipped_chapters = list(filter(None, skipped_chapters))
|
||||||
if len(skipped_chapters) >= 1:
|
if len(skipped_chapters) >= 1:
|
||||||
|
if self.verbosity == 1:
|
||||||
|
print(f"INFO: Skipped chapters: {', '.join(skipped_chapters)}")
|
||||||
|
else:
|
||||||
print(f"INFO: Skipped chapters:\n{', '.join(skipped_chapters)}")
|
print(f"INFO: Skipped chapters:\n{', '.join(skipped_chapters)}")
|
||||||
# filter error list
|
# filter error list
|
||||||
error_chapters = list(filter(None, error_chapters))
|
error_chapters = list(filter(None, error_chapters))
|
||||||
if len(error_chapters) >= 1:
|
if len(error_chapters) >= 1:
|
||||||
|
if self.verbosity == 1:
|
||||||
|
print(f"INFO: Chapters with errors: {', '.join(error_chapters)}")
|
||||||
|
else:
|
||||||
print(f"INFO: Chapters with errors:\n{', '.join(error_chapters)}")
|
print(f"INFO: Chapters with errors:\n{', '.join(error_chapters)}")
|
||||||
|
if self.verbosity != 1:
|
||||||
print(f"{print_divider}\n")
|
print(f"{print_divider}\n")
|
||||||
|
|
||||||
# once called per chapter
|
# once called per chapter
|
||||||
|
@ -225,6 +239,7 @@ class MangaDLP:
|
||||||
# check if chapter already exists
|
# check if chapter already exists
|
||||||
# check for folder, if file format is an empty string
|
# check for folder, if file format is an empty string
|
||||||
if chapter_archive_path.exists():
|
if chapter_archive_path.exists():
|
||||||
|
if self.verbosity != 1:
|
||||||
print(f"INFO: '{chapter_archive_path}' already exists. Skipping")
|
print(f"INFO: '{chapter_archive_path}' already exists. Skipping")
|
||||||
# add to skipped chapters list
|
# add to skipped chapters list
|
||||||
return (
|
return (
|
||||||
|
@ -240,7 +255,7 @@ class MangaDLP:
|
||||||
chapter_path.mkdir(parents=True, exist_ok=True)
|
chapter_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# verbose log
|
# verbose log
|
||||||
if self.verbose:
|
if self.verbosity >= 2:
|
||||||
print(f"INFO: Chapter UUID: {chapter_infos['uuid']}")
|
print(f"INFO: Chapter UUID: {chapter_infos['uuid']}")
|
||||||
print(f"INFO: Filename: '{chapter_archive_path.name}'\n")
|
print(f"INFO: Filename: '{chapter_archive_path.name}'\n")
|
||||||
print(f"INFO: File path: '{chapter_archive_path}'\n")
|
print(f"INFO: File path: '{chapter_archive_path}'\n")
|
||||||
|
@ -252,7 +267,7 @@ class MangaDLP:
|
||||||
# download images
|
# download images
|
||||||
try:
|
try:
|
||||||
downloader.download_chapter(
|
downloader.download_chapter(
|
||||||
chapter_image_urls, chapter_path, self.download_wait, self.verbose
|
chapter_image_urls, chapter_path, self.download_wait, self.verbosity
|
||||||
)
|
)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("ERR: Stopping")
|
print("ERR: Stopping")
|
||||||
|
|
|
@ -14,7 +14,7 @@ def download_chapter(
|
||||||
image_urls: list,
|
image_urls: list,
|
||||||
chapter_path: Union[str, Path],
|
chapter_path: Union[str, Path],
|
||||||
download_wait: float,
|
download_wait: float,
|
||||||
verbose: bool,
|
verbosity: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
total_img = len(image_urls)
|
total_img = len(image_urls)
|
||||||
for image_num, image in enumerate(image_urls, 1):
|
for image_num, image in enumerate(image_urls, 1):
|
||||||
|
@ -22,11 +22,11 @@ def download_chapter(
|
||||||
image_suffix = str(Path(image).suffix) or ".png"
|
image_suffix = str(Path(image).suffix) or ".png"
|
||||||
# set image path
|
# set image path
|
||||||
image_path = Path(f"{chapter_path}/{image_num:03d}{image_suffix}")
|
image_path = Path(f"{chapter_path}/{image_num:03d}{image_suffix}")
|
||||||
# show progress bar if verbose logging is not active
|
# show progress bar or progress by image for verbose
|
||||||
if verbose:
|
if verbosity == 0:
|
||||||
print(f"INFO: Downloading image {image_num}/{total_img}")
|
|
||||||
else:
|
|
||||||
utils.progress_bar(image_num, total_img)
|
utils.progress_bar(image_num, total_img)
|
||||||
|
elif verbosity >= 2:
|
||||||
|
print(f"INFO: Downloading image {image_num}/{total_img}")
|
||||||
|
|
||||||
counter = 1
|
counter = 1
|
||||||
while counter <= 3:
|
while counter <= 3:
|
||||||
|
|
|
@ -48,7 +48,7 @@ def call_app(args):
|
||||||
args.forcevol,
|
args.forcevol,
|
||||||
args.path,
|
args.path,
|
||||||
args.wait,
|
args.wait,
|
||||||
args.verbose,
|
args.verbosity,
|
||||||
)
|
)
|
||||||
mdlp.get_manga()
|
mdlp.get_manga()
|
||||||
|
|
||||||
|
@ -95,8 +95,10 @@ def get_args():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Script to download mangas from various sites"
|
description="Script to download mangas from various sites"
|
||||||
)
|
)
|
||||||
group = parser.add_mutually_exclusive_group(required=True)
|
action = parser.add_mutually_exclusive_group(required=True)
|
||||||
group.add_argument(
|
verbosity = parser.add_mutually_exclusive_group(required=False)
|
||||||
|
|
||||||
|
action.add_argument(
|
||||||
"-u",
|
"-u",
|
||||||
"--url",
|
"--url",
|
||||||
"--uuid",
|
"--uuid",
|
||||||
|
@ -105,14 +107,14 @@ def get_args():
|
||||||
help="URL or UUID of the manga",
|
help="URL or UUID of the manga",
|
||||||
action="store",
|
action="store",
|
||||||
)
|
)
|
||||||
group.add_argument(
|
action.add_argument(
|
||||||
"--read",
|
"--read",
|
||||||
dest="read",
|
dest="read",
|
||||||
required=False,
|
required=False,
|
||||||
help="Path of file with manga links to download. One per line",
|
help="Path of file with manga links to download. One per line",
|
||||||
action="store",
|
action="store",
|
||||||
)
|
)
|
||||||
group.add_argument(
|
action.add_argument(
|
||||||
"-v",
|
"-v",
|
||||||
"--version",
|
"--version",
|
||||||
dest="version",
|
dest="version",
|
||||||
|
@ -176,12 +178,32 @@ def get_args():
|
||||||
default=0.5,
|
default=0.5,
|
||||||
help="Time to wait for each picture to download in seconds(float). Defaults 0.5",
|
help="Time to wait for each picture to download in seconds(float). Defaults 0.5",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
verbosity.add_argument(
|
||||||
|
"--lean",
|
||||||
|
dest="verbosity",
|
||||||
|
required=False,
|
||||||
|
help="Lean logging. Defaults to false",
|
||||||
|
action="store_const",
|
||||||
|
const=1,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
verbosity.add_argument(
|
||||||
"--verbose",
|
"--verbose",
|
||||||
dest="verbose",
|
dest="verbosity",
|
||||||
required=False,
|
required=False,
|
||||||
help="Verbose logging. Defaults to false",
|
help="Verbose logging. Defaults to false",
|
||||||
action="store_true",
|
action="store_const",
|
||||||
|
const=2,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
verbosity.add_argument(
|
||||||
|
"--debug",
|
||||||
|
dest="verbosity",
|
||||||
|
required=False,
|
||||||
|
help="Lean logging. Defaults to false",
|
||||||
|
action="store_const",
|
||||||
|
const=3,
|
||||||
|
default=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
# parser.print_help()
|
# parser.print_help()
|
||||||
|
|
|
@ -57,7 +57,7 @@ def test_chapter_list_full():
|
||||||
forcevol=True,
|
forcevol=True,
|
||||||
download_path="tests",
|
download_path="tests",
|
||||||
download_wait=2,
|
download_wait=2,
|
||||||
verbose=True,
|
verbosity=3,
|
||||||
)
|
)
|
||||||
chap_list = utils.get_chapter_list("1:1,1:2,1:4-1:7,2:", mdlp.manga_chapter_list)
|
chap_list = utils.get_chapter_list("1:1,1:2,1:4-1:7,2:", mdlp.manga_chapter_list)
|
||||||
assert chap_list == [
|
assert chap_list == [
|
||||||
|
|
|
@ -13,7 +13,7 @@ def test_read_and_url():
|
||||||
chapters = "1"
|
chapters = "1"
|
||||||
file_format = "cbz"
|
file_format = "cbz"
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
command_args = f"-u {url_uuid} --read {link_file} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose"
|
command_args = f"-u {url_uuid} --read {link_file} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
assert os.system(f"python3 {script_path} {command_args}") != 0
|
assert os.system(f"python3 {script_path} {command_args}") != 0
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ def test_no_read_and_url():
|
||||||
chapters = "1"
|
chapters = "1"
|
||||||
file_format = "cbz"
|
file_format = "cbz"
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
command_args = f"-l {language} -c {chapters} --path {download_path} --format {file_format} --verbose"
|
command_args = f"-l {language} -c {chapters} --path {download_path} --format {file_format} --debug"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
assert os.system(f"python3 {script_path} {command_args}") != 0
|
assert os.system(f"python3 {script_path} {command_args}") != 0
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ def test_no_chaps():
|
||||||
chapters = ""
|
chapters = ""
|
||||||
file_format = "cbz"
|
file_format = "cbz"
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
command_args = f"-u {url_uuid} -l {language} --path {download_path} --format {file_format} --verbose"
|
command_args = f"-u {url_uuid} -l {language} --path {download_path} --format {file_format} --debug"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
assert os.system(f"python3 {script_path} {command_args}") != 0
|
assert os.system(f"python3 {script_path} {command_args}") != 0
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ def test_no_volume():
|
||||||
chapters = "1"
|
chapters = "1"
|
||||||
file_format = "cbz"
|
file_format = "cbz"
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose --forcevol"
|
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug --forcevol"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
assert os.system(f"python3 {script_path} {command_args}") != 0
|
assert os.system(f"python3 {script_path} {command_args}") != 0
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ def test_uuid_link():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
|
|
||||||
assert test.manga_uuid == "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
assert test.manga_uuid == "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ def test_uuid_pure():
|
||||||
url_uuid = "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
url_uuid = "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
|
|
||||||
assert test.manga_uuid == "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
assert test.manga_uuid == "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ def test_uuid_link_false():
|
||||||
url_uuid = "https://mangadex.org/title/a966-76e-5-8a-e2-42-5e-b-549-7f15dd-34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a966-76e-5-8a-e2-42-5e-b-549-7f15dd-34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
|
|
||||||
with pytest.raises(SystemExit) as e:
|
with pytest.raises(SystemExit) as e:
|
||||||
Mangadex(url_uuid, language, forcevol, verbose)
|
Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
assert e.type == SystemExit
|
assert e.type == SystemExit
|
||||||
assert e.value.code == 1
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ def test_title():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
|
|
||||||
assert test.manga_title == "Komi-san wa Komyushou Desu"
|
assert test.manga_title == "Komi-san wa Komyushou Desu"
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ def test_chapter_infos():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
chapter_infos = test.get_chapter_infos("1")
|
chapter_infos = test.get_chapter_infos("1")
|
||||||
chapter_uuid = chapter_infos["uuid"]
|
chapter_uuid = chapter_infos["uuid"]
|
||||||
chapter_name = chapter_infos["name"]
|
chapter_name = chapter_infos["name"]
|
||||||
|
@ -70,10 +70,10 @@ def test_non_existing_manga():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-999999999999/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-999999999999/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
|
|
||||||
with pytest.raises(SystemExit) as e:
|
with pytest.raises(SystemExit) as e:
|
||||||
Mangadex(url_uuid, language, forcevol, verbose)
|
Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
assert e.type == SystemExit
|
assert e.type == SystemExit
|
||||||
assert e.value.code == 1
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
@ -86,10 +86,10 @@ def test_api_failure(monkeypatch):
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
|
|
||||||
with pytest.raises(SystemExit) as e:
|
with pytest.raises(SystemExit) as e:
|
||||||
Mangadex(url_uuid, language, forcevol, verbose)
|
Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
assert e.type == SystemExit
|
assert e.type == SystemExit
|
||||||
assert e.value.code == 1
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ def test_chapter_lang_en():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = True
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, 3)
|
||||||
|
|
||||||
assert test.check_chapter_lang() > 0
|
assert test.check_chapter_lang() > 0
|
||||||
|
|
||||||
|
@ -108,11 +108,11 @@ def test_empty_chapter_lang():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "ch"
|
language = "ch"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
|
|
||||||
with pytest.raises(SystemExit) as e:
|
with pytest.raises(SystemExit) as e:
|
||||||
Mangadex(url_uuid, language, forcevol, verbose)
|
Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
Mangadex(url_uuid, language, forcevol, verbose).check_chapter_lang()
|
Mangadex(url_uuid, language, forcevol, verbosity).check_chapter_lang()
|
||||||
assert e.type == KeyError or e.type == SystemExit
|
assert e.type == KeyError or e.type == SystemExit
|
||||||
assert e.value.code == 1
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
@ -121,10 +121,10 @@ def test_not_existing_lang():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "zz"
|
language = "zz"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
|
|
||||||
with pytest.raises(SystemExit) as e:
|
with pytest.raises(SystemExit) as e:
|
||||||
Mangadex(url_uuid, language, forcevol, verbose)
|
Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
assert e.type == SystemExit
|
assert e.type == SystemExit
|
||||||
assert e.value.code == 1
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ def test_create_chapter_list():
|
||||||
)
|
)
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
test_list = [
|
test_list = [
|
||||||
"1",
|
"1",
|
||||||
"2",
|
"2",
|
||||||
|
@ -170,8 +170,8 @@ def test_create_chapter_list_forcevol():
|
||||||
)
|
)
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = True
|
forcevol = True
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
test_list = [
|
test_list = [
|
||||||
"1:1",
|
"1:1",
|
||||||
"1:2",
|
"1:2",
|
||||||
|
@ -203,8 +203,8 @@ def test_get_chapter_images():
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
img_base_url = "https://uploads.mangadex.org"
|
img_base_url = "https://uploads.mangadex.org"
|
||||||
chapter_hash = "0752bc5db298beff6b932b9151dd8437"
|
chapter_hash = "0752bc5db298beff6b932b9151dd8437"
|
||||||
chapter_uuid = "e86ec2c4-c5e4-4710-bfaa-7604f00939c7"
|
chapter_uuid = "e86ec2c4-c5e4-4710-bfaa-7604f00939c7"
|
||||||
|
@ -235,8 +235,8 @@ def test_get_chapter_images_error(monkeypatch):
|
||||||
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
url_uuid = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
language = "en"
|
language = "en"
|
||||||
forcevol = False
|
forcevol = False
|
||||||
verbose = True
|
verbosity = 3
|
||||||
test = Mangadex(url_uuid, language, forcevol, verbose)
|
test = Mangadex(url_uuid, language, forcevol, verbosity)
|
||||||
chapter_num = "1"
|
chapter_num = "1"
|
||||||
monkeypatch.setattr(requests, "get", fail_url)
|
monkeypatch.setattr(requests, "get", fail_url)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ def test_full_api_mangadex(wait_20s):
|
||||||
forcevol=False,
|
forcevol=False,
|
||||||
download_path="tests",
|
download_path="tests",
|
||||||
download_wait=2,
|
download_wait=2,
|
||||||
verbose=True,
|
verbosity=3,
|
||||||
)
|
)
|
||||||
mdlp.get_manga()
|
mdlp.get_manga()
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def test_full_with_input_cbz(wait_20s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
||||||
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose --wait 2"
|
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
os.system(f"python3 {script_path} {command_args}")
|
os.system(f"python3 {script_path} {command_args}")
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ def test_full_with_input_pdf(wait_20s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.pdf")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.pdf")
|
||||||
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose --wait 2"
|
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
os.system(f"python3 {script_path} {command_args}")
|
os.system(f"python3 {script_path} {command_args}")
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ def test_full_with_input_folder(wait_20s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1")
|
||||||
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format '{file_format}' --verbose --wait 2"
|
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format '{file_format}' --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
os.system(f"python3 {script_path} {command_args}")
|
os.system(f"python3 {script_path} {command_args}")
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ def test_full_with_input_skip_cbz(wait_10s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
||||||
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose --wait 2"
|
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
manga_path.mkdir(parents=True, exist_ok=True)
|
manga_path.mkdir(parents=True, exist_ok=True)
|
||||||
chapter_path.touch()
|
chapter_path.touch()
|
||||||
|
@ -129,7 +129,7 @@ def test_full_with_input_skip_folder(wait_10s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1")
|
||||||
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format '{file_format}' --verbose --wait 2"
|
command_args = f"-u {url_uuid} -l {language} -c {chapters} --path {download_path} --format '{file_format}' --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
chapter_path.mkdir(parents=True, exist_ok=True)
|
chapter_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ def test_full_with_read_cbz(wait_20s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
||||||
command_args = f"--read {str(url_list)} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose --wait 2"
|
command_args = f"--read {str(url_list)} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
url_list.write_text(
|
url_list.write_text(
|
||||||
"https://mangadex.org/title/0aea9f43-d4a9-4bf7-bebc-550a512f9b95/shikimori-s-not-just-a-cutie"
|
"https://mangadex.org/title/0aea9f43-d4a9-4bf7-bebc-550a512f9b95/shikimori-s-not-just-a-cutie"
|
||||||
|
@ -176,7 +176,7 @@ def test_full_with_read_skip_cbz(wait_10s):
|
||||||
download_path = "tests"
|
download_path = "tests"
|
||||||
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
manga_path = Path("tests/Shikimori's Not Just a Cutie")
|
||||||
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
chapter_path = Path("tests/Shikimori's Not Just a Cutie/Ch. 1.cbz")
|
||||||
command_args = f"--read {str(url_list)} -l {language} -c {chapters} --path {download_path} --format {file_format} --verbose --wait 2"
|
command_args = f"--read {str(url_list)} -l {language} -c {chapters} --path {download_path} --format {file_format} --debug --wait 2"
|
||||||
script_path = "manga-dlp.py"
|
script_path = "manga-dlp.py"
|
||||||
manga_path.mkdir(parents=True, exist_ok=True)
|
manga_path.mkdir(parents=True, exist_ok=True)
|
||||||
chapter_path.touch()
|
chapter_path.touch()
|
||||||
|
|
Loading…
Reference in a new issue