make using proxies only happen in 3 circumstances again

master
Aevann1 2022-09-26 06:01:25 +02:00
parent 9d3c337eb3
commit 37e1f25624
11 changed files with 27 additions and 27 deletions

View File

@ -30,7 +30,7 @@ def badge_grant(user, badge_id, description=None, url=None, notify=True):
def archiveorg(url):
try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100, proxies=proxies)
try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100)
except: pass
def archive_url(url):

View File

@ -112,7 +112,7 @@ def give_monthly_marseybux_task():
data = {'access_token': GUMROAD_TOKEN}
emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5, proxies=proxies).json()["subscribers"]]
emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5).json()["subscribers"]]
for u in g.db.query(User).filter(User.patron > 0, User.patron_utc == 0).all():
g.db.add(u)

View File

@ -25,30 +25,30 @@ def discord_wrap(f):
def add_role(user, role_name):
role_id = ROLES[role_name]
url = f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}/roles/{role_id}"
requests.put(url, headers=headers, timeout=5, proxies=proxies)
requests.put(url, headers=headers, timeout=5)
@discord_wrap
def remove_role(user, role_name):
role_id = ROLES[role_name]
url = f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}/roles/{role_id}"
requests.delete(url, headers=headers, timeout=5, proxies=proxies)
requests.delete(url, headers=headers, timeout=5)
@discord_wrap
def remove_user(user):
url=f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}"
requests.delete(url, headers=headers, timeout=5, proxies=proxies)
requests.delete(url, headers=headers, timeout=5)
@discord_wrap
def set_nick(user, nick):
url=f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}"
data={"nick": nick}
requests.patch(url, headers=headers, json=data, timeout=5, proxies=proxies)
requests.patch(url, headers=headers, json=data, timeout=5)
def send_changelog_message(message):
data={"content": message}
requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5, proxies=proxies)
requests.post("https://discordapp.com/api/channels/1013992002624426015/messages", headers=headers, data=data, timeout=5, proxies=proxies)
requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5)
requests.post("https://discordapp.com/api/channels/1013992002624426015/messages", headers=headers, data=data, timeout=5)
def send_wpd_message(message):
data={"content": message}
requests.post("https://discordapp.com/api/channels/1013990963846332456/messages", headers=headers, data=data, timeout=5, proxies=proxies)
requests.post("https://discordapp.com/api/channels/1013990963846332456/messages", headers=headers, data=data, timeout=5)

View File

@ -30,7 +30,7 @@ def process_files():
def process_other(file):
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': file}, timeout=20, proxies=proxies).json()
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': file}, timeout=20).json()
return req['files'][0]['url']
@ -47,7 +47,7 @@ def process_audio(file):
if os.stat(name).st_size > 8 * 1024 * 1024:
with open(name, 'rb') as f:
os.remove(name)
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20, proxies=proxies).json()
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json()
return req['files'][0]['url']
return f'{SITE_FULL}{name}'
@ -67,7 +67,7 @@ def process_video(file):
if os.stat(new).st_size > 8 * 1024 * 1024:
with open(new, 'rb') as f:
os.remove(new)
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20, proxies=proxies).json()
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json()
return req['files'][0]['url']
return f'{SITE_FULL}{new}'

View File

@ -33,7 +33,7 @@ def get_mentions(queries):
mentions = []
for kind, query in itertools.product(kinds, queries):
try:
data = requests.get(f'https://api.pushshift.io/reddit/{kind}/search?html_decode=true&q={query}&size=1', timeout=5, proxies=proxies).json()['data']
data = requests.get(f'https://api.pushshift.io/reddit/{kind}/search?html_decode=true&q={query}&size=1', timeout=5).json()['data']
except: break
for i in data:

View File

