1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
import { buildUUID } from '@shared/extra-utils'
import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
type FeedType = 'videos' | 'video-comments' | 'subscriptions'
export class FeedCommand extends AbstractCommand {
getXML (options: OverrideCommandOptions & {
feed: FeedType
ignoreCache: boolean
format?: string
}) {
const { feed, format, ignoreCache } = options
const path = '/feeds/' + feed + '.xml'
const query: { [id: string]: string } = {}
if (ignoreCache) query.v = buildUUID()
if (format) query.format = format
return this.getRequestText({
...options,
path,
query,
accept: 'application/xml',
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getPodcastXML (options: OverrideCommandOptions & {
ignoreCache: boolean
channelId: number
}) {
const { ignoreCache, channelId } = options
const path = `/feeds/podcast/videos.xml`
const query: { [id: string]: string } = {}
if (ignoreCache) query.v = buildUUID()
if (channelId) query.videoChannelId = channelId + ''
return this.getRequestText({
...options,
path,
query,
accept: 'application/xml',
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getJSON (options: OverrideCommandOptions & {
feed: FeedType
ignoreCache: boolean
query?: { [ id: string ]: any }
}) {
const { feed, query = {}, ignoreCache } = options
const path = '/feeds/' + feed + '.json'
const cacheQuery = ignoreCache
? { v: buildUUID() }
: {}
return this.getRequestText({
...options,
path,
query: { ...query, ...cacheQuery },
accept: 'application/json',
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
}
|