Update misc.py
Browse files
misc.py
CHANGED
|
@@ -1,73 +1,74 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import random
|
| 3 |
-
from curl_cffi import requests
|
| 4 |
-
|
| 5 |
-
def header_bank_and_impersonate(browser='chrome'):
|
| 6 |
-
langs = [
|
| 7 |
-
"vi,en-US;q=0.9,en;q=0.8",
|
| 8 |
-
"en-US,en;q=0.9",
|
| 9 |
-
"en-GB,en;q=0.8",
|
| 10 |
-
"fr-FR,fr;q=0.9,en;q=0.8",
|
| 11 |
-
"zh-CN,zh;q=0.9,en;q=0.8",
|
| 12 |
-
"ja,en;q=0.9",
|
| 13 |
-
]
|
| 14 |
-
lang = random.choice(langs)
|
| 15 |
-
is_mobile = False # Change to True for mobile headers
|
| 16 |
-
platform = "\"Android\"" if is_mobile else random.choice(["\"Windows\"", "\"macOS\"", "\"Linux\"", "\"Chrome OS\""])
|
| 17 |
-
secchua = (
|
| 18 |
-
"\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", "
|
| 19 |
-
f"\"{'Google Chrome' if browser == 'chrome' else 'Microsoft Edge'}\";v=\"138\""
|
| 20 |
-
)
|
| 21 |
-
user_agent = (
|
| 22 |
-
"Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36"
|
| 23 |
-
if is_mobile else
|
| 24 |
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
# Example query
|
| 28 |
-
a, b = "Aquarium", "Avalanche"
|
| 29 |
-
|
| 30 |
-
curl = rf"""
|
| 31 |
-
curl 'https://neal.fun/api/infinite-craft/pair?first={a}&second={b}' \
|
| 32 |
-
-H 'accept: */*' \
|
| 33 |
-
-H 'accept-language: {lang}' \
|
| 34 |
-
-H 'referer: https://neal.fun/infinite-craft/' \
|
| 35 |
-
-H 'referrer-policy: strict-origin-when-cross-origin' \
|
| 36 |
-
-H 'sec-ch-ua: {secchua}' \
|
| 37 |
-
-H 'sec-ch-ua-mobile: {"?1" if is_mobile else "?0"}' \
|
| 38 |
-
-H 'sec-ch-ua-platform: {platform}' \
|
| 39 |
-
-H 'sec-fetch-dest: empty' \
|
| 40 |
-
-H 'sec-fetch-mode: cors' \
|
| 41 |
-
-H 'sec-fetch-site: same-origin' \
|
| 42 |
-
-H 'user-agent: {user_agent}' \
|
| 43 |
-
--compressed
|
| 44 |
-
"""
|
| 45 |
-
return curl.strip()
|
| 46 |
-
|
| 47 |
-
def log_pair(pair):
|
| 48 |
-
with open('public/pair.txt', 'at+') as f:
|
| 49 |
-
f.write(pair + '\n')
|
| 50 |
-
|
| 51 |
-
def trigger_push():
|
| 52 |
-
token = os.getenv('GITHUB_PAT')
|
| 53 |
-
repo = "ThongAccount/hf-dataset-pusher"
|
| 54 |
-
workflow = "update.yml"
|
| 55 |
-
|
| 56 |
-
url = f"https://api.github.com/repos/{repo}/actions/workflows/{workflow}/dispatches"
|
| 57 |
-
headers = {
|
| 58 |
-
"Accept": "application/vnd.github+json",
|
| 59 |
-
"Authorization": f"Bearer {token}",
|
| 60 |
-
"User-Agent": "hf-dataset-pusher",
|
| 61 |
-
"X-GitHub-Api-Version": "2022-11-28"
|
| 62 |
-
}
|
| 63 |
-
data = {"ref": "main",
|
| 64 |
-
"inputs": {
|
| 65 |
-
"base_url": "https://thongcoder-infinite-craft-searcher.hf.space"
|
| 66 |
-
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
print(f"❌ Failed to trigger Action: {resp.status_code} → {resp.text}")
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import random
|
| 3 |
+
from curl_cffi import requests
|
| 4 |
+
|
| 5 |
+
def header_bank_and_impersonate(browser='chrome'):
|
| 6 |
+
langs = [
|
| 7 |
+
"vi,en-US;q=0.9,en;q=0.8",
|
| 8 |
+
"en-US,en;q=0.9",
|
| 9 |
+
"en-GB,en;q=0.8",
|
| 10 |
+
"fr-FR,fr;q=0.9,en;q=0.8",
|
| 11 |
+
"zh-CN,zh;q=0.9,en;q=0.8",
|
| 12 |
+
"ja,en;q=0.9",
|
| 13 |
+
]
|
| 14 |
+
lang = random.choice(langs)
|
| 15 |
+
is_mobile = False # Change to True for mobile headers
|
| 16 |
+
platform = "\"Android\"" if is_mobile else random.choice(["\"Windows\"", "\"macOS\"", "\"Linux\"", "\"Chrome OS\""])
|
| 17 |
+
secchua = (
|
| 18 |
+
"\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", "
|
| 19 |
+
f"\"{'Google Chrome' if browser == 'chrome' else 'Microsoft Edge'}\";v=\"138\""
|
| 20 |
+
)
|
| 21 |
+
user_agent = (
|
| 22 |
+
"Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36"
|
| 23 |
+
if is_mobile else
|
| 24 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Example query
|
| 28 |
+
a, b = "Aquarium", "Avalanche"
|
| 29 |
+
|
| 30 |
+
curl = rf"""
|
| 31 |
+
curl 'https://neal.fun/api/infinite-craft/pair?first={a}&second={b}' \
|
| 32 |
+
-H 'accept: */*' \
|
| 33 |
+
-H 'accept-language: {lang}' \
|
| 34 |
+
-H 'referer: https://neal.fun/infinite-craft/' \
|
| 35 |
+
-H 'referrer-policy: strict-origin-when-cross-origin' \
|
| 36 |
+
-H 'sec-ch-ua: {secchua}' \
|
| 37 |
+
-H 'sec-ch-ua-mobile: {"?1" if is_mobile else "?0"}' \
|
| 38 |
+
-H 'sec-ch-ua-platform: {platform}' \
|
| 39 |
+
-H 'sec-fetch-dest: empty' \
|
| 40 |
+
-H 'sec-fetch-mode: cors' \
|
| 41 |
+
-H 'sec-fetch-site: same-origin' \
|
| 42 |
+
-H 'user-agent: {user_agent}' \
|
| 43 |
+
--compressed
|
| 44 |
+
"""
|
| 45 |
+
return curl.strip()
|
| 46 |
+
|
| 47 |
+
def log_pair(pair):
|
| 48 |
+
with open('public/pair.txt', 'at+') as f:
|
| 49 |
+
f.write(pair + '\n')
|
| 50 |
+
|
| 51 |
+
def trigger_push(amt):
|
| 52 |
+
token = os.getenv('GITHUB_PAT')
|
| 53 |
+
repo = "ThongAccount/hf-dataset-pusher"
|
| 54 |
+
workflow = "update.yml"
|
| 55 |
+
|
| 56 |
+
url = f"https://api.github.com/repos/{repo}/actions/workflows/{workflow}/dispatches"
|
| 57 |
+
headers = {
|
| 58 |
+
"Accept": "application/vnd.github+json",
|
| 59 |
+
"Authorization": f"Bearer {token}",
|
| 60 |
+
"User-Agent": "hf-dataset-pusher",
|
| 61 |
+
"X-GitHub-Api-Version": "2022-11-28"
|
| 62 |
+
}
|
| 63 |
+
data = {"ref": "main",
|
| 64 |
+
"inputs": {
|
| 65 |
+
"base_url": "https://thongcoder-infinite-craft-searcher.hf.space",
|
| 66 |
+
"amount": amt
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
resp = requests.post(url, headers=headers, json=data)
|
| 71 |
+
if resp.ok:
|
| 72 |
+
print("✅ Triggered GitHub Action successfully.")
|
| 73 |
+
else:
|
| 74 |
print(f"❌ Failed to trigger Action: {resp.status_code} → {resp.text}")
|