Spaces:
Running
Running
File size: 899 Bytes
49afc47 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
from pathlib import Path
import requests
import re
username = "QIN2DIM"
repo = "hcaptcha-challenger"
url = f"https://api.github.com/repos/{username}/{repo}/releases"
models_dir = "/usr/local/lib/python3.11/lib/site-packages/hcaptcha_challenger/onnx/models/"
def download_all():
session = requests.session()
response = session.get(url)
data = response.json()
os.makedirs(models_dir, exist_ok=True)
for i in data:
for j in i['assets']:
asset_url = j['browser_download_url']
asset_name = re.sub('.*/', '', asset_url)
models_path = models_dir + asset_name
if os.path.exists(models_path):
continue
print(f'Downloading {asset_name}')
r = session.get(asset_url, stream=True)
with open(models_path, 'wb') as f:
f.write(r.content)
print("Done!")
|