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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nhpdf
3
- Version: 1.5
3
+ Version: 1.7
4
4
  Summary: Download NHentai doujins as PDF
5
5
  Project-URL: Homepage, https://github.com/Aze543/NhentaiDoujinToPDFMaker
6
6
  Project-URL: Issues, https://github.com/Aze543/NhentaiDoujinToPDFMaker/issues
@@ -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
+ }
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nhpdf"
7
- version = "1.5"
7
+ version = "1.7"
8
8
  dependencies = [
9
9
  "beautifulsoup4",
10
10
  "img2pdf",
@@ -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
- return response.content
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
File without changes
File without changes
File without changes
File without changes