nhpdf 1.0__tar.gz → 1.2__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.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jack Maney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nhpdf
3
- Version: 1.0
3
+ Version: 1.2
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
@@ -8,7 +8,7 @@ Author-email: Aze543 <eizen.9258437663@gmail.com>
8
8
  Maintainer-email: Aze543 <eizen.9258437663@gmail.com>
9
9
  License-Expression: MIT
10
10
  Keywords: goon,pdf,scraper
11
- Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Development Status :: 4 - Beta
12
12
  Classifier: Programming Language :: Python
13
13
  Requires-Python: >=3.8
14
14
  Requires-Dist: beautifulsoup4
@@ -42,23 +42,12 @@ nhpdf 566212 563102 345987
42
42
 
43
43
  ### 🔧 How to Install (CLI Version)
44
44
 
45
- You can install the CLI tool in two ways:
46
-
47
- #### Option 1: From PyPI
45
+ You can install the CLI tool directly from the PyPI as long as you have Python (Refer to the 2nd flavors first step to install it):
48
46
 
49
47
  ```bash
50
48
  pip install nhpdf
51
49
  ```
52
50
 
53
- #### Option 2: Locally (Development)
54
-
55
- If you’ve cloned this repo:
56
-
57
- ```bash
58
- cd NhentaiDoujinToPDFMaker
59
- pip install .
60
- ```
61
-
62
51
  Now you can run it with:
63
52
 
64
53
  ```bash
@@ -79,13 +68,13 @@ python3 main.py
79
68
 
80
69
  ---
81
70
 
82
- ### 📥 How to Set Up (Script Version)
71
+ ### 📥 How to Set Up the Script
83
72
 
84
73
  > These instructions focus on **macOS**, but should work on **Windows** too (with small changes).
85
74
 
86
75
  #### 1. Install Python
87
76
 
88
- Search how to install Python for your OS.
77
+ Go to the [PythonWebsite](https://www.python.org/downloads/) to install Python for your OS.
89
78
 
90
79
  Check if Python is installed:
91
80
 
@@ -94,7 +83,7 @@ Check if Python is installed:
94
83
  python
95
84
  ```
96
85
 
97
- - **macOS**:
86
+ - **macOS/Linux**:
98
87
  ```bash
99
88
  python3
100
89
  ```
@@ -135,7 +124,7 @@ python main.py
135
124
  python3 main.py
136
125
  ```
137
126
 
138
- You should see:
127
+ You should see an ascii logo:
139
128
 
140
129
  ```
141
130
  NHENTAI DOUJIN-TO-PDF MAKER
@@ -24,23 +24,12 @@ nhpdf 566212 563102 345987
24
24
 
25
25
  ### 🔧 How to Install (CLI Version)
26
26
 
27
- You can install the CLI tool in two ways:
28
-
29
- #### Option 1: From PyPI
27
+ You can install the CLI tool directly from the PyPI as long as you have Python (Refer to the 2nd flavors first step to install it):
30
28
 
31
29
  ```bash
32
30
  pip install nhpdf
33
31
  ```
34
32
 
35
- #### Option 2: Locally (Development)
36
-
37
- If you’ve cloned this repo:
38
-
39
- ```bash
40
- cd NhentaiDoujinToPDFMaker
41
- pip install .
42
- ```
43
-
44
33
  Now you can run it with:
45
34
 
46
35
  ```bash
@@ -61,13 +50,13 @@ python3 main.py
61
50
 
62
51
  ---
63
52
 
64
- ### 📥 How to Set Up (Script Version)
53
+ ### 📥 How to Set Up the Script
65
54
 
66
55
  > These instructions focus on **macOS**, but should work on **Windows** too (with small changes).
67
56
 
68
57
  #### 1. Install Python
69
58
 
70
- Search how to install Python for your OS.
59
+ Go to the [PythonWebsite](https://www.python.org/downloads/) to install Python for your OS.
71
60
 
72
61
  Check if Python is installed:
73
62
 
@@ -76,7 +65,7 @@ Check if Python is installed:
76
65
  python
77
66
  ```
78
67
 
79
- - **macOS**:
68
+ - **macOS/Linux**:
80
69
  ```bash
81
70
  python3
82
71
  ```
@@ -117,7 +106,7 @@ python main.py
117
106
  python3 main.py
118
107
  ```
119
108
 
120
- You should see:
109
+ You should see an ascii logo:
121
110
 
122
111
  ```
