File size: 2,435 Bytes
91ff88d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6ec3072
 
 
 
91ff88d
6ec3072
 
 
91ff88d
6ec3072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
import random
from curl_cffi import requests

def header_bank_and_impersonate(browser='chrome'):
    langs = [
        "vi,en-US;q=0.9,en;q=0.8",
        "en-US,en;q=0.9",
        "en-GB,en;q=0.8",
        "fr-FR,fr;q=0.9,en;q=0.8",
        "zh-CN,zh;q=0.9,en;q=0.8",
        "ja,en;q=0.9",
    ]
    lang = random.choice(langs)
    is_mobile = False  # Change to True for mobile headers
    platform = "\"Android\"" if is_mobile else random.choice(["\"Windows\"", "\"macOS\"", "\"Linux\"", "\"Chrome OS\""])
    secchua = (
        "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", "
        f"\"{'Google Chrome' if browser == 'chrome' else 'Microsoft Edge'}\";v=\"138\""
    )
    user_agent = (
        "Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36"
        if is_mobile else
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
    )

    # Example query
    a, b = "Aquarium", "Avalanche"

    curl = rf"""
curl 'https://neal.fun/api/infinite-craft/pair?first={a}&second={b}' \
  -H 'accept: */*' \
  -H 'accept-language: {lang}' \
  -H 'referer: https://neal.fun/infinite-craft/' \
  -H 'referrer-policy: strict-origin-when-cross-origin' \
  -H 'sec-ch-ua: {secchua}' \
  -H 'sec-ch-ua-mobile: {"?1" if is_mobile else "?0"}' \
  -H 'sec-ch-ua-platform: {platform}' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: {user_agent}' \
  --compressed
"""
    return curl.strip()

def log_pair(pair):
    with open('public/pair.txt', 'at+') as f:
        f.write(pair + '\n')

def trigger_push(n):
    env["HF_HOME"] = "/tmp/hf_cache"
    env["XDG_CACHE_HOME"] = "/tmp/xdg_cache"
    env["TMPDIR"] = "/tmp"

    os.makedirs(env["HF_HOME"], exist_ok=True)
    os.makedirs(env["XDG_CACHE_HOME"], exist_ok=True)
    os.makedirs(env["TMPDIR"], exist_ok=True)

    cwd = "/tmp"
    os.makedirs(cwd, exist_ok=True)
    
    repo_id = 'ThongCoder/infinite-craft'
    local_path = 'db/cache.sqlite'
    path_in_repo = 'cache.sqlite'
    repo_type = 'dataset'
    
    cmd = [
        "hf", "upload",
        repo_id,
        local_path,
        path_in_repo,
        "--repo-type", repo_type,
    ]

    process = subprocess.Popen(
        cmd,
        env=env,
        text=True,
        cwd=cwd,
    )
    process.wait()