add manga title to custom naming placeholders and add first changelog
Some checks failed
ci/woodpecker/push/tests Pipeline failed

This commit is contained in:
Ivan Schaller 2023-01-15 13:19:41 +01:00
parent f1b6d3a189
commit 19effe0fcc
Signed by: olofvndrhr
GPG key ID: 2A6BE07D99C8C205
5 changed files with 46 additions and 18 deletions

View file

@ -9,6 +9,27 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Add support for more sites - Add support for more sites
## [2.2.17] - 2023-01-XX
### Fixed
- Set a timeout of 10 seconds for the api requests
### Added
- `--name-format` and `--name-format-none` flags to add a custom naming scheme for the downloaded files. See
docs: https://manga-dlp.ivn.sh/download/
- More debug log messages
- More tests for the custom naming scheme
- More type hints
### Changed
- In the `--format` option the leading dot is now invalid. `--format .cbz` -> `--format cbz`
- Changed empty values from the api from None to an empty string
- Minor code readability improvements
- Make `--format` a `click.Choice` option
## [2.2.16] - 2022-12-30 ## [2.2.16] - 2022-12-30
### Fixed ### Fixed

View file

@ -97,15 +97,18 @@ This will download the chapter and save it as a zip archive.
## Set chapter naming format ## Set chapter naming format
You can specify the naming format of the downloaded chapters with the `--name-format` option. You can specify the naming format of the downloaded chapters with the `--name-format` option.
Just be sure that you use quotation marks so that the cli parser interprets it as one string.
Available placeholders are: Available placeholders are:
- `{manga_title}` -> The name of the manga
- `{chapter_name}` -> The name of the chapter - `{chapter_name}` -> The name of the chapter
- `{chapter_vol}` -> The volume number of the chapter - `{chapter_vol}` -> The volume number of the chapter
- `{chapter_num}` -> The chapter number - `{chapter_num}` -> The chapter number
**Example:** **Example:**
- Manga title: "Test title"
- Chapter name: "Test chapter" - Chapter name: "Test chapter"
- Chapter volume: 3 - Chapter volume: 3
- Chapter number: 2 - Chapter number: 2
@ -123,6 +126,7 @@ with the `--name-format-none` flag.
**Example:** **Example:**
- Manga title: "Test title"
- Chapter name: "Test chapter" - Chapter name: "Test chapter"
- Chapter volume: - Chapter volume:
- Chapter number: 2 - Chapter number: 2

View file

@ -153,11 +153,11 @@ class Mangadex:
for chapter in r.json()["data"]: for chapter in r.json()["data"]:
attributes: dict = chapter["attributes"] attributes: dict = chapter["attributes"]
# chapter infos from feed # chapter infos from feed
chapter_num = attributes.get("chapter", "") or "" chapter_num = attributes.get("chapter") or ""
chapter_vol = attributes.get("volume", "") or "" chapter_vol = attributes.get("volume") or ""
chapter_uuid = chapter.get("id", "") or "" chapter_uuid = chapter.get("id") or ""
chapter_name = attributes.get("title", "") or "" chapter_name = attributes.get("title") or ""
chapter_external = attributes.get("externalUrl", "") or "" chapter_external = attributes.get("externalUrl") or ""
# check for chapter title and fix it # check for chapter title and fix it
if chapter_name: if chapter_name:

View file

@ -278,6 +278,7 @@ class MangaDLP:
# get filename for chapter (without suffix) # get filename for chapter (without suffix)
chapter_filename = utils.get_filename( chapter_filename = utils.get_filename(
self.manga_title,
chapter_infos["name"], chapter_infos["name"],
chapter_infos["volume"], chapter_infos["volume"],
chapter, chapter,

View file

@ -99,6 +99,7 @@ def fix_name(filename: str) -> str:
# create name for chapter # create name for chapter
def get_filename( def get_filename(
manga_title: str,
chapter_name: str, chapter_name: str,
chapter_vol: str, chapter_vol: str,
chapter_num: str, chapter_num: str,
@ -111,6 +112,7 @@ def get_filename(
log.debug(f"Using custom name format: '{name_format}'") log.debug(f"Using custom name format: '{name_format}'")
try: try:
filename = name_format.format( filename = name_format.format(
manga_title=manga_title or name_format_none,
chapter_name=chapter_name or name_format_none, chapter_name=chapter_name or name_format_none,
chapter_vol=chapter_vol or name_format_none, chapter_vol=chapter_vol or name_format_none,
chapter_num=chapter_num or name_format_none, chapter_num=chapter_num or name_format_none,
@ -120,27 +122,27 @@ def get_filename(
else: else:
return filename return filename
# set vol to 0 if none found
chapter_vol = chapter_vol or "0"
# use default format # use default format
log.debug("Using default name format") log.debug("Using default name format")
# if chapter is a oneshot # if chapter is a oneshot
if not chapter_num: if not chapter_num or "oneshot" in [chapter_name.lower(), chapter_num.lower()]:
return "Oneshot"
if "oneshot" in [chapter_name.lower(), chapter_num.lower()]:
return "Oneshot" return "Oneshot"
# if the chapter has no name # if the chapter has no name
if not chapter_name and forcevol:
return f"Vol. {chapter_vol} Ch. {chapter_num}"
if not chapter_name: if not chapter_name:
return ( return f"Ch. {chapter_num}"
f"Vol. {chapter_vol} Ch. {chapter_num}"
if forcevol
else f"Ch. {chapter_num}"
)
# if the chapter has a name # if the chapter has a name
# return with volume if option is set, else just the chapter num and name # return with volume if option is set, else just the chapter num and name
return ( if forcevol:
f"Vol. {chapter_vol} Ch. {chapter_num} - {chapter_name}" return f"Vol. {chapter_vol} Ch. {chapter_num} - {chapter_name}"
if forcevol
else f"Ch. {chapter_num} - {chapter_name}" return f"Ch. {chapter_num} - {chapter_name}"
)
def progress_bar(progress: float, total: float) -> None: def progress_bar(progress: float, total: float) -> None: