gemini-webapi 1.6.1__py3-none-any.whl → 1.7.0__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.
gemini_webapi/client.py CHANGED
@@ -77,8 +77,8 @@ class GeminiClient:
77
77
  __Secure-1PSID cookie value.
78
78
  secure_1psidts: `str`, optional
79
79
  __Secure-1PSIDTS cookie value, some google accounts don't require this value, provide only if it's in the cookie list.
80
- proxies: `dict`, optional
81
- Dict of proxies.
80
+ proxy: `str`, optional
81
+ Proxy URL.
82
82
 
83
83
  Raises
84
84
  ------
@@ -88,7 +88,7 @@ class GeminiClient:
88
88
 
89
89
  __slots__ = [
90
90
  "cookies",
91
- "proxies",
91
+ "proxy",
92
92
  "running",
93
93
  "client",
94
94
  "access_token",
@@ -104,10 +104,10 @@ class GeminiClient:
104
104
  self,
105
105
  secure_1psid: str | None = None,
106
106
  secure_1psidts: str | None = None,
107
- proxies: dict | None = None,
107
+ proxy: str | None = None,
108
108
  ):
109
109
  self.cookies = {}
110
- self.proxies = proxies
110
+ self.proxy = proxy
111
111
  self.running: bool = False
112
112
  self.client: AsyncClient | None = None
113
113
  self.access_token: str | None = None
@@ -164,12 +164,12 @@ class GeminiClient:
164
164
 
165
165
  try:
166
166
  access_token, valid_cookies = await get_access_token(
167
- base_cookies=self.cookies, proxies=self.proxies, verbose=verbose
167
+ base_cookies=self.cookies, proxy=self.proxy, verbose=verbose
168
168
  )
169
169
 
170
170
  self.client = AsyncClient(
171
171
  timeout=timeout,
172
- proxies=self.proxies,
172
+ proxy=self.proxy,
173
173
  follow_redirects=True,
174
174
  headers=Headers.GEMINI.value,
175
175
  cookies=valid_cookies,
@@ -238,7 +238,7 @@ class GeminiClient:
238
238
 
239
239
  while True:
240
240
  try:
241
- new_1psidts = await rotate_1psidts(self.cookies, self.proxies)
241
+ new_1psidts = await rotate_1psidts(self.cookies, self.proxy)
242
242
  except AuthError:
243
243
  if task := rotate_tasks.get(self.cookies["__Secure-1PSID"]):
244
244
  task.cancel()
@@ -313,7 +313,7 @@ class GeminiClient:
313
313
  [
314
314
  [
315
315
  await upload_file(
316
- image, self.proxies
316
+ image, self.proxy
317
317
  ),
318
318
  1,
319
319
  ]
@@ -377,7 +377,7 @@ class GeminiClient:
377
377
  url=image[0][0][0],
378
378
  title=image[7][0],
379
379
  alt=image[0][4],
380
- proxies=self.proxies,
380
+ proxy=self.proxy,
381
381
  )
382
382
  for image in candidate[12][1]
383
383
  ]
@@ -395,7 +395,7 @@ class GeminiClient:
395
395
  alt=len(image[3][5]) > i
396
396
  and image[3][5][i]
397
397
  or image[3][5][0],
398
- proxies=self.proxies,
398
+ proxy=self.proxy,
399
399
  cookies=self.cookies,
400
400
  )
