UNPKG

ytmusic-api-proxy

Version:
179 lines (178 loc) 5.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.YTMusicOptions = exports.ProxyConfig = exports.HomeSection = exports.SearchResult = exports.PlaylistFull = exports.AlbumFull = exports.ArtistFull = exports.UpNextsDetails = exports.VideoFull = exports.SongFull = exports.PlaylistDetailed = exports.AlbumDetailed = exports.ArtistDetailed = exports.VideoDetailed = exports.SongDetailed = exports.AlbumBasic = exports.ArtistBasic = exports.ThumbnailFull = void 0; const zod_1 = require("zod"); exports.ThumbnailFull = zod_1.z .object({ url: zod_1.z.string(), width: zod_1.z.number(), height: zod_1.z.number(), }) .strict(); exports.ArtistBasic = zod_1.z .object({ artistId: zod_1.z.nullable(zod_1.z.string()), name: zod_1.z.string(), }) .strict(); exports.AlbumBasic = zod_1.z .object({ albumId: zod_1.z.string(), name: zod_1.z.string(), }) .strict(); exports.SongDetailed = zod_1.z .object({ type: zod_1.z.literal("SONG"), videoId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, album: zod_1.z.nullable(exports.AlbumBasic), duration: zod_1.z.nullable(zod_1.z.number()), thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.VideoDetailed = zod_1.z .object({ type: zod_1.z.literal("VIDEO"), videoId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, duration: zod_1.z.nullable(zod_1.z.number()), thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.ArtistDetailed = zod_1.z .object({ artistId: zod_1.z.string(), name: zod_1.z.string(), type: zod_1.z.literal("ARTIST"), thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.AlbumDetailed = zod_1.z .object({ type: zod_1.z.literal("ALBUM"), albumId: zod_1.z.string(), playlistId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, year: zod_1.z.nullable(zod_1.z.number()), thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.PlaylistDetailed = zod_1.z .object({ type: zod_1.z.literal("PLAYLIST"), playlistId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.SongFull = zod_1.z .object({ type: zod_1.z.literal("SONG"), videoId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, duration: zod_1.z.number(), thumbnails: zod_1.z.array(exports.ThumbnailFull), formats: zod_1.z.array(zod_1.z.any()), adaptiveFormats: zod_1.z.array(zod_1.z.any()), }) .strict(); exports.VideoFull = zod_1.z .object({ type: zod_1.z.literal("VIDEO"), videoId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, duration: zod_1.z.number(), thumbnails: zod_1.z.array(exports.ThumbnailFull), unlisted: zod_1.z.boolean(), familySafe: zod_1.z.boolean(), paid: zod_1.z.boolean(), tags: zod_1.z.array(zod_1.z.string()), }) .strict(); exports.UpNextsDetails = zod_1.z .object({ type: zod_1.z.literal("SONG"), videoId: zod_1.z.string(), title: zod_1.z.string(), artists: exports.ArtistBasic, duration: zod_1.z.number(), thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.ArtistFull = zod_1.z .object({ artistId: zod_1.z.string(), name: zod_1.z.string(), type: zod_1.z.literal("ARTIST"), thumbnails: zod_1.z.array(exports.ThumbnailFull), topSongs: zod_1.z.array(exports.SongDetailed), topAlbums: zod_1.z.array(exports.AlbumDetailed), topSingles: zod_1.z.array(exports.AlbumDetailed), topVideos: zod_1.z.array(exports.VideoDetailed), featuredOn: zod_1.z.array(exports.PlaylistDetailed), similarArtists: zod_1.z.array(exports.ArtistDetailed), }) .strict(); exports.AlbumFull = zod_1.z .object({ type: zod_1.z.literal("ALBUM"), albumId: zod_1.z.string(), playlistId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, year: zod_1.z.nullable(zod_1.z.number()), thumbnails: zod_1.z.array(exports.ThumbnailFull), songs: zod_1.z.array(exports.SongDetailed), }) .strict(); exports.PlaylistFull = zod_1.z .object({ type: zod_1.z.literal("PLAYLIST"), playlistId: zod_1.z.string(), name: zod_1.z.string(), artist: exports.ArtistBasic, videoCount: zod_1.z.number(), thumbnails: zod_1.z.array(exports.ThumbnailFull), }) .strict(); exports.SearchResult = zod_1.z.discriminatedUnion("type", [ exports.SongDetailed, exports.VideoDetailed, exports.AlbumDetailed, exports.ArtistDetailed, exports.PlaylistDetailed, ]); exports.HomeSection = zod_1.z .object({ title: zod_1.z.string(), contents: zod_1.z.array(zod_1.z.union([exports.AlbumDetailed, exports.PlaylistDetailed, exports.SongDetailed])), }) .strict(); exports.ProxyConfig = zod_1.z .object({ protocol: zod_1.z.enum(["http", "https", "socks4", "socks5"]).optional(), host: zod_1.z.string(), port: zod_1.z.number(), auth: zod_1.z .object({ username: zod_1.z.string(), password: zod_1.z.string(), }) .optional(), }) .strict(); exports.YTMusicOptions = zod_1.z .object({ cookies: zod_1.z.string().optional(), GL: zod_1.z.string().optional(), HL: zod_1.z.string().optional(), proxy: exports.ProxyConfig.optional(), }) .strict();