1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Support <podcast:txt purpose="p20url"> element

This commit is contained in:
Chocobozzz 2025-03-04 13:49:01 +01:00
parent 888273a1d7
commit cb91056514
No known key found for this signature in database
GPG key ID: 583A612D890159BE
10 changed files with 212 additions and 103 deletions

View file

@ -5,35 +5,39 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
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
getXML (
options: OverrideCommandOptions & {
feed: FeedType
ignoreCache: boolean
format?: string
query?: { [id: string]: any }
}
) {
const { feed, format, ignoreCache, query = {} } = options
const path = '/feeds/' + feed + '.xml'
const query: { [id: string]: string } = {}
const internalQuery: { [id: string]: string } = {}
if (ignoreCache) query.v = buildUUID()
if (format) query.format = format
if (ignoreCache) internalQuery.v = buildUUID()
if (format) internalQuery.format = format
return this.getRequestText({
...options,
path,
query,
query: { ...internalQuery, ...query },
accept: 'application/xml',
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getPodcastXML (options: OverrideCommandOptions & {
ignoreCache: boolean
channelId: number
}) {
getPodcastXML (
options: OverrideCommandOptions & {
ignoreCache: boolean
channelId: number
}
) {
const { ignoreCache, channelId } = options
const path = `/feeds/podcast/videos.xml`
@ -53,11 +57,13 @@ export class FeedCommand extends AbstractCommand {
})
}
getJSON (options: OverrideCommandOptions & {
feed: FeedType
ignoreCache: boolean
query?: { [ id: string ]: any }
}) {
getJSON (
options: OverrideCommandOptions & {
feed: FeedType
ignoreCache: boolean
query?: { [id: string]: any }
}
) {
const { feed, query = {}, ignoreCache } = options
const path = '/feeds/' + feed + '.json'

View file

@ -13,7 +13,6 @@ import { unwrapBody } from '../requests/index.js'
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
export class ChannelsCommand extends AbstractCommand {
list (options: OverrideCommandOptions & {
start?: number
count?: number
@ -32,14 +31,16 @@ export class ChannelsCommand extends AbstractCommand {
})
}
listByAccount (options: OverrideCommandOptions & {
accountName: string
start?: number
count?: number
sort?: string
withStats?: boolean
search?: string
}) {
listByAccount (
options: OverrideCommandOptions & {
accountName: string
start?: number
count?: number
sort?: string
withStats?: boolean
search?: string
}
) {
const { accountName, sort = 'createdAt' } = options
const path = '/api/v1/accounts/' + accountName + '/video-channels'
@ -53,9 +54,11 @@ export class ChannelsCommand extends AbstractCommand {
})
}
async create (options: OverrideCommandOptions & {
attributes: Partial<VideoChannelCreate>
}) {
async create (
options: OverrideCommandOptions & {
attributes: Partial<VideoChannelCreate>
}
) {
const path = '/api/v1/video-channels/'
// Default attributes
@ -78,10 +81,12 @@ export class ChannelsCommand extends AbstractCommand {
return body.videoChannel
}
update (options: OverrideCommandOptions & {
channelName: string
attributes: VideoChannelUpdate
}) {
update (
options: OverrideCommandOptions & {
channelName: string
attributes: VideoChannelUpdate
}
) {
const { channelName, attributes } = options
const path = '/api/v1/video-channels/' + channelName
@ -95,9 +100,11 @@ export class ChannelsCommand extends AbstractCommand {
})
}
delete (options: OverrideCommandOptions & {
channelName: string
}) {
delete (
options: OverrideCommandOptions & {
channelName: string
}
) {
const path = '/api/v1/video-channels/' + options.channelName
return this.deleteRequest({
@ -109,9 +116,13 @@ export class ChannelsCommand extends AbstractCommand {
})
}
get (options: OverrideCommandOptions & {
channelName: string
}) {
// ---------------------------------------------------------------------------
get (
options: OverrideCommandOptions & {
channelName: string
}
) {
const path = '/api/v1/video-channels/' + options.channelName
return this.getRequestBody<VideoChannel>({
@ -123,11 +134,25 @@ export class ChannelsCommand extends AbstractCommand {
})
}
updateImage (options: OverrideCommandOptions & {
fixture: string
channelName: string | number
type: 'avatar' | 'banner'
}) {
async getIdOf (
options: OverrideCommandOptions & {
channelName: string
}
) {
const { id } = await this.get(options)
return id
}
// ---------------------------------------------------------------------------
updateImage (
options: OverrideCommandOptions & {
fixture: string
channelName: string | number
type: 'avatar' | 'banner'
}
) {
const { channelName, fixture, type } = options
const path = `/api/v1/video-channels/${channelName}/${type}/pick`
@ -144,10 +169,12 @@ export class ChannelsCommand extends AbstractCommand {
})
}
deleteImage (options: OverrideCommandOptions & {
channelName: string | number
type: 'avatar' | 'banner'
}) {
deleteImage (
options: OverrideCommandOptions & {
channelName: string | number
type: 'avatar' | 'banner'
}
) {
const { channelName, type } = options
const path = `/api/v1/video-channels/${channelName}/${type}`
@ -161,13 +188,15 @@ export class ChannelsCommand extends AbstractCommand {
})
}
listFollowers (options: OverrideCommandOptions & {
channelName: string
start?: number
count?: number
sort?: string
search?: string
}) {
listFollowers (
options: OverrideCommandOptions & {
channelName: string
start?: number
count?: number
sort?: string
search?: string
}
) {
const { channelName, start, count, sort, search } = options
const path = '/api/v1/video-channels/' + channelName + '/followers'
@ -183,9 +212,11 @@ export class ChannelsCommand extends AbstractCommand {
})
}
importVideos (options: OverrideCommandOptions & VideosImportInChannelCreate & {
channelName: string
}) {
importVideos (
options: OverrideCommandOptions & VideosImportInChannelCreate & {
channelName: string
}
) {
const { channelName, externalChannelUrl, videoChannelSyncId } = options
const path = `/api/v1/video-channels/${channelName}/import-videos`