401
401
  for i, image in enumerate(
@@ -20,14 +20,14 @@ class Image(BaseModel):
20
20
  Title of the image, by default is "[Image]".
21
21
  alt: `str`, optional
22
22
  Optional description of the image.
23
- proxies: `dict`, optional
24
- Dict of proxies used when saving image.
23
+ proxy: `str`, optional
24
+ Proxy used when saving image.
25
25
  """
26
26
 
27
27
  url: str
28
28
  title: str = "[Image]"
29
29
  alt: str = ""
30
- proxies: dict | None = None
30
+ proxy: str | None = None
31
31
 
32
32
  def __str__(self):
33
33
  return f"{self.title}({self.url}) - {self.alt}"
@@ -80,7 +80,7 @@ class Image(BaseModel):
80
80
  return None
81
81
 
82
82
  async with AsyncClient(
83
- follow_redirects=True, cookies=cookies, proxies=self.proxies
83
+ follow_redirects=True, cookies=cookies, proxy=self.proxy
84
84
  ) as client:
85
85
  response = await client.get(self.url)
86
86
  if response.status_code == 200:
@@ -12,7 +12,7 @@ from .logger import logger
12
12
 
13
13
 
14
14
  async def get_access_token(
15
- base_cookies: dict, proxies: dict | None = None, verbose: bool = False
15
+ base_cookies: dict, proxy: str | None = None, verbose: bool = False
16
16
  ) -> tuple[str, dict]:
17
17
  """
18
18
  Send a get request to gemini.google.com for each group of available cookies and return
@@ -27,8 +27,8 @@ async def get_access_token(
27
27
  ----------
28
28
  base_cookies : `dict`
29
29
  Base cookies to be used in the request.
30
- proxies: `dict`, optional
31
- Dict of proxies.
30
+ proxy: `str`, optional
31
+ Proxy URL.
32
32
  verbose: `bool`, optional
33
33
  If `True`, will print more infomation in logs.
34
34
 
@@ -47,7 +47,7 @@ async def get_access_token(
47
47
 
48
48
  async def send_request(cookies: dict) -> tuple[Response | None, dict]:
49
49
  async with AsyncClient(
50
- proxies=proxies,
50
+ proxy=proxy,
51
51
  headers=Headers.GEMINI.value,
52
52
  cookies=cookies,
53
53
  follow_redirects=True,
@@ -8,7 +8,7 @@ from ..constants import Endpoint, Headers
8
8
  from ..exceptions import AuthError
9
9
 
10
10
 
11
- async def rotate_1psidts(cookies: dict, proxies: dict | None = None) -> str:
11
+ async def rotate_1psidts(cookies: dict, proxy: str | None = None) -> str:
12
12
  """
13
13
  Refresh the __Secure-1PSIDTS cookie and store the refreshed cookie value in cache file.
14
14
 
@@ -16,8 +16,8 @@ async def rotate_1psidts(cookies: dict, proxies: dict | None = None) -> str:
16
16
  ----------
17
17
  cookies : `dict`
18
18
  Cookies to be used in the request.
19
- proxies: `dict`, optional
20
- Dict of proxies.
19
+ proxy: `str`, optional
20
+ Proxy URL.
21
21
 
22
22
  Returns
23
23
  -------
@@ -39,7 +39,7 @@ async def rotate_1psidts(cookies: dict, proxies: dict | None = None) -> str:
39
39
 
40
40
  # Check if the cache file was modified in the last minute to avoid 429 Too Many Requests
41
41
  if not (path.is_file() and time.time() - os.path.getmtime(path) <= 60):
42
- async with AsyncClient(proxies=proxies) as client:
42
+ async with AsyncClient(proxy=proxy) as client:
43
43
  response = await client.post(
44
44
  url=Endpoint.ROTATE_COOKIES.value,
45
45
  headers=Headers.ROTATE_COOKIES.value,
@@ -7,7 +7,7 @@ from ..constants import Endpoint, Headers
7
7
 
8
8
 
9
9
  @validate_call
10
- async def upload_file(file: bytes | str | Path, proxies: dict | None = None) -> str:
10
+ async def upload_file(file: bytes | str | Path, proxy: str | None = None) -> str:
11
11
  """
12
12
  Upload a file to Google's server and return its identifier.
13
13
 
@@ -15,8 +15,8 @@ async def upload_file(file: bytes | str | Path, proxies: dict | None = None) ->
15
15
  ----------
16
16
  file : `bytes` | `str` | `Path`
17
17
  File data in bytes, or path to the file to be uploaded.
18
- proxies: `dict`, optional
19
- Dict of proxies.
18
+ proxy: `str`, optional
19
+ Proxy URL.
20
20
 
21
21
  Returns
22
22
  -------
@@ -34,7 +34,7 @@ async def upload_file(file: bytes | str | Path, proxies: dict | None = None) ->
34
34
  with open(file, "rb") as f:
35
35
  file = f.read()
36
36
 
37
- async with AsyncClient(proxies=proxies) as client:
37
+ async with AsyncClient(proxy=proxy) as client:
38
38
  response = await client.post(
39
39
  url=Endpoint.UPLOAD.value,
40
40
  headers=Headers.UPLOAD.value,
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gemini-webapi
3
- Version: 1.6.1
3
+ Version: 1.7.0
4
4
  Summary: ✨ An elegant async Python wrapper for Google Gemini web app
5
5
  Author: UZQueen
6
- License: GNU AFFERO GENERAL PUBLIC LICENSE
6
+ License: GNU AFFERO GENERAL PUBLIC LICENSE
7
7
  Version 3, 19 November 2007
8
8
 
9
9
  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
@@ -676,9 +676,9 @@ Classifier: Programming Language :: Python :: 3.12
676
676
  Requires-Python: >=3.10
677
677
  Description-Content-Type: text/markdown
678
678
  License-File: LICENSE
679
- Requires-Dist: httpx >=0.25.2
680
- Requires-Dist: pydantic >=2.5.3
681
- Requires-Dist: loguru >=0.7.2
679
+ Requires-Dist: httpx~=0.28.0
680
+ Requires-Dist: pydantic~=2.10.2
681
+ Requires-Dist: loguru~=0.7.2
682
682
 
683
683
  <p align="center">
684
684
  <img src="https://raw.githubusercontent.com/HanaokaYuzu/Gemini-API/master/assets/banner.png" width="55%" alt="Gemini Banner" align="center">
@@ -804,7 +804,7 @@ Secure_1PSIDTS = "COOKIE VALUE HERE"
804
804
 
805
805
  async def main():
806
806
  # If browser-cookie3 is installed, simply use `client = GeminiClient()`
807
- client = GeminiClient(Secure_1PSID, Secure_1PSIDTS, proxies=None)
807
+ client = GeminiClient(Secure_1PSID, Secure_1PSIDTS, proxy=None)
808
808
  await client.init(timeout=30, auto_close=False, close_delay=300, auto_refresh=True)
809
809
 
810
810
  asyncio.run(main())
@@ -1,19 +1,19 @@
1
1
  gemini_webapi/__init__.py,sha256=28uNIywK4vCXxENaSagNWUzhqr1RyNtLzDF6WRRM4KQ,194
2
- gemini_webapi/client.py,sha256=q99zlCYr97ThzaMYgczICOub0WUqxzQ2JN4VFv2PzSw,20960
2
+ gemini_webapi/client.py,sha256=A_unTPUCSSLch0zojvTG4PrS7Hvpxgr7mnIXG-uW_kM,20922
3
3
  gemini_webapi/constants.py,sha256=ezJ0Squ5FPTspAp5IGRe5gg9CYaPHnzx5N95W5gGm5s,865
4
4
  gemini_webapi/exceptions.py,sha256=6e-EXHGApi4iC0GDw7RKc3YqVK8UvEkHYaJyGQbReLw,548
5
5
  gemini_webapi/types/__init__.py,sha256=d2kvXnE004s2E2KDmPPLi5N-BQ59FgDSlrGrO3Wphww,163
6
6
  gemini_webapi/types/candidate.py,sha256=Z9bpIK4l8UWbUVMLEoophfhgROo93dxOM9cAwx77CkU,1030
7
- gemini_webapi/types/image.py,sha256=UrLG1NiiXax6w79ES88vykG5mipGKHI9-9R7QcG768Q,5245
7
+ gemini_webapi/types/image.py,sha256=9l4_k4C3RPFOgGIVnPnTAKYmUISdvdx_LwvcJYJNLuo,5225
8
8
  gemini_webapi/types/modeloutput.py,sha256=sGEnaQtSOJE68ve5R5sFgW4POmsyWZAV5zei3Z4BRVk,1090
9
9
  gemini_webapi/utils/__init__.py,sha256=mcm1kgQ5HHKyZrhHS-rd_GXbKMpIDUsq02XtmlQNN_I,357
10
- gemini_webapi/utils/get_access_token.py,sha256=ssMccXzqSAgSzpezaRu1w7LiO9tRIroiSXWru_X9g3c,5457
10
+ gemini_webapi/utils/get_access_token.py,sha256=h0gcCCQZzVStE4sgUS_jjMVGYQT_20LK2HX5jcIriWs,5441
11
11
  gemini_webapi/utils/load_browser_cookies.py,sha256=A5n_VsB7Rm8ck5lpy856UNJEhv30l3dvQ3j0g3ln1fE,1535
12
12
  gemini_webapi/utils/logger.py,sha256=PF4ROQq7scRRrWzeYdeYiYs2S2Jqr0bgjyrPbXVOCqE,816
13
- gemini_webapi/utils/rotate_1psidts.py,sha256=HY_rOpO13J34uQwRmARQ9rM0eKRSIzYM6Sk0j8noWVU,1684
14
- gemini_webapi/utils/upload_file.py,sha256=RsttsLLFyw3HJLjEaXcy9aY6DmKEhJt02_iK5gPMKOY,1167
15
- gemini_webapi-1.6.1.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
16
- gemini_webapi-1.6.1.dist-info/METADATA,sha256=6iFMi7oDeVNa2pFtLV2U3QluF8JRzMvX7ccsg367ELI,55713
17
- gemini_webapi-1.6.1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
18
- gemini_webapi-1.6.1.dist-info/top_level.txt,sha256=dtWtug_ZrmnUqCYuu8NmGzTgWglHeNzhHU_hXmqZGWE,14
19
- gemini_webapi-1.6.1.dist-info/RECORD,,
13
+ gemini_webapi/utils/rotate_1psidts.py,sha256=cwCXsE_mX2knaKCuquZT2jsRXHQo-GK2Ldom-cO9Gio,1668
14
+ gemini_webapi/utils/upload_file.py,sha256=X0k-3jW7usheFo5z0nXL9mUt-XF-2L2OgwpJnPSIcKw,1151
15
+ gemini_webapi-1.7.0.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
16
+ gemini_webapi-1.7.0.dist-info/METADATA,sha256=XhfeQVH9p_5SYZ1t12mVhrhbIJMCw9Ucqhmzq0PvKI0,55729
17
+ gemini_webapi-1.7.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
18
+ gemini_webapi-1.7.0.dist-info/top_level.txt,sha256=dtWtug_ZrmnUqCYuu8NmGzTgWglHeNzhHU_hXmqZGWE,14
19
+ gemini_webapi-1.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.2)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5