forked from MarseyWorld/MarseyWorld
proxy all requests we make
parent
c2a189012b
commit
dd0f8fbed7
|
@ -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)
|
||||
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)
|
||||
except: pass
|
||||
|
||||
def archive_url(url):
|
||||
|
|
|
@ -114,7 +114,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).json()["subscribers"]]
|
||||
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"]]
|
||||
|
||||
for u in g.db.query(User).filter(User.patron > 0, User.patron_utc == 0).all():
|
||||
g.db.add(u)
|
||||
|
|
|
@ -34,7 +34,7 @@ def get_mentions(queries):
|
|||
for kind, query in itertools.product(kinds, queries):
|
||||
try:
|
||||
data = requests.get(f'https://api.pushshift.io/reddit/{kind}/search'
|
||||
+ f'?html_decode=true&q={query}&size=1', timeout=5).json()['data']
|
||||
+ f'?html_decode=true&q={query}&size=1', timeout=5, proxies=proxies).json()['data']
|
||||
except: break
|
||||
|
||||
for i in data:
|
||||
|
|
|
@ -429,7 +429,7 @@ def admin_home(v):
|
|||
|
||||
if v.admin_level > 2:
|
||||
if CF_ZONE == 'blahblahblah': response = 'high'
|
||||
else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value']
|
||||
else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5, proxies=proxies).json()['result']['value']
|
||||
under_attack = response == 'under_attack'
|
||||
|
||||
gitref = admin_git_head()
|
||||
|
@ -498,7 +498,7 @@ def purge_cache(v):
|
|||
@app.post("/admin/under_attack")
|
||||
@admin_level_required(3)
|
||||
def under_attack(v):
|
||||
response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value']
|
||||
response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5, proxies=proxies).json()['result']['value']
|
||||
|
||||
if response == 'under_attack':
|
||||
ma = ModAction(
|
||||
|
|
|
@ -67,7 +67,7 @@ def discord_redirect(v):
|
|||
headers={
|
||||
'Authorization': f"Bearer {token}"
|
||||
}
|
||||
x=requests.get(url, headers=headers, timeout=5)
|
||||
x=requests.get(url, headers=headers, timeout=5, proxies=proxies)
|
||||
|
||||
x=x.json()
|
||||
|
||||
|
|
|
@ -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).json())
|
||||
return jsonify(requests.get(url, timeout=5, proxies=proxies).json())
|
||||
|
|
|
@ -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).json()["html"]
|
||||
embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5, proxies=proxies).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).json()
|
||||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={yt_id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5, proxies=proxies).json()
|
||||
if req.get('items'):
|
||||
params = parse_qs(urlparse(url).query, keep_blank_values=True)
|
||||
t = params.get('t', params.get('start', [0]))[0]
|
||||
|
|
|
@ -358,7 +358,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).json()["sales"]
|
||||
response = requests.get('https://api.gumroad.com/v2/sales', data=data, timeout=5, proxies=proxies).json()["sales"]
|
||||
|
||||
if len(response) == 0: return {"error": "Email not found"}, 404
|
||||
|
||||
|
@ -824,7 +824,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).json()
|
||||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5, proxies=proxies).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!")
|
||||
|
|
Loading…
Reference in New Issue