ehentai 0.2.1__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 CHANGED
@@ -8,7 +8,7 @@
8
8
  """
9
9
  __title__="ehentai"
10
10
  __description__="Python for viewing e-hentai"
11
- __version__="0.2.1"
11
+ __version__="0.2.2"
12
12
  __url__="https://github.com/Homoarea/hentai"
13
13
  __build__=0x3f3f3f
14
14
  __author__="Homoarea"
ehentai/api.py CHANGED
@@ -1,10 +1,10 @@
1
1
  from ehentai.fetch import Gallery,Page
2
- from ehentai.connect import URL, get_sp, keyword
2
+ from ehentai.connect import URL_E, get_sp, keyword
3
3
 
4
- def get_Page(url: str=URL,params=None,encoding: str=None,direct: bool=False)->Page:
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 URL.
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=URL,
19
+ url=URL_E,
20
20
  params=keyword(
21
21
  f_search=search_content,
22
22
  f_cats=cats_code,
ehentai/connect.py CHANGED
@@ -3,12 +3,14 @@ import time
3
3
  from ehentai.conf import CATS
4
4
  from curl_cffi import requests
5
5
 
6
- DOMAIN="e-hentai.org"
7
- URL="https://e-hentai.org"
6
+ DOMAIN_E="e-hentai.org"
7
+ URL_E="https://e-hentai.org"
8
8
 
9
9
  headers={
10
- "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
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
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"
12
14
  }
13
15
 
14
16
  hosts=["104.20.19.168", "172.67.2.238", "104.20.18.168"]
@@ -17,11 +19,11 @@ def get_response(url: str,direct: bool=False,hosts=hosts,headers=headers,params=
17
19
 
18
20
  if not direct:
19
21
  for ip in hosts:
20
- if url.find(DOMAIN)!=-1:
21
- headers['Host']=DOMAIN
22
- url=url[:url.find(DOMAIN)]+ip+url[url.find(DOMAIN)+len(DOMAIN):]
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):]}"
23
26
  try:
24
- print(url)
25
27
  response = requests.get(
26
28
  url,
27
29
  params=params,
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
- echo(params if params else "DEFAULT")
106
- pass
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
@@ -2,6 +2,7 @@ from bs4 import BeautifulSoup
2
2
  import os
3
3
  from ehentai.conf import FONT_STYLE,CATS_BG_COLOR,RESET
4
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=True)
54
+ img=get_response(img_src,stream=stream)
53
55
  with open(os.path.join(fdir,f"{i}.{img_suffix}"),"wb") as f:
54
- for chunk in img.iter_content(chunk_size=chunk_size):
55
- if chunk:
56
- f.write(chunk)
57
- f.flush()
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ehentai
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Python for viewing e-hentai
5
5
  Home-page: https://github.com/Homoarea/hentai
6
6
  Author: Homoarea
@@ -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,,
@@ -1,14 +0,0 @@
1
- ehentai/__init__.py,sha256=2nj4ZQ3qwERHMUCSE1S0I3wy0mDkCNwCxeSFk-QMZo4,52
2
- ehentai/__version__.py,sha256=tEY2wJZdUS7tYb5RmztuKRSgueXqaNjuVbuxO-E1h0A,1012
3
- ehentai/api.py,sha256=pSZUt_tYSyKz4HLVAvfrrNilRWjUnh7qIaLUTjUPruw,1115
4
- ehentai/conf.py,sha256=_58VU-o5T4k7X1bHLNp_iZXimj9T-JOYYP6PPmeIaFA,1115
5
- ehentai/connect.py,sha256=65ZXrWIZkBk6IhMqBHpXKMJmR5L2ARFZGCTrNhEESbQ,3467
6
- ehentai/eh.py,sha256=bkwYJF3mW1Vk5WxupvREWp0imKWTXSdH356aQBr5uBo,4485
7
- ehentai/fetch.py,sha256=UsSKZLem3RwCsPJi4KO5sRnHjK6TYpDzD6UZJ0_j3EY,4975
8
- ehentai-0.2.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
9
- ehentai-0.2.1.dist-info/licenses/NOTICE,sha256=mTsYLHfcXGcFMSSdkQX-LbKWxxieIA2L4sMNXitGN4k,30
10
- ehentai-0.2.1.dist-info/METADATA,sha256=7CaX-ZL_IcECJZlBaOfONVDyPDvVTwr2R8Vm9TtBG_E,606
11
- ehentai-0.2.1.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
12
- ehentai-0.2.1.dist-info/entry_points.txt,sha256=lc9qUbtXSHccaXX_CLtlh605pt2r3zfw6Lbuem3mQO8,38
13
- ehentai-0.2.1.dist-info/top_level.txt,sha256=NzB7Gi8Sxv8D3VNP4b9wiNdC-zQ4yntM0Uo9TAXnScE,8
14
- ehentai-0.2.1.dist-info/RECORD,,