nhpdf 1.6__py3-none-any.whl → 1.7__py3-none-any.whl
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/nhpdf.py
CHANGED
@@ -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)
|
@@ -33,16 +35,32 @@ def download_image(raw_url: str) -> bytes:
|
|
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:
|
@@ -0,0 +1,6 @@
|
|
1
|
+
nhpdf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
nhpdf/nhpdf.py,sha256=YQl9bsXDgv7uJTpW_iiCRDFyRahJYVPKvscbtKC-sgs,3758
|
3
|
+
nhpdf-1.7.dist-info/METADATA,sha256=NbXvJvEAQTbGQsxL3Ok6vyeQTlXStb9Nkzvsxu7RDMw,2873
|
4
|
+
nhpdf-1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
+
nhpdf-1.7.dist-info/entry_points.txt,sha256=Dn0ISURSvQrGZMCOxYEA5ocSWU5DUOiT50J7FHZk5Xs,50
|
6
|
+
nhpdf-1.7.dist-info/RECORD,,
|
nhpdf-1.6.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
nhpdf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
nhpdf/nhpdf.py,sha256=-o0ryeh69xNosrLmP8SD_MIOawLXvKb6x3vo1oFmpPw,3265
|
3
|
-
nhpdf-1.6.dist-info/METADATA,sha256=wqI6ZqBEwE6Vc2SSGehddMfwqH10JeaLObON9venzD8,2873
|
4
|
-
nhpdf-1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
-
nhpdf-1.6.dist-info/entry_points.txt,sha256=Dn0ISURSvQrGZMCOxYEA5ocSWU5DUOiT50J7FHZk5Xs,50
|
6
|
-
nhpdf-1.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|