diff --git a/netlify/edge-functions/linkPreview.ts b/netlify/edge-functions/linkPreview.ts deleted file mode 100644 index 037aaa7a8..000000000 --- a/netlify/edge-functions/linkPreview.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Context, Config } from '@netlify/edge-functions'; - -export default async (request: Request, context: Context) => { - - const url = new URL(request.url); - const id = url.searchParams.get('s') || ''; - - if (id.length < 11) return; - - const response = await context.next(); - const page = await response.text(); - const keys = process.env.rkeys!.split(','); - - shuffle(keys); - - const data = await fetcher(keys, id); - - if (!data) return; - const music = data.channelTitle.endsWith(' - Topic') ? 'https://wsrv.nl?w=180&h=180&fit=cover&url=' : ''; - const thumbnail = `${music}https://i.ytimg.com/vi_webp/${id}/mqdefault.webp`; - const newPage = page - .replace('48-160kbps Opus YouTube Audio Streaming Web App.', data.channelTitle.replace(' - Topic', '')) - .replace('"ytify"', `"${data.title}"`) - .replace('ytify.pp.ua', `ytify.pp.ua?s=${id}`) - .replaceAll('/ytify_thumbnail_min.webp', thumbnail); - - return new Response(newPage, response); -}; - -export const config: Config = { - path: '/*', - excludedPath: '/list' -}; - -const host = 'yt-api.p.rapidapi.com'; -export const fetcher = (keys: string[], id: string): Promise<{ - title: string, - channelTitle: string, - channelId: string, - lengthSeconds: number, - isLiveContent: boolean, - adaptiveFormats: { - mimeType: string, - url: string, - bitrate: number, - contentLength: string - }[] -}> => fetch(`https://${host}/dl?id=${id}`, { - headers: { - 'X-RapidAPI-Key': keys.shift(), - 'X-RapidAPI-Host': host - } -}) - .then(res => res.json()) - .then(data => { - if (data && 'adaptiveFormats' in data && data.adaptiveFormats.length) - return data; - else throw new Error(data.message); - }) - .catch(() => fetcher(keys, id)); - - - -export function shuffle(array: string[]) { - let currentIndex = array.length; - - while (currentIndex != 0) { - - const randomIndex = Math.floor(Math.random() * currentIndex); - currentIndex--; - - [array[currentIndex], array[randomIndex]] = [ - array[randomIndex], array[currentIndex]]; - } -} diff --git a/src/lib/libraryUtils.ts b/src/lib/libraryUtils.ts index 18445ba40..a26a3ddb5 100644 --- a/src/lib/libraryUtils.ts +++ b/src/lib/libraryUtils.ts @@ -130,13 +130,10 @@ export async function fetchCollection( listBtnsContainer.className = listContainer.classList.contains('reverse') ? 'reserved' : (shared ? 'shared' : 'collection'); - if (listBtnsContainer.classList.contains('favorites')) { - if (id !== 'favorites') - listBtnsContainer.classList.remove('favorites'); - } - else if (id === 'favorites') - listBtnsContainer.classList.add('favorites'); - + ['favorites', 'listenLater'].forEach(cls => { + listBtnsContainer.classList.toggle(cls, id === cls); + }); + if (location.pathname !== '/list') goTo('/list'); diff --git a/src/locales/fr.json b/src/locales/fr.json index 79003a6be..056a0f3fd 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -173,5 +173,6 @@ "list_sort_title": "Trier par Titre A↔Z", "list_sort_author": "Trier par Auteur A↔Z", "settings_audio_quality": "Qualité Audio", - "settings_prefetch": "Prélecture de la file d'attente" + "settings_prefetch": "Prélecture de la file d'attente", + "settings_jiosaavn": "Préférez JioSaavn pour la musique" } diff --git a/src/stylesheets/list.css b/src/stylesheets/list.css index 0cd9c0049..337ebd115 100644 --- a/src/stylesheets/list.css +++ b/src/stylesheets/list.css @@ -59,7 +59,8 @@ } } - &.favorites { + &.favorites, + &.listenLater { li { display: block !important; } @@ -116,4 +117,4 @@ font-family: inherit; } } -} \ No newline at end of file +}