2022-05-04 23:09:46 +00:00
|
|
|
from flask import *
|
|
|
|
import requests
|
|
|
|
from files.helpers.wrappers import *
|
2022-07-08 16:21:13 +00:00
|
|
|
from files.helpers.const import *
|
2022-05-04 23:09:46 +00:00
|
|
|
|
|
|
|
from files.__main__ import app
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/giphy")
|
|
|
|
@app.get("/giphy<path>")
|
|
|
|
@auth_required
|
|
|
|
def giphy(v=None, path=None):
|
|
|
|
|
|
|
|
searchTerm = request.values.get("searchTerm", "").strip()
|
2022-10-16 09:51:42 +00:00
|
|
|
limit = 48
|
|
|
|
try:
|
|
|
|
limit = int(request.values.get("limit", 48))
|
|
|
|
except:
|
|
|
|
pass
|
2022-05-04 23:09:46 +00:00
|
|
|
if searchTerm and limit:
|
|
|
|
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}"
|
|
|
|
elif searchTerm and not limit:
|
|
|
|
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"
|
2022-09-26 04:01:25 +00:00
|
|
|
return jsonify(requests.get(url, timeout=5).json())
|