@ -55,7 +55,7 @@ def discord_redirect(v):
}
url="https://discord.com/api/oauth2/token"
x=requests.post(url, headers=headers, data=data, timeout=5, proxies=proxies)
x=requests.post(url, headers=headers, data=data, timeout=5)
x=x.json()
@ -67,7 +67,7 @@ def discord_redirect(v):
headers={
'Authorization': f"Bearer {token}"
}
x=requests.get(url, headers=headers, timeout=5, proxies=proxies)
x=requests.get(url, headers=headers, timeout=5)
x=x.json()
@ -80,7 +80,7 @@ def discord_redirect(v):
if v.discord_id and v.discord_id != x['id']:
url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{v.discord_id}"
requests.delete(url, headers=headers, timeout=5, proxies=proxies)
requests.delete(url, headers=headers, timeout=5)
if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).one_or_none():
return render_template("message.html", title="Discord account already linked.", error="This Discord account is already in use by another user.", v=v)
@ -97,7 +97,7 @@ def discord_redirect(v):
"nick":name,
}
x=requests.put(url, headers=headers, json=data, timeout=5, proxies=proxies)
x=requests.put(url, headers=headers, json=data, timeout=5)
if x.status_code in {201, 204}:
time.sleep(0.1)
@ -112,7 +112,7 @@ def discord_redirect(v):
add_role(v, "admin")
time.sleep(0.1)
requests.put("https://discord.com/api/guilds/913091440035389520/members/788152118669606932", headers=headers, json={"access_token":token,"roles":[915260962540511292]}, timeout=5, proxies=proxies)
requests.put("https://discord.com/api/guilds/913091440035389520/members/788152118669606932", headers=headers, json={"access_token":token,"roles":[915260962540511292]}, timeout=5)
else:
return x.json()
@ -124,7 +124,7 @@ def discord_redirect(v):
"nick": name
}
requests.patch(url, headers=headers, json=data, timeout=5, proxies=proxies)
requests.patch(url, headers=headers, json=data, timeout=5)
return redirect(f"https://discord.com/channels/{DISCORD_SERVER_ID}/{DISCORD_WELCOME_CHANNEL}")

View File

@ -19,4 +19,4 @@ def giphy(v=None, path=None):
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
else:
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
return jsonify(requests.get(url, timeout=5, proxies=proxies).json())
return jsonify(requests.get(url, timeout=5).json())

View File

@ -318,7 +318,7 @@ def sign_up_post(v):
"sitekey": HCAPTCHA_SITEKEY}
url = "https://hcaptcha.com/siteverify"
x = requests.post(url, data=data, timeout=5, proxies=proxies)
x = requests.post(url, data=data, timeout=5)
if not x.json()["success"]:
return signup_error("Unable to verify captcha [2].")

View File

@ -769,7 +769,7 @@ def submit_post(v, sub=None):
return error(reason)
elif "twitter.com" == domain:
try:
embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5, proxies=proxies).json()["html"]
embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5).json()["html"]
embed = embed.replace('<a href', '<a rel="nofollow noopener noreferrer" href')
except: pass
elif url.startswith('https://youtube.com/watch?v='):
@ -777,7 +777,7 @@ def submit_post(v, sub=None):
yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0].split('%')[0]
if yt_id_regex.fullmatch(yt_id):
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={yt_id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5, proxies=proxies).json()
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={yt_id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
if req.get('items'):
params = parse_qs(urlparse(url).query, keep_blank_values=True)
t = params.get('t', params.get('start', [0]))[0]

View File

@ -350,7 +350,7 @@ def gumroad(v):
return {"error": f"You must have a verified email to verify {patron} status and claim your rewards!"}, 400
data = {'access_token': GUMROAD_TOKEN, 'email': v.email}
response = requests.get('https://api.gumroad.com/v2/sales', data=data, timeout=5, proxies=proxies).json()["sales"]
response = requests.get('https://api.gumroad.com/v2/sales', data=data, timeout=5).json()["sales"]
if len(response) == 0: return {"error": "Email not found"}, 404
@ -816,7 +816,7 @@ def settings_song_change(v):
return redirect("/settings/profile")
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5, proxies=proxies).json()
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
duration = req['items'][0]['contentDetails']['duration']
if duration == 'P0D':
return render_template("settings_profile.html", v=v, error="Can't use a live youtube video!")

View File

@ -447,7 +447,7 @@ if SITE == 'pcmemes.net':
def process_streamer(id, live='live'):
url = f'https://www.youtube.com/channel/{id}/{live}'
req = requests.get(url, cookies={'CONSENT': 'YES+1'}, timeout=5, proxies=proxies)
req = requests.get(url, cookies={'CONSENT': 'YES+1'}, timeout=5)
text = req.text
if '"videoDetails":{"videoId"' in text:
y = live_regex.search(text)
@ -558,7 +558,7 @@ if SITE == 'pcmemes.net':
if 'youtube.com/channel/' in link:
id = link.split('youtube.com/channel/')[1].rstrip('/')
else:
text = requests.get(link, cookies={'CONSENT': 'YES+1'}, timeout=5, proxies=proxies).text
text = requests.get(link, cookies={'CONSENT': 'YES+1'}, timeout=5).text
try: id = id_regex.search(text).group(1)
except: return {"error": "Invalid ID"}