ehentai 0.2__py2.py3-none-any.whl → 0.2.2__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/api.py +4 -4
- ehentai/connect.py +122 -0
- ehentai/eh.py +8 -7
- ehentai/fetch.py +13 -8
- {ehentai-0.2.dist-info → ehentai-0.2.2.dist-info}/METADATA +1 -1
- ehentai-0.2.2.dist-info/RECORD +14 -0
- ehentai-0.2.dist-info/RECORD +0 -13
- {ehentai-0.2.dist-info → ehentai-0.2.2.dist-info}/WHEEL +0 -0
- {ehentai-0.2.dist-info → ehentai-0.2.2.dist-info}/entry_points.txt +0 -0
- {ehentai-0.2.dist-info → ehentai-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {ehentai-0.2.dist-info → ehentai-0.2.2.dist-info}/licenses/NOTICE +0 -0
- {ehentai-0.2.dist-info → ehentai-0.2.2.dist-info}/top_level.txt +0 -0
ehentai/__version__.py
CHANGED
ehentai/api.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
from ehentai.fetch import Gallery,Page
|
2
|
-
from ehentai.
|
2
|
+
from ehentai.connect import URL_E, get_sp, keyword
|
3
3
|
|
4
|
-
def get_Page(url: str=
|
4
|
+
def get_Page(url: str=URL_E,params=None,encoding: str=None,direct: bool=False)->Page:
|
5
5
|
"""
|
6
6
|
Args:
|
7
|
-
url (str, optional): ehentai has the galleries. Defaults to
|
7
|
+
url (str, optional): ehentai has the galleries. Defaults to URL_E.
|
8
8
|
params (fetch.keyword, optional): use this to search. Defaults to None.
|
9
9
|
encoding (str, optional): 'utf-8'..,use this when encoding is wrong. Defaults to None.
|
10
10
|
direct (bool,optional): enable this to connect directly
|
@@ -16,7 +16,7 @@ def get_Page(url: str=URL,params=None,encoding: str=None,direct: bool=False)->Pa
|
|
16
16
|
|
17
17
|
def get_search(search_content,cats_code=None,rating=None,expunged=None,torrent=None,cats_list=None,**args)->Page:
|
18
18
|
return get_Page(
|
19
|
-
url=
|
19
|
+
url=URL_E,
|
20
20
|
params=keyword(
|
21
21
|
f_search=search_content,
|
22
22
|
f_cats=cats_code,
|
ehentai/connect.py
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
from bs4 import BeautifulSoup
|
2
|
+
import time
|
3
|
+
from ehentai.conf import CATS
|
4
|
+
from curl_cffi import requests
|
5
|
+
|
6
|
+
DOMAIN_E="e-hentai.org"
|
7
|
+
URL_E="https://e-hentai.org"
|
8
|
+
|
9
|
+
headers={
|
10
|
+
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
|
11
|
+
"Referer":"http://www.google.com",
|
12
|
+
"Accept":"image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
|
13
|
+
"Accept-Language":"zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"
|
14
|
+
}
|
15
|
+
|
16
|
+
hosts=["104.20.19.168", "172.67.2.238", "104.20.18.168"]
|
17
|
+
|
18
|
+
def get_response(url: str,direct: bool=False,hosts=hosts,headers=headers,params=None,**args)->requests.Response:
|
19
|
+
|
20
|
+
if not direct:
|
21
|
+
for ip in hosts:
|
22
|
+
if url.find(DOMAIN_E)!=-1:
|
23
|
+
domain=url.split('/')[2]
|
24
|
+
headers['Host']=domain
|
25
|
+
url=f"{url[:url.find(domain)]}{ip}{url[url.find(domain)+len(domain):]}"
|
26
|
+
try:
|
27
|
+
response = requests.get(
|
28
|
+
url,
|
29
|
+
params=params,
|
30
|
+
impersonate="chrome",
|
31
|
+
headers=headers,
|
32
|
+
verify=False,
|
33
|
+
**args,
|
34
|
+
)
|
35
|
+
|
36
|
+
if response.ok:
|
37
|
+
return response
|
38
|
+
except requests.exceptions.ConnectionError as e:
|
39
|
+
time.sleep(1)
|
40
|
+
print("fetch again..")
|
41
|
+
except requests.exceptions.ReadTimeout as e:
|
42
|
+
time.sleep(1)
|
43
|
+
print("fetch again..")
|
44
|
+
except Exception as e:
|
45
|
+
time.sleep(1)
|
46
|
+
print("fetch again..")
|
47
|
+
|
48
|
+
return requests.get(url,params=params,headers=headers,impersonate="chrome",timeout=27.03,**args)
|
49
|
+
|
50
|
+
def keyword(
|
51
|
+
f_search: str = None,
|
52
|
+
f_cats: int = None,
|
53
|
+
advsearch: bool = None,
|
54
|
+
f_sh: bool = None,
|
55
|
+
f_sto: bool = None,
|
56
|
+
f_spf: int = None,
|
57
|
+
f_spt: int = None,
|
58
|
+
f_srdd: int = None,
|
59
|
+
f_sfl: bool = None,
|
60
|
+
f_sfu: bool = None,
|
61
|
+
f_sft: bool = None,
|
62
|
+
cats_list=None
|
63
|
+
):
|
64
|
+
kw={}
|
65
|
+
# search_kw
|
66
|
+
kw["f_search"]=f_search
|
67
|
+
# category
|
68
|
+
if f_cats or cats_list:kw["f_cats"]=get_f_cats(f_cats,cats_list),
|
69
|
+
# advanced search
|
70
|
+
# show advanced options
|
71
|
+
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
|
72
|
+
# show expunged galleries
|
73
|
+
if f_sh:kw["f_sh"]="on"
|
74
|
+
# require Gallery torrent
|
75
|
+
if f_sto:kw["f_sto"]="on"
|
76
|
+
# between {f_spf} and {f_spt} Pages
|
77
|
+
if f_spf:kw["f_spf"]=f_spf,
|
78
|
+
if f_spt:kw["f_spt"]=f_spt,
|
79
|
+
# minimum_rating
|
80
|
+
if f_srdd:kw["f_srdd"]=f_srdd,
|
81
|
+
# disable filter language
|
82
|
+
if f_sfl:kw["f_sfl"]="on"
|
83
|
+
# disable filter uploader
|
84
|
+
if f_sfu:kw["f_sfu"]="on"
|
85
|
+
# disable filter tags
|
86
|
+
if f_sft:kw["f_sft"]="on"
|
87
|
+
|
88
|
+
return kw
|
89
|
+
|
90
|
+
|
91
|
+
def next_view(sp: BeautifulSoup):
|
92
|
+
return sp.find('table',class_="ptt").find_all('td')[-1].find('a')
|
93
|
+
|
94
|
+
# url:target_URL
|
95
|
+
# parms:search_keyword
|
96
|
+
def get_sp(url: str,params=None,encoding=None,direct=False)->BeautifulSoup:
|
97
|
+
# set encoding
|
98
|
+
response=get_response(url,direct,params=params)
|
99
|
+
|
100
|
+
if encoding:
|
101
|
+
response.encoding=encoding
|
102
|
+
|
103
|
+
# response info
|
104
|
+
# print(response.encoding)
|
105
|
+
# print(response.url)
|
106
|
+
|
107
|
+
return BeautifulSoup(response.text,"lxml")
|
108
|
+
|
109
|
+
|
110
|
+
# switch categories: doujinshi...
|
111
|
+
def get_f_cats(cat_code=None,cats: list=None):
|
112
|
+
cat_code=cat_code if cat_code else 0b0011111111
|
113
|
+
res=0b1111111111
|
114
|
+
if cats:
|
115
|
+
for v in list(i.value for i in cats):
|
116
|
+
res&=v
|
117
|
+
return res
|
118
|
+
|
119
|
+
for v in list(i.value for i in CATS):
|
120
|
+
if cat_code&1:res&=v
|
121
|
+
cat_code>>=1
|
122
|
+
return res
|
ehentai/eh.py
CHANGED
@@ -74,13 +74,14 @@ def list(detailed):
|
|
74
74
|
@click.option('--download/--no-download','-d/',default=False,help="select this to download gallery")
|
75
75
|
@click.option('--rename',default=None,type=str,help="rename gallery when download")
|
76
76
|
@click.option('--path','-p',default=None,type=click.Path(),help="download path,default is current directory")
|
77
|
+
@click.option('--stream/--no-stream','-s/',default=True,type=bool,help="enable stream download")
|
77
78
|
@click.option('--comment/--no-comment', '-c/',default=False,help="echo the comment of gallery")
|
78
|
-
def view(id,download,rename,path,comment):
|
79
|
+
def view(id,download,rename,path,stream,comment):
|
79
80
|
page=load_json("page.json",Page)
|
80
81
|
gl=page.gl_table[id]
|
81
82
|
echo(gl)
|
82
83
|
if download:
|
83
|
-
gl.download(name=rename,path=path)
|
84
|
+
gl.download(name=rename,path=path,stream=stream)
|
84
85
|
elif comment:
|
85
86
|
comment=gl.comment()
|
86
87
|
if comment:
|
@@ -99,8 +100,8 @@ def popular(use_direct):
|
|
99
100
|
save_json("page.json",page)
|
100
101
|
|
101
102
|
# testing
|
102
|
-
@cli.command()
|
103
|
-
@click.option('--params','-p',default=None)
|
104
|
-
def t(params):
|
105
|
-
|
106
|
-
|
103
|
+
# @cli.command()
|
104
|
+
# @click.option('--params','-p',default=None)
|
105
|
+
# def t(params):
|
106
|
+
# echo(params if params else "DEFAULT")
|
107
|
+
# pass
|
ehentai/fetch.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
from bs4 import BeautifulSoup
|
2
2
|
import os
|
3
3
|
from ehentai.conf import FONT_STYLE,CATS_BG_COLOR,RESET
|
4
|
-
from ehentai.
|
4
|
+
from ehentai.connect import get_sp,next_view,get_response
|
5
|
+
import time
|
5
6
|
# book
|
6
7
|
class Gallery:
|
7
8
|
name=""#名字
|
@@ -23,7 +24,8 @@ class Gallery:
|
|
23
24
|
def __repr__(self):
|
24
25
|
return f"<{self.name}>"
|
25
26
|
|
26
|
-
def download(self,name=None,path=None,img_suffix="webp",show=True,chunk_size=8192):
|
27
|
+
def download(self,name=None,path=None,img_suffix="webp",show=True,stream=True,chunk_size=8192):
|
28
|
+
start_time=time.time()
|
27
29
|
if show:
|
28
30
|
print("fetching the URL...")
|
29
31
|
path=path if path else "./"
|
@@ -49,15 +51,18 @@ class Gallery:
|
|
49
51
|
print(f"Downloading...{i+1}/{totals}")
|
50
52
|
|
51
53
|
img_src=get_sp(v).find('img',id="img").get('src')
|
52
|
-
img=get_response(img_src,stream=
|
54
|
+
img=get_response(img_src,stream=stream)
|
53
55
|
with open(os.path.join(fdir,f"{i}.{img_suffix}"),"wb") as f:
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
if stream:
|
57
|
+
for chunk in img.iter_content(chunk_size=chunk_size):
|
58
|
+
if chunk:
|
59
|
+
f.write(chunk)
|
60
|
+
f.flush()
|
61
|
+
else:
|
62
|
+
f.write(img.content)
|
58
63
|
|
59
64
|
if show:
|
60
|
-
print("Completed!!")
|
65
|
+
print(f"Completed!! consum:{time.time()-start_time}")
|
61
66
|
|
62
67
|
# @return:list(author,list[str])
|
63
68
|
def comment(self):
|
@@ -0,0 +1,14 @@
|
|
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,,
|
ehentai-0.2.dist-info/RECORD
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
ehentai/__init__.py,sha256=2nj4ZQ3qwERHMUCSE1S0I3wy0mDkCNwCxeSFk-QMZo4,52
|
2
|
-
ehentai/__version__.py,sha256=ItZgDjKTDWKAb-z5rJ4jLukDnSFQ7Ep6F-6NImOEqJk,1010
|
3
|
-
ehentai/api.py,sha256=zTPygliwFDJ4AxHg1OQgKGWXlEevyTOBiTBObi4aCBE,1121
|
4
|
-
ehentai/conf.py,sha256=_58VU-o5T4k7X1bHLNp_iZXimj9T-JOYYP6PPmeIaFA,1115
|
5
|
-
ehentai/eh.py,sha256=bkwYJF3mW1Vk5WxupvREWp0imKWTXSdH356aQBr5uBo,4485
|
6
|
-
ehentai/fetch.py,sha256=IZDVdnV2aMnUszd0S0e_H2yerc8oP_XFLopo7q-ulBo,4981
|
7
|
-
ehentai-0.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
8
|
-
ehentai-0.2.dist-info/licenses/NOTICE,sha256=mTsYLHfcXGcFMSSdkQX-LbKWxxieIA2L4sMNXitGN4k,30
|
9
|
-
ehentai-0.2.dist-info/METADATA,sha256=nkW-443IMUDLEZrNHnC90rc-ujDhwzSMJ-1fAgyLN1M,604
|
10
|
-
ehentai-0.2.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
11
|
-
ehentai-0.2.dist-info/entry_points.txt,sha256=lc9qUbtXSHccaXX_CLtlh605pt2r3zfw6Lbuem3mQO8,38
|
12
|
-
ehentai-0.2.dist-info/top_level.txt,sha256=NzB7Gi8Sxv8D3VNP4b9wiNdC-zQ4yntM0Uo9TAXnScE,8
|
13
|
-
ehentai-0.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|