put my fake headers in const
parent
a8771dc1d9
commit
bee7cc8892
|
@ -26,14 +26,13 @@ from files.helpers.slots import check_slots_command
|
||||||
post_target_type = Union[Submission, User]
|
post_target_type = Union[Submission, User]
|
||||||
|
|
||||||
def _archiveorg(url):
|
def _archiveorg(url):
|
||||||
headers = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
|
|
||||||
try:
|
try:
|
||||||
requests.get(f'https://web.archive.org/save/{url}',
|
requests.get(f'https://web.archive.org/save/{url}',
|
||||||
headers=headers, timeout=10, proxies=proxies)
|
headers=HEADERS, timeout=10, proxies=proxies)
|
||||||
except: pass
|
except: pass
|
||||||
try:
|
try:
|
||||||
requests.post('https://ghostarchive.org/archive2', data={"archive": url},
|
requests.post('https://ghostarchive.org/archive2', data={"archive": url},
|
||||||
headers=headers, timeout=10, proxies=proxies)
|
headers=HEADERS, timeout=10, proxies=proxies)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1177,3 +1177,5 @@ CHUD_PHRASES = (
|
||||||
"Long live the CCP",
|
"Long live the CCP",
|
||||||
"I stand with Ukraine",
|
"I stand with Ukraine",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
HEADERS = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"}
|
||||||
|
|
|
@ -30,8 +30,6 @@ from .users import userpagelisting
|
||||||
|
|
||||||
from files.__main__ import app, limiter
|
from files.__main__ import app, limiter
|
||||||
|
|
||||||
titleheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"}
|
|
||||||
|
|
||||||
@app.post("/publish/<int:pid>")
|
@app.post("/publish/<int:pid>")
|
||||||
@limiter.limit('1/second', scope=rpath)
|
@limiter.limit('1/second', scope=rpath)
|
||||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||||
|
@ -291,10 +289,8 @@ def thumbnail_thread(pid:int, vid:int):
|
||||||
if fetch_url.startswith('/') and '\\' not in fetch_url:
|
if fetch_url.startswith('/') and '\\' not in fetch_url:
|
||||||
fetch_url = f"{SITE_FULL}{fetch_url}"
|
fetch_url = f"{SITE_FULL}{fetch_url}"
|
||||||
|
|
||||||
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
x=requests.get(fetch_url, headers=headers, timeout=5, proxies=proxies)
|
x=requests.get(fetch_url, headers=HEADERS, timeout=5, proxies=proxies)
|
||||||
except:
|
except:
|
||||||
db.close()
|
db.close()
|
||||||
return
|
return
|
||||||
|
@ -342,7 +338,7 @@ def thumbnail_thread(pid:int, vid:int):
|
||||||
|
|
||||||
for url in thumb_candidate_urls:
|
for url in thumb_candidate_urls:
|
||||||
try:
|
try:
|
||||||
image_req=requests.get(url, headers=headers, timeout=5, proxies=proxies)
|
image_req=requests.get(url, headers=HEADERS, timeout=5, proxies=proxies)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -965,7 +961,7 @@ def get_post_title(v):
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
x = gevent.with_timeout(POST_TITLE_TIMEOUT, requests.get, url, headers=titleheaders, timeout=POST_TITLE_TIMEOUT, proxies=proxies)
|
x = gevent.with_timeout(POST_TITLE_TIMEOUT, requests.get, url, headers=HEADERS, timeout=POST_TITLE_TIMEOUT, proxies=proxies)
|
||||||
except: abort(400)
|
except: abort(400)
|
||||||
|
|
||||||
content_type = x.headers.get("Content-Type")
|
content_type = x.headers.get("Content-Type")
|
||||||
|
|
Loading…
Reference in New Issue