ehentai 0.2.2__py2.py3-none-any.whl → 0.2.4__py2.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.
- ehentai/__version__.py +1 -1
- ehentai/connect.py +11 -7
- ehentai/eh.py +16 -33
- ehentai/utils.py +38 -0
- {ehentai-0.2.2.dist-info → ehentai-0.2.4.dist-info}/METADATA +2 -1
- ehentai-0.2.4.dist-info/RECORD +15 -0
- ehentai-0.2.2.dist-info/RECORD +0 -14
- {ehentai-0.2.2.dist-info → ehentai-0.2.4.dist-info}/WHEEL +0 -0
- {ehentai-0.2.2.dist-info → ehentai-0.2.4.dist-info}/entry_points.txt +0 -0
- {ehentai-0.2.2.dist-info → ehentai-0.2.4.dist-info}/licenses/LICENSE +0 -0
- {ehentai-0.2.2.dist-info → ehentai-0.2.4.dist-info}/licenses/NOTICE +0 -0
- {ehentai-0.2.2.dist-info → ehentai-0.2.4.dist-info}/top_level.txt +0 -0
ehentai/__version__.py
CHANGED
ehentai/connect.py
CHANGED
@@ -15,7 +15,7 @@ headers={
|
|
15
15
|
|
16
16
|
hosts=["104.20.19.168", "172.67.2.238", "104.20.18.168"]
|
17
17
|
|
18
|
-
def get_response(url: str,direct: bool=False,hosts=hosts,headers=headers,params=None,**args)->requests.Response:
|
18
|
+
def get_response(url: str,direct: bool=False,hosts=hosts,headers=headers,params=None,timeout=6.1,**args)->requests.Response:
|
19
19
|
|
20
20
|
if not direct:
|
21
21
|
for ip in hosts:
|
@@ -30,6 +30,7 @@ def get_response(url: str,direct: bool=False,hosts=hosts,headers=headers,params=
|
|
30
30
|
impersonate="chrome",
|
31
31
|
headers=headers,
|
32
32
|
verify=False,
|
33
|
+
timeout=timeout,
|
33
34
|
**args,
|
34
35
|
)
|
35
36
|
|
@@ -37,15 +38,18 @@ def get_response(url: str,direct: bool=False,hosts=hosts,headers=headers,params=
|
|
37
38
|
return response
|
38
39
|
except requests.exceptions.ConnectionError as e:
|
39
40
|
time.sleep(1)
|
40
|
-
print("fetch again..")
|
41
|
+
print("fetch again..",type(e))
|
42
|
+
except requests.exceptions.RequestException as e:
|
43
|
+
time.sleep(1)
|
44
|
+
print("fetch again..",type(e))
|
41
45
|
except requests.exceptions.ReadTimeout as e:
|
42
46
|
time.sleep(1)
|
43
|
-
print("fetch again..")
|
47
|
+
print("fetch again..",type(e))
|
44
48
|
except Exception as e:
|
45
49
|
time.sleep(1)
|
46
|
-
print("fetch again..")
|
50
|
+
print("fetch again..",type(e))
|
47
51
|
|
48
|
-
return requests.get(url,params=params,headers=headers,impersonate="chrome",timeout=
|
52
|
+
return requests.get(url,params=params,headers=headers,impersonate="chrome",timeout=timeout,**args)
|
49
53
|
|
50
54
|
def keyword(
|
51
55
|
f_search: str = None,
|
@@ -65,7 +69,7 @@ def keyword(
|
|
65
69
|
# search_kw
|
66
70
|
kw["f_search"]=f_search
|
67
71
|
# category
|
68
|
-
|
72
|
+
kw["f_cats"]=get_f_cats(f_cats,cats_list),
|
69
73
|
# advanced search
|
70
74
|
# show advanced options
|
71
75
|
if advsearch or f_sh or f_sto or f_spf or f_spt or f_srdd or f_sfl or f_sfu or f_sft:kw["advsearch"]=1
|
@@ -94,9 +98,9 @@ def next_view(sp: BeautifulSoup):
|
|
94
98
|
# url:target_URL
|
95
99
|
# parms:search_keyword
|
96
100
|
def get_sp(url: str,params=None,encoding=None,direct=False)->BeautifulSoup:
|
97
|
-
# set encoding
|
98
101
|
response=get_response(url,direct,params=params)
|
99
102
|
|
103
|
+
# set encoding
|
100
104
|
if encoding:
|
101
105
|
response.encoding=encoding
|
102
106
|
|
ehentai/eh.py
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
import sys
|
2
|
-
import os
|
3
|
-
import json
|
4
1
|
import click
|
5
2
|
import json
|
6
3
|
from click import echo
|
@@ -8,11 +5,7 @@ from typing import List
|
|
8
5
|
from ehentai.conf import *
|
9
6
|
from ehentai import __version__
|
10
7
|
from ehentai import Page,Gallery,get_search,get_popular
|
11
|
-
|
12
|
-
HOME=os.path.abspath(os.path.join(os.getenv('HOME'),".hentai"))
|
13
|
-
|
14
|
-
if not os.path.exists(HOME):
|
15
|
-
os.makedirs(HOME)
|
8
|
+
from ehentai.utils import save_Page,load_Page
|
16
9
|
|
17
10
|
def echo_gl_table(detail=False,gl_table: List[Gallery]=None):
|
18
11
|
if gl_table:
|
@@ -25,16 +18,11 @@ def echo_gl_table(detail=False,gl_table: List[Gallery]=None):
|
|
25
18
|
else:
|
26
19
|
echo("Page's Gallery Table is None.")
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
with open(os.path.join(HOME,filename),"r") as f:
|
34
|
-
return data_type(**json.loads(f.read()))
|
35
|
-
|
36
|
-
page: Page
|
37
|
-
|
21
|
+
def echo_gl_comment(comment):
|
22
|
+
for nick,cs in comment:
|
23
|
+
echo(f"{FONT_STYLE.bold.value}{FONT_COLOR.green.value}{nick}{RESET}")
|
24
|
+
for c in cs:
|
25
|
+
echo(f"\t{c}")
|
38
26
|
|
39
27
|
@click.group()
|
40
28
|
def cli():
|
@@ -52,21 +40,20 @@ def version():
|
|
52
40
|
echo(f"Version: {__version__.__version__}")
|
53
41
|
|
54
42
|
@cli.command(help="|search from e-hentai")
|
55
|
-
@click.
|
43
|
+
@click.argument('search-content',default="")
|
56
44
|
@click.option('--cats','-c',default=255,type=int,help="Doujinshi,Manga...")
|
57
45
|
@click.option('--rating','-r',default=None,type=int,help="the minium rating")
|
58
46
|
@click.option('--show-expunged/--no-show-expunged','-sh/',default=False,help="show the removed galleries")
|
59
47
|
@click.option('--show-torrent/--no-show-torrent','-sto/',default=False,help="filter galleries have torrent")
|
60
|
-
|
61
|
-
|
62
|
-
page
|
63
|
-
save_json("page.json",page)
|
48
|
+
def search(search_content,cats,rating,show_expunged,show_torrent):
|
49
|
+
page=get_search(search_content,cats,rating,show_expunged,show_torrent)
|
50
|
+
save_Page(page)
|
64
51
|
print(page)
|
65
52
|
|
66
53
|
@cli.command(help="|show the fetched galleries")
|
67
54
|
@click.option("--detailed/--no-detailed", "-d/", default=False)
|
68
55
|
def list(detailed):
|
69
|
-
page=
|
56
|
+
page=load_Page()
|
70
57
|
echo_gl_table(detailed,page.gl_table)
|
71
58
|
|
72
59
|
@cli.command(help="|show and operate the gallery")
|
@@ -77,7 +64,7 @@ def list(detailed):
|
|
77
64
|
@click.option('--stream/--no-stream','-s/',default=True,type=bool,help="enable stream download")
|
78
65
|
@click.option('--comment/--no-comment', '-c/',default=False,help="echo the comment of gallery")
|
79
66
|
def view(id,download,rename,path,stream,comment):
|
80
|
-
page=
|
67
|
+
page=load_Page()
|
81
68
|
gl=page.gl_table[id]
|
82
69
|
echo(gl)
|
83
70
|
if download:
|
@@ -85,19 +72,15 @@ def view(id,download,rename,path,stream,comment):
|
|
85
72
|
elif comment:
|
86
73
|
comment=gl.comment()
|
87
74
|
if comment:
|
88
|
-
|
89
|
-
echo(f"{FONT_STYLE.bold.value}{FONT_COLOR.green.value}{nick}{RESET}")
|
90
|
-
for c in cs:
|
91
|
-
echo(f"\t{c}")
|
75
|
+
echo_gl_comment(comment)
|
92
76
|
else:
|
93
77
|
echo("no comments")
|
94
78
|
|
95
79
|
@cli.command(help="|fetch popular galleries")
|
96
|
-
|
97
|
-
|
98
|
-
page=get_popular(direct=use_direct)
|
80
|
+
def popular():
|
81
|
+
page=get_popular()
|
99
82
|
echo(f"Currently Popular Recent Galleries:{len(page.gl_table)}")
|
100
|
-
|
83
|
+
save_Page(page)
|
101
84
|
|
102
85
|
# testing
|
103
86
|
# @cli.command()
|
ehentai/utils.py
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
import json
|
2
|
+
import os
|
3
|
+
from PIL import Image
|
4
|
+
import platform
|
5
|
+
from ehentai.api import get_Page,Page
|
6
|
+
|
7
|
+
# home path
|
8
|
+
HOME:str
|
9
|
+
match platform.system():
|
10
|
+
case 'Windows':HOME=os.path.abspath(os.path.join(os.getenv('TEMP'),".hentai"))
|
11
|
+
case _:HOME=os.path.abspath(os.path.join(os.getenv('HOME'),".cache",".hentai"))
|
12
|
+
|
13
|
+
# json data
|
14
|
+
if not os.path.exists(HOME):
|
15
|
+
os.makedirs(HOME)
|
16
|
+
def save_json(filename: str,data: object):
|
17
|
+
with open(os.path.join(HOME,filename),"w") as f:
|
18
|
+
f.write(json.dumps(data,default=lambda obj:obj.__dict__))
|
19
|
+
def load_json(filename: str,data_type):
|
20
|
+
with open(os.path.join(HOME,filename),"r") as f:
|
21
|
+
return data_type(**json.loads(f.read()))
|
22
|
+
|
23
|
+
# page
|
24
|
+
def load_Page()->Page:
|
25
|
+
return load_json("page.json",Page)
|
26
|
+
def save_Page(page):
|
27
|
+
save_json("page.json",page)
|
28
|
+
|
29
|
+
if not os.path.exists(os.path.join(HOME,"page.json")):
|
30
|
+
save_Page(get_Page())
|
31
|
+
|
32
|
+
# args:list[Image]
|
33
|
+
def merge_img():
|
34
|
+
pass
|
35
|
+
|
36
|
+
# args:list[Image]
|
37
|
+
def img2pdf():
|
38
|
+
pass
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ehentai
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.4
|
4
4
|
Summary: Python for viewing e-hentai
|
5
5
|
Home-page: https://github.com/Homoarea/hentai
|
6
6
|
Author: Homoarea
|
@@ -14,6 +14,7 @@ Requires-Dist: click
|
|
14
14
|
Requires-Dist: curl_cffi
|
15
15
|
Requires-Dist: beautifulsoup4
|
16
16
|
Requires-Dist: lxml
|
17
|
+
Requires-Dist: pillow
|
17
18
|
Dynamic: author
|
18
19
|
Dynamic: author-email
|
19
20
|
Dynamic: home-page
|
@@ -0,0 +1,15 @@
|
|
1
|
+
ehentai/__init__.py,sha256=2nj4ZQ3qwERHMUCSE1S0I3wy0mDkCNwCxeSFk-QMZo4,52
|
2
|
+
ehentai/__version__.py,sha256=GguDToFIlSErZW130csurvT_XQLqtPKqYRqftig6Zww,1012
|
3
|
+
ehentai/api.py,sha256=IGCwJiGgQBu9Q0XNJb4_vbNsO7VPOzx31KkqQC2FmtI,1123
|
4
|
+
ehentai/conf.py,sha256=_58VU-o5T4k7X1bHLNp_iZXimj9T-JOYYP6PPmeIaFA,1115
|
5
|
+
ehentai/connect.py,sha256=CgcSpTuOD-XV3cyGCSxa-4ib9xsyvorGCMLqDHZrmvY,3823
|
6
|
+
ehentai/eh.py,sha256=4SmiWm0cCx5gA2L7ao3fAVVXw8-Qxbn-0iqAz7N5NcY,3885
|
7
|
+
ehentai/fetch.py,sha256=UxBFd8FpKXQ3KO746IpA7p3o8B0T7PKDt8ZLpoQ3Zo8,5171
|
8
|
+
ehentai/utils.py,sha256=n9W5GMfM_hr0Krq0JfIiAA7q2eu6VmIH1Tplp5jmWQI,983
|
9
|
+
ehentai-0.2.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
10
|
+
ehentai-0.2.4.dist-info/licenses/NOTICE,sha256=mTsYLHfcXGcFMSSdkQX-LbKWxxieIA2L4sMNXitGN4k,30
|
11
|
+
ehentai-0.2.4.dist-info/METADATA,sha256=umcqJwkcmaKEi0jW5_WpU4iFsH1nxqtpB4ER6gVdU4U,628
|
12
|
+
ehentai-0.2.4.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
13
|
+
ehentai-0.2.4.dist-info/entry_points.txt,sha256=lc9qUbtXSHccaXX_CLtlh605pt2r3zfw6Lbuem3mQO8,38
|
14
|
+
ehentai-0.2.4.dist-info/top_level.txt,sha256=NzB7Gi8Sxv8D3VNP4b9wiNdC-zQ4yntM0Uo9TAXnScE,8
|
15
|
+
ehentai-0.2.4.dist-info/RECORD,,
|
ehentai-0.2.2.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
ehentai/__init__.py,sha256=2nj4ZQ3qwERHMUCSE1S0I3wy0mDkCNwCxeSFk-QMZo4,52
|
2
|
-
ehentai/__version__.py,sha256=kgvFd5p-NAoTPoLjOlA4IFV8peVOaT53_w6zhX5i8sQ,1012
|
3
|
-
ehentai/api.py,sha256=IGCwJiGgQBu9Q0XNJb4_vbNsO7VPOzx31KkqQC2FmtI,1123
|
4
|
-
ehentai/conf.py,sha256=_58VU-o5T4k7X1bHLNp_iZXimj9T-JOYYP6PPmeIaFA,1115
|
5
|
-
ehentai/connect.py,sha256=AdmYBewqvCSMs-satHwB33BGbZOaYAmxq9M762NK5ss,3632
|
6
|
-
ehentai/eh.py,sha256=Ju4jgWXaoRf_XzlzwJh_14SlPpVRNZ1L4DMnWBk0nbY,4613
|
7
|
-
ehentai/fetch.py,sha256=UxBFd8FpKXQ3KO746IpA7p3o8B0T7PKDt8ZLpoQ3Zo8,5171
|
8
|
-
ehentai-0.2.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
9
|
-
ehentai-0.2.2.dist-info/licenses/NOTICE,sha256=mTsYLHfcXGcFMSSdkQX-LbKWxxieIA2L4sMNXitGN4k,30
|
10
|
-
ehentai-0.2.2.dist-info/METADATA,sha256=VuIX9XRzY1zRJWjXS6Cghfc4GhcqoMGY5sUEqpU8Woc,606
|
11
|
-
ehentai-0.2.2.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
12
|
-
ehentai-0.2.2.dist-info/entry_points.txt,sha256=lc9qUbtXSHccaXX_CLtlh605pt2r3zfw6Lbuem3mQO8,38
|
13
|
-
ehentai-0.2.2.dist-info/top_level.txt,sha256=NzB7Gi8Sxv8D3VNP4b9wiNdC-zQ4yntM0Uo9TAXnScE,8
|
14
|
-
ehentai-0.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|