UNPKG

yt-dlx

Version:

Effortless Audio-Video Downloader And Streamer!

46 lines 1.98 kB
import colors from "colors"; import { z, ZodError } from "zod"; import TubeLogin from "../../utils/TubeLogin"; const ZodSchema = z.object({ cookies: z.string(), verbose: z.boolean().optional() }); export default async function unseen_notifications(options) { try { ZodSchema.parse(options); const { verbose, cookies } = options; if (verbose) console.log(colors.green("@info:"), "Fetching unseen notifications..."); if (!cookies) { throw new Error(`${colors.red("@error:")} Cookies not provided!`); } const client = await TubeLogin(cookies); if (!client) { throw new Error(`${colors.red("@error:")} Could not initialize Tube client.`); } const count = await client.getUnseenNotificationsCount(); if (count === undefined) { throw new Error(`${colors.red("@error:")} Failed to fetch unseen notifications count.`); } const result = { status: "success", data: { count: Number(count) || 0 } }; if (verbose) console.log(colors.green("@info:"), "❣️ Thank you for using yt-dlx. Consider 🌟starring the GitHub repo https://github.com/yt-dlx."); return result; } catch (error) { if (error instanceof ZodError) { const errorMessage = `${colors.red("@error:")} Argument validation failed: ${error.errors.map(e => `${e.path.join(".")}: ${e.message}`).join(", ")}`; console.error(errorMessage); throw new Error(errorMessage); } else if (error instanceof Error) { console.error(error.message); throw error; } else { const unexpectedError = `${colors.red("@error:")} An unexpected error occurred: ${String(error)}`; console.error(unexpectedError); throw new Error(unexpectedError); } } finally { } } //# sourceMappingURL=UnseenNotifications.js.map