1 import { buildUUID } from '@shared/extra-utils'
2 import { HttpStatusCode } from '@shared/models'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 type FeedType = 'videos' | 'video-comments' | 'subscriptions'
7 export class FeedCommand extends AbstractCommand {
9 getXML (options: OverrideCommandOptions & {
14 const { feed, format, ignoreCache } = options
15 const path = '/feeds/' + feed + '.xml'
17 const query: { [id: string]: string } = {}
19 if (ignoreCache) query.v = buildUUID()
20 if (format) query.format = format
22 return this.getRequestText({
27 accept: 'application/xml',
29 defaultExpectedStatus: HttpStatusCode.OK_200
33 getPodcastXML (options: OverrideCommandOptions & {
37 const { ignoreCache, channelId } = options
38 const path = `/feeds/podcast/videos.xml`
40 const query: { [id: string]: string } = {}
42 if (ignoreCache) query.v = buildUUID()
43 if (channelId) query.videoChannelId = channelId + ''
45 return this.getRequestText({
50 accept: 'application/xml',
52 defaultExpectedStatus: HttpStatusCode.OK_200
56 getJSON (options: OverrideCommandOptions & {
59 query?: { [ id: string ]: any }
61 const { feed, query = {}, ignoreCache } = options
62 const path = '/feeds/' + feed + '.json'
64 const cacheQuery = ignoreCache
68 return this.getRequestText({
72 query: { ...query, ...cacheQuery },
73 accept: 'application/json',
75 defaultExpectedStatus: HttpStatusCode.OK_200