youtube-downloader

Simple Next.js website and interface to download YouTube videos to mp3 or mp4 files with URLs
git clone https://codeberg.org/night0721/youtube-downloader
Log | Files | Refs | README | LICENSE

commit 4d1c6e892f9881878a3b5c4d87eb55c484b6f576
parent ecf1d45af8d8a1e2002b5bb8148a584371548ac1
Author: NK <[email protected]>
Date:   Thu, 27 Apr 2023 15:23:04 +0100

fix

Diffstat:
Apublic/icon.png | 0
Msrc/pages/api/download.ts | 6++++++
Msrc/pages/index.tsx | 10+++-------
Mtailwind.config.js | 3+--
4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/public/icon.png b/public/icon.png Binary files differ. diff --git a/src/pages/api/download.ts b/src/pages/api/download.ts @@ -28,3 +28,9 @@ export default async function handler( res.status(405).json({ message: "Method not allowed", code: 405 }); } } + +export const config = { + api: { + responseLimit: false, + }, +}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx @@ -9,16 +9,13 @@ export default function Home() { const getTitle = async (videoID: string) => { const youtubeAPI = `https://www.googleapis.com/youtube/v3/videos?part=snippet&id=${videoID}&fields=items(id%2Csnippet)&key=AIzaSyB8Fk-MWT_r8nVgG35gIZoP-DhJYpJ_tZ0`; - let response = await fetch(youtubeAPI); - const res = await response.json(); - const title = res.items[0].snippet.title; - return title; + const response = await fetch(youtubeAPI).then(res => res.json()); + return response.items[0].snippet.title; }; const getVideoID = (url: string) => { if (url.match(/watch/)) { - const videoID = url.split("/")[3].split("?")[1].split("=")[1]; - return videoID; + return url.split("/")[3].split("?")[1].split("=")[1]; } else if (url.match(/youtu.be/)) { const videoID = url != "" && url.split("/")[3]; return videoID; @@ -39,7 +36,6 @@ export default function Home() { .then(res => res.blob()) .then(blob => { const sizeInBytes = blob.size; - console.log("sizeInBytes: ", sizeInBytes); if (sizeInBytes <= 0) { setInfo( "Unable to download! Maybe File size is too high. Try to download video less than 5MB" diff --git a/tailwind.config.js b/tailwind.config.js @@ -1,6 +1,5 @@ module.exports = { - purge: ["./src/pages/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"], - darkMode: false, // or 'media' or 'class' + purge: ["./src/pages/*.{js,ts,jsx,tsx}"], theme: { extend: {}, },