Add Civitai download request headers
Browse files
app.py
CHANGED
|
@@ -198,6 +198,22 @@ MODEL_LOCATION_CHOICES = [
|
|
| 198 |
(kind.replace("_", " ").title(), kind)
|
| 199 |
for kind in MODEL_KINDS
|
| 200 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
DEFAULT_NEGATIVE = (
|
| 202 |
"(censored, mosaic censoring, bar censor:1.1), bad quality, worst quality, "
|
| 203 |
"worst detail, bad anatomy, extra fingers, extra toes, extra legs, 4 toes, "
|
|
@@ -499,10 +515,7 @@ def download_bucket_asset(url, kind, anima, password):
|
|
| 499 |
|
| 500 |
temp = None
|
| 501 |
try:
|
| 502 |
-
request = urllib.request.Request(
|
| 503 |
-
url,
|
| 504 |
-
headers={"User-Agent": "Mozilla/5.0"},
|
| 505 |
-
)
|
| 506 |
with urllib.request.urlopen(request) as response:
|
| 507 |
name = bucket_url_filename(response)
|
| 508 |
if Path(name).suffix.casefold() not in MODEL_SUFFIXES:
|
|
|
|
| 198 |
(kind.replace("_", " ").title(), kind)
|
| 199 |
for kind in MODEL_KINDS
|
| 200 |
]
|
| 201 |
+
DOWNLOAD_HEADERS = {
|
| 202 |
+
"User-Agent": (
|
| 203 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) "
|
| 204 |
+
"Gecko/20100101 Firefox/140.0"
|
| 205 |
+
),
|
| 206 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
| 207 |
+
"Accept-Language": "en-US,en;q=0.5",
|
| 208 |
+
"Referer": "https://civitai.red/",
|
| 209 |
+
"Sec-GPC": "1",
|
| 210 |
+
"Upgrade-Insecure-Requests": "1",
|
| 211 |
+
"Sec-Fetch-Dest": "document",
|
| 212 |
+
"Sec-Fetch-Mode": "navigate",
|
| 213 |
+
"Sec-Fetch-Site": "cross-site",
|
| 214 |
+
"Sec-Fetch-User": "?1",
|
| 215 |
+
"Priority": "u=0, i",
|
| 216 |
+
}
|
| 217 |
DEFAULT_NEGATIVE = (
|
| 218 |
"(censored, mosaic censoring, bar censor:1.1), bad quality, worst quality, "
|
| 219 |
"worst detail, bad anatomy, extra fingers, extra toes, extra legs, 4 toes, "
|
|
|
|
| 515 |
|
| 516 |
temp = None
|
| 517 |
try:
|
| 518 |
+
request = urllib.request.Request(url, headers=DOWNLOAD_HEADERS)
|
|
|
|
|
|
|
|
|
|
| 519 |
with urllib.request.urlopen(request) as response:
|
| 520 |
name = bucket_url_filename(response)
|
| 521 |
if Path(name).suffix.casefold() not in MODEL_SUFFIXES:
|