Skip to content

Commit 971bb94

Browse files
authored
Merge pull request #136 from hentai-chan/rec-hentai
v3.2.8
2 parents f4548d5 + ea77bc6 commit 971bb94

File tree

9 files changed

+225
-115
lines changed

9 files changed

+225
-115
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
indent_style = 4
5+
indent_style = tab
6+
tab_width = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespaces = true
10+
insert_final_newline = true
11+
max_line_length = 160
12+
13+
[*.yml]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[*.py]
18+
indent_style = space
19+
indent_size = 4

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# Changelog
22

3+
## Version 3.2.8 (28 Aug 2021)
4+
5+
The log file path has been changed to a new, platform-specific location which is
6+
accessible via code through the `get_logfile_path` method. Page objects now also
7+
implement a download method which makes it possible to download individual pages:
8+
9+
```python
10+
from hentai import Hentai
11+
doujin = Hentai(177013)
12+
13+
# download the last page to the CWD
14+
doujin.pages[-1].download(doujin.handler)
15+
```
16+
17+
Another noticeably change took place in the download method of `Hentai` objects:
18+
The `zip` option has been renamed to `zip_dir` to prevent conflicts with the built-in
19+
`zip` method from the Python standard library. On top of all of that, its implementation
20+
has also changed: archives created as a result of this operation use a `.zip` extension
21+
on Windows platforms (as it already did previously), and `.tar.gz` on macOS and
22+
Linux platforms (which is what's new). It also uses a more aggressive compression
23+
configuration, which makes for smaller archives but also increases the overall
24+
execution time.
25+
26+
Additionally, a bug related to the previous implementation has been fixed
27+
by Shikanime Deva (<deva.shikanime@protonmail.com>) that was also caused by the
28+
(former) `zip` option in which the download directory was not properly cleaned up
29+
afterwards.
30+
31+
The `--verbose` option in the CLI is now turned on by default. You can revert this
32+
change by using the `--no-verbose` flag to run this command in scripts silently.
33+
34+
Last but not least, the underlying `RequestHandler` class experienced a few minor
35+
optimizations which also affects the `Hentai` class.
36+
337
## Version 3.2.7 (29 June 2021)
438

539
Makes the `Hentai` class hashable and changes the return type of some methods from

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<a href="https://hentaichan.pythonanywhere.com/projects/hentai" title="Project Logo">
2+
<a href="https://www.hentai-chan.dev/projects/hentai" title="Project Logo">
33
<img height="150" style="margin-top:15px" src="https://raw.githubusercontent.com/hentai-chan/hentai/master/docs/hentai.svg">
44
</a>
55
</p>
@@ -164,7 +164,7 @@ doujins within the terminal:
164164
hentai --help
165165
166166
# download this doujin to the CWD
167-
hentai --verbose download --id 177013
167+
hentai download --id 177013
168168
169169
# check the module version
170170
hentai --version

README.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<a href="https://hentaichan.pythonanywhere.com/projects/hentai" title="Project Logo">
2+
<a href="https://www.hentai-chan.dev/projects/hentai" title="Project Logo">
33
<img height="150" style="margin-top:15px" src="https://raw.githubusercontent.com/hentai-chan/hentai/master/docs/hentai.svg">
44
</a>
55
</p>
@@ -155,7 +155,7 @@ Utils.export(popular_loli, filename=Path('popular_loli.json'), options=custom)
155155
hentai --help
156156
157157
# 将此同人下载到CWD
158-
hentai --verbose download --id 177013
158+
hentai download --id 177013
159159
160160
# 查看模组版本
161161
hentai --version

requirements/release.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
tqdm==4.61.1
2-
requests==2.25.1
1+
tqdm==4.62.2
2+
requests==2.26.0

src/hentai/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import argparse
4+
import errno
45
import sys
56
from pathlib import Path
67

@@ -16,7 +17,7 @@ def main():
1617
parser._optionals.title = 'Arguments'
1718

1819
parser.add_argument('-v', '--version', action='version', version=f"%(prog)s {__version__}")
19-
parser.add_argument('-V', '--verbose', action='store_true', help="increase output verbosity")
20+
parser.add_argument('-V', '--verbose', default=True, action=argparse.BooleanOptionalAction, help="increase output verbosity")
2021

2122
subparser = parser.add_subparsers(dest='command')
2223

@@ -28,7 +29,7 @@ def main():
2829
preview_parser.add_argument('--id', type=int, nargs='+', required=True, help="magic number")
2930

3031
args = parser.parse_args()
31-
32+
3233
if args.command == 'download':
3334
count = len(args.id)
3435
for id_ in args.id:
@@ -38,9 +39,9 @@ def main():
3839
except HTTPError as error:
3940
print(f"\033[31mDownloadError:\033[0m {error}", file=sys.stderr)
4041
count -= 1
41-
if count: print(f"Stored {count} doujin{'s' if count > 1 else ''} in {str(args.dest)!r}")
42-
43-
if args.command == 'preview':
42+
if count:
43+
print(f"Stored {count} doujin{'s' if count > 1 else ''} in {str(args.dest)!r}")
44+
elif args.command == 'preview':
4445
for id_ in args.id:
4546
try:
4647
doujin = Hentai(id_)
@@ -50,6 +51,9 @@ def main():
5051
print(f"pages:\t{doujin.num_pages}", end='\n\n' if id_ != len(args.id) else '')
5152
except HTTPError as error:
5253
print(f"\033[31mPreviewError:\033[0m {error}", file=sys.stderr)
54+
else:
55+
parser.print_help(sys.stderr)
56+
sys.stderr(errno.EINVAL)
5357

5458
if __name__ == '__main__':
5559
main()

0 commit comments

Comments
 (0)