switch from giphy to tenor

master
Aevann 2024-07-26 03:49:24 +03:00
parent af129fe389
commit b3ccfd4ee5
2 changed files with 6 additions and 7 deletions

View File

@ -118,7 +118,6 @@ async function show_gif_categories(t, form) {
document.getElementById('gifs-back-btn').addEventListener('click', () => show_gif_categories(null, null));
async function searchGifs(searchTerm) {
gifSearchBar.value = searchTerm;
noGIFs.classList.add("d-none");
@ -126,11 +125,11 @@ async function searchGifs(searchTerm) {
let response = await fetch("/giphy?searchTerm=" + searchTerm + "&limit=48");
let data = await response.json()
data = data.data
data = data.results
if (data.length) {
if (data) {
for (const e of data) {
const url = "https://media.giphy.com/media/" + e.id + "/giphy.webp";
const url = e.media_formats.webp.url
const insert = `<img class="giphy" loading="lazy" data-bs-dismiss="modal" src="${url}"></div>`
container.insertAdjacentHTML('beforeend', insert);
}

View File

@ -19,9 +19,9 @@ def giphy(v, path=None):
except:
pass
if searchTerm and limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}"
url = f"https://tenor.googleapis.com/v2/search?media_filter=webp&q={searchTerm}&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"
url = f"https://tenor.googleapis.com/v2/search?media_filter=webp&q={searchTerm}&key={GIPHY_KEY}&limit=48"
else:
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
url = f"https://tenor.googleapis.com/v2?media_filter=webp&key={GIPHY_KEY}&limit=48"
return requests.get(url, headers=HEADERS, timeout=5).json()