You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
import z from "zod";
|
|
import { ThumbnailModel } from "../thumbnail";
|
|
import { VideoModel } from "../video";
|
|
|
|
export const VideoResultModel = z
|
|
.object({
|
|
type: z.literal("video")
|
|
})
|
|
.and(VideoModel);
|
|
|
|
export const ChannelResultModel = z.object({
|
|
type: z.literal("channel"),
|
|
author: z.string(),
|
|
authorId: z.string(),
|
|
authorUrl: z.string(),
|
|
authorThumbnails: z
|
|
.object({
|
|
url: z.string(),
|
|
width: z.number(),
|
|
height: z.number()
|
|
})
|
|
.array(),
|
|
autoGenerated: z.boolean(),
|
|
subCount: z.number(),
|
|
videoCount: z.number(),
|
|
description: z.string(),
|
|
descriptionHtml: z.string()
|
|
});
|
|
|
|
export const PlaylistResultModel = z.object({
|
|
type: z.literal("playlist"),
|
|
title: z.string(),
|
|
playlistId: z.string(),
|
|
playlistThumbnail: z.string().url(),
|
|
author: z.string(),
|
|
authorId: z.string(),
|
|
authorUrl: z.string(),
|
|
authorVerified: z.boolean(),
|
|
videoCount: z.number(),
|
|
videos: z.object({
|
|
title: z.string(),
|
|
videoId: z.string(),
|
|
lengthSeconds: z.number(),
|
|
videoThumbnails: ThumbnailModel.array()
|
|
})
|
|
});
|
|
|
|
export const SearchModel = z
|
|
.union([VideoResultModel, ChannelResultModel, PlaylistResultModel])
|
|
.array();
|
|
|
|
type Search = z.infer<typeof SearchModel>;
|
|
|
|
export default Search;
|