123
112
  NHENTAI DOUJIN-TO-PDF MAKER
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nhpdf"
7
- version = "1.0"
7
+ version = "1.2"
8
8
  dependencies = [
9
9
  "beautifulsoup4",
10
10
  "img2pdf",
@@ -23,7 +23,7 @@ license = "MIT"
23
23
  license-files = ["LICEN[CS]E.*"]
24
24
  keywords = ["pdf", "scraper", "goon"]
25
25
  classifiers = [
26
- "Development Status :: 5 - Production/Stable",
26
+ "Development Status :: 4 - Beta",
27
27
  "Programming Language :: Python"
28
28
  ]
29
29
 
@@ -2,37 +2,43 @@ import img2pdf # type: ignore
2
2
  import requests
3
3
  from typing import NoReturn
4
4
  from bs4 import BeautifulSoup
5
+ from concurrent.futures import ThreadPoolExecutor
5
6
  import re
6
7
  import sys
7
8
  import time
8
9
  import threading
9
10
  from pathlib import Path
11
+ from math import trunc
10
12
 
11
13
  nhpdf_dir = Path.home()/"Documents"/"nhpdf"
12
14
  nhpdf_dir.mkdir(parents=True, exist_ok=True)
13
15
 
14
- def loading_animation():
16
+ def loading_animation() -> NoReturn:
15
17
  global la, pages, page
16
18
  spinner = ['|', '/', '-', '\\']
17
19
  while not la:
18
20
  for frame in spinner:
19
- sys.stdout.write(f'\rDownloading the pages ({page}/{pages})...{frame}')
21
+ sys.stdout.write(f'\rDownloading the pages ({trunc(((page-1)/pages)*100)}%/{100}%)...{frame}')
20
22
  sys.stdout.flush()
21
23
  time.sleep(0.1)
22
24
  if la:
25
+ sys.stdout.write(f'\rDownloading the pages (100%/100%)...{frame}')
26
+ sys.stdout.flush()
23
27
  break
24
-
25
- def compile_images(raw: list, name: str) -> NoReturn:
28
+
29
+ def download_image(raw_url: str) -> bytes:
26
30
  global pages, page
27
- raw_images = []
28
- for item in raw:
29
- page += 1
30
- img_code, f_type = re.search(r'/(\d+)', item['data-src']).group(), re.search(r'\.([a-zA-Z0-9]+)$', item['data-src']).group()
31
- url = f'https://i3.nhentai.net/galleries{img_code}/{page}{f_type}'
32
- response = requests.get(url)
33
- raw_images.append(response.content)
34
- if page == pages:
35
- break
31
+ 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()
33
+ url = f'https://i3.nhentai.net/galleries{img_code}/{page}{f_type}'
34
+ response = requests.get(url)
35
+ if response.status_code == 200:
36
+ return response.content
37
+ return None
38
+
39
+ def compile_images(raw: list, name: str) -> NoReturn:
40
+ with ThreadPoolExecutor(max_workers=10) as executor:
41
+ raw_images = list(executor.map(download_image, raw))
36
42
  nhpdf = nhpdf_dir/f"{name}.pdf"
37
43
  with open(nhpdf, "wb") as file:
38
44
  file.write(img2pdf.convert(raw_images))
@@ -68,9 +74,10 @@ def start_nhpdf():
68
74
  print("\n[ERROR]: The code cannot be found in the website.\n\ngoing to the next code...")
69
75
  continue
70
76
  print(f"\nH-Doujin Details:\nname: {name}\nauthor: {author}\npages: {pages}\n")
77
+ raw_data.remove(raw_data[0])
71
78
  function_thread = threading.Thread(target=loading_animation)
72
79
  function_thread.start()
73
- compile_images(raw_data, name)
80
+ compile_images(raw_data[:pages], name)
74
81
  la = True
75
82
  function_thread.join()
76
83
  if item != items:
nhpdf-1.2/test.py ADDED
@@ -0,0 +1,40 @@
1
+ import requests
2
+ from concurrent.futures import ThreadPoolExecutor
3
+ import time
4
+ import img2pdf
5
+
6
+
7
+
8
+
9
+
10
+ def download_image(url):
11
+ response = requests.get(url)
12
+ if response.status_code == 200:
13
+ return response.content # or save to file here
14
+
15
+
16
+
17
+
18
+
19
+ image_urls = [
20
+ "https://i3.nhentai.net/galleries/3311475/1.webp",
21
+ "https://i3.nhentai.net/galleries/3311475/2.webp",
22
+ "https://i3.nhentai.net/galleries/3311475/3.webp",
23
+ "https://i3.nhentai.net/galleries/3311475/4.webp",
24
+ "https://i3.nhentai.net/galleries/3311475/5.webp",
25
+ "https://i3.nhentai.net/galleries/3311475/6.webp",
26
+ "https://i3.nhentai.net/galleries/3311475/7.webp",
27
+ "https://i3.nhentai.net/galleries/3311475/8.webp",
28
+ "https://i3.nhentai.net/galleries/3311475/9.webp",
29
+ "https://i3.nhentai.net/galleries/3311475/10.webp",
30
+ "https://i3.nhentai.net/galleries/3311475/11.webp",
31
+ "https://i3.nhentai.net/galleries/3311475/12.webp",
32
+ "https://i3.nhentai.net/galleries/3311475/13.webp",
33
+ "https://i3.nhentai.net/galleries/3285893/21.jpg",
34
+ ]
35
+
36
+ with ThreadPoolExecutor(max_workers=10) as executor:
37
+ results = list(executor.map(download_image, image_urls))
38
+
39
+ with open("test.pdf", "wb") as file:
40
+ file.write(img2pdf.convert(results))
nhpdf-1.0/LICENSE DELETED
File without changes
File without changes
File without changes