5 VideoChannelsSearchQuery,
7 VideoPlaylistsSearchQuery,
9 } from '@shared/models'
10 import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
11 import { AbstractCommand, OverrideCommandOptions } from '../shared'
13 export class SearchCommand extends AbstractCommand {
15 searchChannels (options: OverrideCommandOptions & {
18 return this.advancedChannelSearch({
21 search: { search: options.search }
25 advancedChannelSearch (options: OverrideCommandOptions & {
26 search: VideoChannelsSearchQuery
28 const { search, token } = options
29 const path = '/api/v1/search/video-channels'
31 return this.getRequestBody<ResultList<VideoChannel>>({
38 defaultExpectedStatus: HttpStatusCode.OK_200
42 searchPlaylists (options: OverrideCommandOptions & {
45 return this.advancedPlaylistSearch({
48 search: { search: options.search }
52 advancedPlaylistSearch (options: OverrideCommandOptions & {
53 search: VideoPlaylistsSearchQuery
55 const { search, token } = options
56 const path = '/api/v1/search/video-playlists'
58 return this.getRequestBody<ResultList<VideoPlaylist>>({
65 defaultExpectedStatus: HttpStatusCode.OK_200
69 searchVideos (options: OverrideCommandOptions & {
73 const { search, sort } = options
75 return this.advancedVideoSearch({
80 sort: sort ?? '-publishedAt'
85 advancedVideoSearch (options: OverrideCommandOptions & {
86 search: VideosSearchQuery
88 const { search, token } = options
89 const path = '/api/v1/search/videos'
91 return this.getRequestBody<ResultList<Video>>({
98 defaultExpectedStatus: HttpStatusCode.OK_200