diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index db9524ac5..662f5cd59 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -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 = `` container.insertAdjacentHTML('beforeend', insert); } diff --git a/files/routes/giphy.py b/files/routes/giphy.py index d4f7b7365..66288a556 100644 --- a/files/routes/giphy.py +++ b/files/routes/giphy.py @@ -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()