From 10c9fc47b7058d8016dc27929e2f546f57d6e9a1 Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Fri, 17 Jun 2022 23:39:01 +0200 Subject: [PATCH 1/5] fix image suffix and add readme entry of --format --- README.md | 30 +++++++++++++++++++++++++++--- mangadlp/downloader.py | 16 +++++++++------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0d29ad5..4a879a6 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,6 @@ See the docker [README](./docker/README.md) ## Options -> "--format" currently only works with "", "pdf", "zip", "rar" and "cbz". As it just renames the zip file with the new -> suffix (except pdf). For pdf creation you have to install img2pdf. - ```txt usage: manga-dlp.py [-h] (-u URL_UUID | --read READ | -v) [-c CHAPTERS] [-p PATH] [-l LANG] [--list] [--format FORMAT] [--forcevol] [--wait WAIT] [--verbose] @@ -169,6 +166,33 @@ is `/downloads`. Absolute and relative paths are supported. This will save all mangas/chapters in the path `/media/mangas//` +### Set output format + +> `--format` currently only works with `""`, `"pdf"`, `"zip"`, `"rar"` and `"cbz"`. +> As it just renames the zip file with the new +> suffix (except pdf). + +You can specify the output format of the manga images with the `--format` option. +The default is set to `.cbz`, so if no format is given it falls back to `/.cbz` + +For pdf creation you have to install [img2pdf](https://pypi.org/project/img2pdf/). +With the amd64 docker image it is already installed +see more in the Docker [README.md](docker/README.md). + +#### Supported format options are: + +* cbz - `--format "cbz"` or `--format ".cbz"` **- default** +* cbr - `--format "cbr"` or `--format ".cbr"` +* zip - `--format "zip"` or `--format ".zip"` +* pdf - `--format "pdf"` or `--format ".pdf"` +* _none_ - `--format ""` - this saves the images just in a folder + +#### Example: + +`python3 manga-dlp.py --format "zip"` + +This will download the chapter and save it as a zip archive. + ## Contribution / Bugs For suggestions for improvement, just open a pull request. diff --git a/mangadlp/downloader.py b/mangadlp/downloader.py index d3efb6c..4f7cd04 100644 --- a/mangadlp/downloader.py +++ b/mangadlp/downloader.py @@ -13,21 +13,23 @@ def download_chapter( image_urls: list, chapter_path: str or Path, download_wait: float, verbose: bool ) -> None: total_img = len(image_urls) - for img_num, img in enumerate(image_urls, 1): + for image_num, image in enumerate(image_urls, 1): + # get image suffix + image_suffix = str(Path(image).suffix) or ".png" # set image path - image_path = Path(f"{chapter_path}/{img_num:03d}") + image_path = Path(f"{chapter_path}/{image_num:03d}{image_suffix}") # show progress bar if verbose logging is not active if verbose: - print(f"INFO: Downloading image {img_num}/{total_img}") + print(f"INFO: Downloading image {image_num}/{total_img}") else: - utils.progress_bar(img_num, total_img) + utils.progress_bar(image_num, total_img) counter = 1 while counter <= 3: try: - r = requests.get(img, stream=True) + r = requests.get(image, stream=True) if r.status_code != 200: - print(f"ERR: Request for image {img} failed, retrying") + print(f"ERR: Request for image {image} failed, retrying") raise ConnectionError except KeyboardInterrupt: print("ERR: Stopping") @@ -50,5 +52,5 @@ def download_chapter( print("ERR: Can't write file") raise IOError - img_num += 1 + image_num += 1 sleep(download_wait) From a11c9438e76ea3aac4ceb2b479df77fa841b860c Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Fri, 17 Jun 2022 23:57:52 +0200 Subject: [PATCH 2/5] push version --- .woodpecker/build_docker.yml | 4 +++- .woodpecker/publish_docker.yml | 2 ++ CHANGELOG.md | 10 ++++++++++ docker/Dockerfile.amd64 | 6 ++---- docker/Dockerfile.arm64 | 6 ++---- manga-dlp.py | 2 +- mangadlp/input.py | 2 +- setup.py | 2 +- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.woodpecker/build_docker.yml b/.woodpecker/build_docker.yml index 86e580a..b39268c 100644 --- a/.woodpecker/build_docker.yml +++ b/.woodpecker/build_docker.yml @@ -30,6 +30,7 @@ pipeline: dockerfile: docker/Dockerfile.amd64 auto_tag: true auto_tag_suffix: linux-amd64 + build_args: BUILD_DATE="$(date +%Y-%m-%d_%H:%M)" # build docker image for arm64 dryrun-build-arm64: @@ -44,5 +45,6 @@ pipeline: platforms: linux/arm64 dockerfile: docker/Dockerfile.arm64 auto_tag: true - auto_tag_suffix: linux-arm64 + auto_tag_suffix: linux-arm64# + build_args: BUILD_DATE="$(date +%Y-%m-%d_%H:%M)" diff --git a/.woodpecker/publish_docker.yml b/.woodpecker/publish_docker.yml index 364bd83..9e71224 100644 --- a/.woodpecker/publish_docker.yml +++ b/.woodpecker/publish_docker.yml @@ -29,6 +29,7 @@ pipeline: dockerfile: docker/Dockerfile.amd64 auto_tag: true auto_tag_suffix: linux-amd64 + build_args: BUILD_DATE="$(date +%Y-%m-%d_%H:%M)" username: from_secret: cr-dhub-username password: @@ -47,6 +48,7 @@ pipeline: dockerfile: docker/Dockerfile.arm64 auto_tag: true auto_tag_suffix: linux-arm64 + build_args: BUILD_DATE="$(date +%Y-%m-%d_%H:%M)" username: from_secret: cr-dhub-username password: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7901524..fc45cfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,16 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Add support for more sites +## [2.1.5] - 2022-06-17 + +### Fixed + +- Image names now have a suffix, as some comic readers have problems with no suffix + +### Added + +- `--format` section in the README + ## [2.1.4] - 2022-05-29 ### Fixed diff --git a/docker/Dockerfile.amd64 b/docker/Dockerfile.amd64 index 23068c9..2cf4d3f 100644 --- a/docker/Dockerfile.amd64 +++ b/docker/Dockerfile.amd64 @@ -1,13 +1,11 @@ FROM cr.44net.ch/baseimages/debian-s6:1.3.5 # set version label +ENV MDLP_VERSION=2.1.5 ARG BUILD_DATE -ARG VERSION -LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL build_version="Version: ${MDLP_VERSION} - Build-date: ${BUILD_DATE}" LABEL maintainer="Ivan Schaller" -# manga-dlp version -ENV MDLP_VERSION=2.1.4 # install packages RUN \ diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index a1c5510..9f92aeb 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -1,13 +1,11 @@ FROM cr.44net.ch/baseimages/debian-s6:1.3.5 # set version label +ENV MDLP_VERSION=2.1.5 ARG BUILD_DATE -ARG VERSION -LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL build_version="Version: ${MDLP_VERSION} - Build-date: ${BUILD_DATE}" LABEL maintainer="Ivan Schaller" -# manga-dlp version -ENV MDLP_VERSION=2.1.4 # install packages RUN \ diff --git a/manga-dlp.py b/manga-dlp.py index 75dfe24..1251e84 100644 --- a/manga-dlp.py +++ b/manga-dlp.py @@ -3,7 +3,7 @@ import sys from mangadlp.input import get_args -mangadlp_version = "2.1.4" +mangadlp_version = "2.1.5" def get_input(): diff --git a/mangadlp/input.py b/mangadlp/input.py index 4ae6871..d9096fe 100644 --- a/mangadlp/input.py +++ b/mangadlp/input.py @@ -4,7 +4,7 @@ from pathlib import Path import mangadlp.app as app -mangadlp_version = "2.1.4" +mangadlp_version = "2.1.5" def check_args(args): diff --git a/setup.py b/setup.py index 151d055..f2e591c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = readme.read_text() setuptools.setup( name="manga-dlp", - version="2.1.4", + version="2.1.5", author="Ivan Schaller", author_email="ivan@schaller.sh", description="A cli manga downloader", From c4f6ac727cd3016fcc5150167530c50228e63661 Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sat, 18 Jun 2022 00:01:55 +0200 Subject: [PATCH 3/5] fix test --- tests/test_03_downloader.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_03_downloader.py b/tests/test_03_downloader.py index 6f42fe6..52c9d2d 100644 --- a/tests/test_03_downloader.py +++ b/tests/test_03_downloader.py @@ -1,8 +1,10 @@ +import shutil from pathlib import Path + import pytest import requests + import mangadlp.downloader as downloader -import shutil def test_downloader(): @@ -21,7 +23,7 @@ def test_downloader(): images.append(file.name) print(images) - assert images == ["001", "002", "003", "004", "005"] + assert images == ["001.png", "002.png", "003.png", "004.png", "005.png"] # cleanup shutil.rmtree(chapter_path, ignore_errors=True) From 67f4a286e110f1c317b102dcf257ea95d68ed77a Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sat, 18 Jun 2022 00:05:21 +0200 Subject: [PATCH 4/5] fix date [CI SKIP] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc45cfc..891d4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Add support for more sites -## [2.1.5] - 2022-06-17 +## [2.1.5] - 2022-06-18 ### Fixed From b96470a4f6b5eeeb405ec682dee97149fdaa9e21 Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sat, 18 Jun 2022 00:12:23 +0200 Subject: [PATCH 5/5] add issue in changelog [CI SKIP] --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 891d4be..e9aa804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed -- Image names now have a suffix, as some comic readers have problems with no suffix +- Image names now have a suffix, as some comic readers have problems with no + suffix [fixes issue #2] ### Added