This commit is contained in:
NK 2023-04-27 15:23:04 +01:00
parent ecf1d45af8
commit 4d1c6e892f
4 changed files with 10 additions and 9 deletions

BIN
public/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View file

@ -28,3 +28,9 @@ export default async function handler(
res.status(405).json({ message: "Method not allowed", code: 405 }); res.status(405).json({ message: "Method not allowed", code: 405 });
} }
} }
export const config = {
api: {
responseLimit: false,
},
};

View file

@ -9,16 +9,13 @@ export default function Home() {
const getTitle = async (videoID: string) => { 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`; 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 response = await fetch(youtubeAPI).then(res => res.json());
const res = await response.json(); return response.items[0].snippet.title;
const title = res.items[0].snippet.title;
return title;
}; };
const getVideoID = (url: string) => { const getVideoID = (url: string) => {
if (url.match(/watch/)) { if (url.match(/watch/)) {
const videoID = url.split("/")[3].split("?")[1].split("=")[1]; return url.split("/")[3].split("?")[1].split("=")[1];
return videoID;
} else if (url.match(/youtu.be/)) { } else if (url.match(/youtu.be/)) {
const videoID = url != "" && url.split("/")[3]; const videoID = url != "" && url.split("/")[3];
return videoID; return videoID;
@ -39,7 +36,6 @@ export default function Home() {
.then(res => res.blob()) .then(res => res.blob())
.then(blob => { .then(blob => {
const sizeInBytes = blob.size; const sizeInBytes = blob.size;
console.log("sizeInBytes: ", sizeInBytes);
if (sizeInBytes <= 0) { if (sizeInBytes <= 0) {
setInfo( setInfo(
"Unable to download! Maybe File size is too high. Try to download video less than 5MB" "Unable to download! Maybe File size is too high. Try to download video less than 5MB"

View file

@ -1,6 +1,5 @@
module.exports = { module.exports = {
purge: ["./src/pages/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"], purge: ["./src/pages/*.{js,ts,jsx,tsx}"],
darkMode: false, // or 'media' or 'class'
theme: { theme: {
extend: {}, extend: {},
}, },