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..e9aa804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Add support for more sites +## [2.1.5] - 2022-06-18 + +### Fixed + +- Image names now have a suffix, as some comic readers have problems with no + suffix [fixes issue #2] + +### Added + +- `--format` section in the README + ## [2.1.4] - 2022-05-29 ### Fixed 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/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/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) 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", 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)