Skip to content

Commit

Permalink
Merge pull request '[2.2.19] - 2023-02-11' (#38) from dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
olofvndrhr committed Feb 11, 2023
2 parents 406a665 + 0b6d263 commit 059aca8
Show file tree
Hide file tree
Showing 23 changed files with 315 additions and 159 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mangas.txt
.idea/
venv
test.sh
.ruff_cache/

### Python template
# Byte-compiled / optimized / DLL files
Expand Down
6 changes: 3 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
python 3.9.13 3.10.5 3.8.13
shellcheck 0.9.0
shfmt 3.6.0
shellcheck 0.8.0
just 1.13.0
direnv 2.32.1
direnv 2.32.2
just 1.13.0
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Add support for more sites

## [2.2.19] - 2023-02-11

### Added

- First version of the chapter cache (very basic functionality)

### Fixed

- Fixed all exception re-raises to include the original stack trace

### Changed

- Simplified chapter download loop

## [2.2.18] - 2023-01-21

### Fixed
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,27 @@ Script to download mangas from various sites
Options:
--help Show this message and exit.
--version Show the version and exit.
source: [mutually_exclusive, required]
-u, --url, --uuid TEXT URL or UUID of the manga
--read FILE Path of file with manga links to download. One per line
-u, --url, --uuid TEXT URL or UUID of the manga
--read FILE Path of file with manga links to download. One per line
verbosity: [mutually_exclusive]
--loglevel INTEGER Custom log level [default: 20]
--warn Only log warnings and higher
--debug Debug logging. Log EVERYTHING
--loglevel INTEGER Custom log level
--warn Only log warnings and higher
--debug Debug logging. Log EVERYTHING
-c, --chapters TEXT Chapters to download
-p, --path PATH Download path [default: downloads]
-l, --language TEXT Manga language [default: en]
--list List all available chapters
--format TEXT Archive format to create. An empty string means dont archive the folder [default: cbz]
--format [cbz|cbr|zip|pdf|] Archive format to create. An empty string means dont archive the folder [default: cbz]
--name-format TEXT Naming format to use when saving chapters. See docs for more infos [default: {default}]
--name-format-none TEXT String to use when the variable of the custom name format is empty
--forcevol Force naming of volumes. For mangas where chapters reset each volume
--wait FLOAT Time to wait for each picture to download in seconds(float) [default: 0.5]
--hook-manga-pre TEXT Commands to execute before the manga download starts
--hook-manga-post TEXT Commands to execute after the manga download finished
--hook-chapter-pre TEXT Commands to execute before the chapter download starts
--hook-chapter-post TEXT Commands to execute after the chapter download finished
--cache-path PATH Where to store the cache-db. If no path is given, cache is disabled
```

## Contribution / Bugs
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM cr.44net.ch/baseimages/debian-s6:11.5-linux-amd64
FROM cr.44net.ch/baseimages/debian-s6:11.6-linux-amd64

# set version label
ARG BUILD_VERSION
ENV MDLP_VERSION=${BUILD_VERSION}
ENV IMAGE_VERSION=${BUILD_VERSION}
LABEL version="${BUILD_VERSION}"
LABEL maintainer="Ivan Schaller"
LABEL description="A CLI manga downloader"
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM cr.44net.ch/baseimages/debian-s6:11.5-linux-arm64
FROM cr.44net.ch/baseimages/debian-s6:11.6-linux-arm64

# set version label
ARG BUILD_VERSION
ENV MDLP_VERSION=${BUILD_VERSION}
ENV IMAGE_VERSION=${BUILD_VERSION}
LABEL version="${BUILD_VERSION}"
LABEL maintainer="Ivan Schaller"
LABEL description="A CLI manga downloader"
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,11 @@ link3
`python3 manga-dlp.py --read mangas.txt --list`

This will list all available chapters for link1, link2 and link3.

## Create basic cache

With the `--cache-path <cache file>` option you can let the script create a very basic json cache. Your downloaded
chapters will be
tracked there, and the script doesn't have to check on disk if you already downloaded it.

If the option is unset (default), then no caching will be done.
18 changes: 9 additions & 9 deletions docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@ Script to download mangas from various sites
Options:
--help Show this message and exit.
--version Show the version and exit.
source: [mutually_exclusive, required]
-u, --url, --uuid TEXT URL or UUID of the manga
--read FILE Path of file with manga links to download. One per line
-u, --url, --uuid TEXT URL or UUID of the manga
--read FILE Path of file with manga links to download. One per line
verbosity: [mutually_exclusive]
--loglevel INTEGER Custom log level [default: 20]
--warn Only log warnings and higher
--debug Debug logging. Log EVERYTHING
--loglevel INTEGER Custom log level
--warn Only log warnings and higher
--debug Debug logging. Log EVERYTHING
-c, --chapters TEXT Chapters to download
-p, --path PATH Download path [default: downloads]
-l, --language TEXT Manga language [default: en]
--list List all available chapters
--format TEXT Archive format to create. An empty string means dont archive the folder [default: cbz]
--format [cbz|cbr|zip|pdf|] Archive format to create. An empty string means dont archive the folder [default: cbz]
--name-format TEXT Naming format to use when saving chapters. See docs for more infos [default: {default}]
--name-format-none TEXT String to use when the variable of the custom name format is empty
--forcevol Force naming of volumes. For mangas where chapters reset each volume
--wait FLOAT Time to wait for each picture to download in seconds(float) [default: 0.5]
--hook-manga-pre TEXT Commands to execute before the manga download starts
--hook-manga-post TEXT Commands to execute after the manga download finished
--hook-chapter-pre TEXT Commands to execute before the chapter download starts
--hook-chapter-post TEXT Commands to execute after the chapter download finished
--cache-path PATH Where to store the cache-db. If no path is given, cache is disabled
```

## Contribution / Bugs
Expand Down
2 changes: 1 addition & 1 deletion mangadlp/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.2.18"
__version__ = "2.2.19"
25 changes: 11 additions & 14 deletions mangadlp/api/mangadex.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ def __init__(self, url_uuid: str, language: str, forcevol: bool):
self.api_additions = f"{self.api_language}&{self.api_content_ratings}"

# infos from functions
try:
self.manga_uuid = self.get_manga_uuid()
self.manga_data = self.get_manga_data()
self.manga_title = self.get_manga_title()
self.manga_chapter_data = self.get_chapter_data()
self.chapter_list = self.create_chapter_list()
except Exception as exc:
raise RuntimeError from exc
self.manga_uuid = self.get_manga_uuid()
self.manga_data = self.get_manga_data()
self.manga_title = self.get_manga_title()
self.manga_chapter_data = self.get_chapter_data()
self.chapter_list = self.create_chapter_list()

# get the uuid for the manga
def get_manga_uuid(self) -> str:
Expand All @@ -65,7 +62,7 @@ def get_manga_uuid(self) -> str:
uuid = uuid_regex.search(self.url_uuid)[0] # type: ignore
except Exception as exc:
log.error("No valid UUID found")
raise KeyError("No valid UUID found") from exc
raise exc

return uuid

Expand All @@ -81,7 +78,7 @@ def get_manga_data(self) -> dict:
except Exception as exc:
if counter >= 3:
log.error("Maybe the MangaDex API is down?")
raise ConnectionError("Maybe the MangaDex API is down?") from exc
raise exc
log.error("Mangadex API not reachable. Retrying")
sleep(2)
counter += 1
Expand All @@ -90,7 +87,7 @@ def get_manga_data(self) -> dict:
# check if manga exists
if response.json()["result"] != "ok":
log.error("Manga not found")
raise KeyError("Manga not found")
raise KeyError

return response.json()["data"]

Expand All @@ -101,7 +98,7 @@ def get_manga_title(self) -> str:
# try to get the title in requested language
try:
title = attributes["title"][self.language]
except Exception:
except KeyError:
log.info("Manga title not found in requested language. Trying alt titles")
else:
log.debug(f"Language={self.language}, Title='{title}'")
Expand All @@ -115,7 +112,7 @@ def get_manga_title(self) -> str:
alt_title = item
break
title = alt_title[self.language]
except Exception:
except (KeyError, UnboundLocalError):
log.warning(
"Manga title also not found in alt titles. Falling back to english title"
)
Expand All @@ -140,7 +137,7 @@ def check_chapter_lang(self) -> int:
log.error(
"Error retrieving the chapters list. Did you specify a valid language code?"
)
raise KeyError from exc
raise exc
else:
if total_chapters == 0:
log.error("No chapters available to download in specified language")
Expand Down
Loading

0 comments on commit 059aca8

Please sign in to comment.