import { HttpStatusCode , ResultList , Video , VideoChannel , VideoChannelsSearchQuery , VideoPlaylist , VideoPlaylistsSearchQuery , VideosSearchQuery } from '@shared/models' ; import { AbstractCommand , OverrideCommandOptions } from '../shared' ; export class SearchCommand extends AbstractCommand { searchChannels ( options ) { return this . advancedChannelSearch ( { ... options , search : { search : options . search } } ) ; } advancedChannelSearch ( options ) { const { search } = options ; const path = '/api/v1/search/video-channels' ; return this . getRequestBody < ResultList < VideoChannel > > ( { ... options , path , query : search , implicitToken : false , defaultExpectedStatus : HttpStatusCode . OK_200 } ) ; } searchPlaylists ( options ) { return this . advancedPlaylistSearch ( { ... options , search : { search : options . search } } ) ; } advancedPlaylistSearch ( options ) { const { search } = options ; const path = '/api/v1/search/video-playlists' ; return this . getRequestBody < ResultList < VideoPlaylist > > ( { ... options , path , query : search , implicitToken : false , defaultExpectedStatus : HttpStatusCode . OK_200 } ) ; } searchVideos ( options ) { const { search , sort } = options ; return this . advancedVideoSearch ( { ... options , search : { search : search , sort : sort ?? '-publishedAt' } } ) ; } advancedVideoSearch ( options ) { const { search } = options ; const path = '/api/v1/search/videos' ; return this . getRequestBody < ResultList < Video > > ( { ... options , path , query : search , implicitToken : false , defaultExpectedStatus : HttpStatusCode . OK_200 } ) ; } }