captchakraken 5.2.0 → 5.2.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captchakraken",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "description": "Captcha solver for Playwright and Puppeteer. Finds the captcha, reads it with the v2 pointer model, and clicks, drags, slides or types through to a token \u2014 reCAPTCHA, GeeTest, NetEase Yidun, Tencent, Lemin, Prosopo, Turnstile and distorted text. Hosted API or self-hosted.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "captchakraken"
7
- version = "5.2.0"
7
+ version = "5.2.1"
8
8
  description = "Captcha-solving engine and CLI: a v2 pointer model for image grids, click and drag puzzles, sliders, distorted text and animated challenges. Hosted API or self-hosted on vLLM."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -104,4 +104,4 @@ __all__ = [
104
104
  "PauseKind",
105
105
  ]
106
106
 
107
- __version__ = "5.2.0"
107
+ __version__ = "5.2.1"
@@ -53,6 +53,8 @@ class Model:
53
53
  listed: bool = True
54
54
  # How an account without access gets it; empty means the Abyss Licence.
55
55
  access: str = ""
56
+ # The folder of the repo that is served, when the repo holds several builds; empty means the whole repo.
57
+ subfolder: str = ""
56
58
 
57
59
  @property
58
60
  def licensed(self) -> bool:
@@ -73,9 +75,9 @@ MODELS = (
73
75
  3.8, 8, aliases=("abyss",)),
74
76
  Model("CaptchaKraken/AbyssV2", "Abyss V2", "Abyss at full precision, needs an Abyss Licence", 9.1, 16),
75
77
  Model("CaptchaKraken/CaptchaKraken-Custom-Yidun-Commision", "CaptchaKraken Custom Yidun", "Abyss tuned for Yidun icon click-in-order boards",
76
- 3.8, 8, aliases=("custom-yidun",), listed=False,
77
- access=" Access to this model is granted by hand once its purchase is confirmed: send the CaptchaKraken team\n"
78
- " your Hugging Face username. Then run this again."),
78
+ 3.8, 8, aliases=("custom-yidun",), listed=False, subfolder="q4",
79
+ access=" Use the access token the CaptchaKraken team sent you once your purchase was confirmed:\n"
80
+ " HF_TOKEN=hf_... captchakraken fetch custom-yidun"),
79
81
  )
80
82
 
81
83
 
@@ -277,7 +279,7 @@ def _licence_steps() -> str:
277
279
 
278
280
 
279
281
  def ensure_access(repo: str, *, interactive: bool, http: Optional[Callable] = None,
280
- read_secret: Callable[[str], str] = getpass.getpass, access: str = "") -> str:
282
+ read_secret: Callable[[str], str] = getpass.getpass, access: str = "", subfolder: str = "") -> str:
281
283
  """The Hugging Face account that will download `repo`, once it is known to be allowed to. A token typed here is saved where huggingface_hub looks, so the download and later updates use it."""
282
284
  http = http or _HUB_REQUEST
283
285
  token, typed = hub_token(), False
@@ -299,7 +301,7 @@ def ensure_access(repo: str, *, interactive: bool, http: Optional[Callable] = No
299
301
  raise RuntimeError(f"Hugging Face answered {who.status_code} when asked who the token belongs to. Try again shortly.")
300
302
  user = who.json().get("name") or "this account"
301
303
 
302
- probe = _hub(http, "HEAD", f"{HUB}/{repo}/resolve/main/config.json", token)
304
+ probe = _hub(http, "HEAD", f"{HUB}/{repo}/resolve/main/{subfolder + '/' if subfolder else ''}config.json", token)
303
305
  if probe.status_code in (401, 403, 404):
304
306
  if access:
305
307
  raise RuntimeError(f"Hugging Face account {user} cannot download {repo} yet.\n" + access)
@@ -359,15 +361,17 @@ def install_client(python: Path, extra: str = "") -> None:
359
361
 
360
362
 
361
363
  _DOWNLOAD = """
362
- import sys
364
+ import os, sys
363
365
  from huggingface_hub import snapshot_download
364
- print(snapshot_download(sys.argv[1]))
366
+ repo, sub = sys.argv[1], sys.argv[2]
367
+ path = snapshot_download(repo, allow_patterns=[sub + "/*"] if sub else None)
368
+ print(os.path.join(path, sub) if sub else path)
365
369
  """
366
370
 
367
371
 
368
- def download(python: Path, repo: str) -> str:
369
- """The model directory. Stored as a path so a server never asks the Hub again."""
370
- out = subprocess.run([str(python), "-c", _DOWNLOAD, repo], stdout=subprocess.PIPE, text=True, check=True)
372
+ def download(python: Path, repo: str, subfolder: str = "") -> str:
373
+ """The model directory. Stored as a path so a server never asks the Hub again. Only `subfolder` is fetched when one is given."""
374
+ out = subprocess.run([str(python), "-c", _DOWNLOAD, repo, subfolder], stdout=subprocess.PIPE, text=True, check=True)
371
375
  return out.stdout.strip().splitlines()[-1]
372
376
 
373
377
 
@@ -448,7 +452,7 @@ def install(choice: Choice, saved: dict) -> dict:
448
452
  install_client(python, "[serve]")
449
453
 
450
454
  _step(f"Downloading {choice.model.title}")
451
- model_path = download(python, choice.model.repo)
455
+ model_path = download(python, choice.model.repo, choice.model.subfolder)
452
456
 
453
457
  values = settings(choice, model_path, saved)
454
458
  write_settings(values)
@@ -529,7 +533,8 @@ def fetch(*, yes: bool = False, model: Optional[str] = None, gpu: Optional[int]
529
533
  choice = ask(gpus, saved)
530
534
  if choice.model.licensed:
531
535
  # A sign-in, not a choice: asked for whenever there is a terminal, --yes or not.
532
- ensure_access(choice.model.repo, interactive=interactive, access=choice.model.access)
536
+ ensure_access(choice.model.repo, interactive=interactive, access=choice.model.access,
537
+ subfolder=choice.model.subfolder)
533
538
  values = install(choice, saved)
534
539
  except Cancelled:
535
540
  print("Cancelled. Nothing was changed.")