nhpdf 1.5__tar.gz → 1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nhpdf-1.5 → nhpdf-1.7}/PKG-INFO +1 -1
- nhpdf-1.7/org_settings.json +24 -0
- {nhpdf-1.5 → nhpdf-1.7}/pyproject.toml +1 -1
- {nhpdf-1.5 → nhpdf-1.7}/src/nhpdf/nhpdf.py +20 -2
- {nhpdf-1.5 → nhpdf-1.7}/.gitignore +0 -0
- {nhpdf-1.5 → nhpdf-1.7}/LICENSE +0 -0
- {nhpdf-1.5 → nhpdf-1.7}/README.md +0 -0
- {nhpdf-1.5 → nhpdf-1.7}/src/nhpdf/__init__.py +0 -0
- {nhpdf-1.5 → nhpdf-1.7}/test.py +0 -0
{nhpdf-1.5 → nhpdf-1.7}/PKG-INFO
RENAMED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"terminal.external.osxExec": "iTerm.app",
|
3
|
+
|
4
|
+
"background.fullscreen": {
|
5
|
+
|
6
|
+
|
7
|
+
// Local images can be dragged into the browser to quickly get the file protocol address from the address bar
|
8
|
+
"images": ["file:///Users/eizen/Documents/papelnapader/+9999Aura.png"],
|
9
|
+
"opacity": 0.1,
|
10
|
+
"size": "cover",
|
11
|
+
"position": "center",
|
12
|
+
"interval": 0,
|
13
|
+
"random": false
|
14
|
+
},
|
15
|
+
// `sidebar` and `panel` have the same config as `fullscreen`
|
16
|
+
"background.sidebar": {},
|
17
|
+
"background.panel": {},
|
18
|
+
"background.enabled": true,
|
19
|
+
"workbench.colorTheme": "dragan",
|
20
|
+
"editor.fontFamily": "JetBrains Mono",
|
21
|
+
"editor.fontLigatures": true,
|
22
|
+
"terminal.integrated.fontLigatures.enabled": true,
|
23
|
+
"terminal.integrated.fontFamily": "monospace",
|
24
|
+
}
|
@@ -9,6 +9,8 @@ import time
|
|
9
9
|
import threading
|
10
10
|
from pathlib import Path
|
11
11
|
from math import trunc
|
12
|
+
import io
|
13
|
+
from PIL import Image
|
12
14
|
|
13
15
|
nhpdf_dir = Path.home()/"Documents"/"nhpdf"
|
14
16
|
nhpdf_dir.mkdir(parents=True, exist_ok=True)
|
@@ -29,20 +31,36 @@ def loading_animation() -> NoReturn:
|
|
29
31
|
def download_image(raw_url: str) -> bytes:
|
30
32
|
global pages, page
|
31
33
|
page += 1
|
32
|
-
img_code, f_type = re.search(r'/(\d+)', raw_url['data-src']).group(), re.search(r'\b(.(jpg|jpeg|png|webp))\b', raw_url['data-src']).group()
|
34
|
+
img_code, f_type = re.search(r'/(\d+)', raw_url['data-src']).group(), re.search(r'\b(.(jpg|jpeg|png|webp|gif|tiff|svg))\b', raw_url['data-src']).group()
|
33
35
|
url = f'https://i3.nhentai.net/galleries{img_code}/{page}{f_type}'
|
34
36
|
response = requests.get(url)
|
35
37
|
if response.status_code == 200:
|
36
|
-
|
38
|
+
content = check_alpha(response.content)
|
39
|
+
return content
|
37
40
|
return None
|
38
41
|
|
39
42
|
def compile_images(raw: list, name: str) -> NoReturn:
|
40
43
|
with ThreadPoolExecutor(max_workers=10) as executor:
|
41
44
|
raw_images = list(executor.map(download_image, raw))
|
45
|
+
for img in raw_images:
|
46
|
+
check_alpha(img)
|
42
47
|
nhpdf = nhpdf_dir/f"{name}.pdf"
|
43
48
|
with open(nhpdf, "wb") as file:
|
44
49
|
file.write(img2pdf.convert(raw_images))
|
45
50
|
|
51
|
+
def check_alpha(image: bytes) -> bytes:
|
52
|
+
try:
|
53
|
+
img2pdf.convert(image)
|
54
|
+
except img2pdf.AlphaChannelError as alphaError:
|
55
|
+
buffered = io.BytesIO(image)
|
56
|
+
img = Image.open(buffered)
|
57
|
+
converted: Image = img.convert('RGB')
|
58
|
+
buf = io.BytesIO()
|
59
|
+
converted.save(buf, format='PNG')
|
60
|
+
image = buf.getvalue()
|
61
|
+
return image
|
62
|
+
|
63
|
+
|
46
64
|
def start_nhpdf():
|
47
65
|
global la, page, pages
|
48
66
|
if len(sys.argv) < 2:
|
File without changes
|
{nhpdf-1.5 → nhpdf-1.7}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|
{nhpdf-1.5 → nhpdf-1.7}/test.py
RENAMED
File without changes
|