PeerTube/server/models/video/video-channel.ts

867 lines
23 KiB
TypeScript
Raw Normal View History

import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions, Transaction, WhereOptions } from 'sequelize'
2017-12-12 10:53:50 -06:00
import {
Add Podcast RSS feeds (#5487) * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Add medium/socialInteract to podcast RSS feeds. Use HTML for description * Change base production image to bullseye, install prosody in image * Add liveItem and trackers to Podcast RSS feeds Remove height from alternateEnclosure, replaced with title. * Clear Podcast RSS feed cache when live streams start/end * Upgrade to Node 16 * Refactor clearCacheRoute to use ApiCache * Remove unnecessary type hint * Update dockerfile to node 16, install python-is-python2 * Use new file paths for captions/playlists * Fix legacy videos in RSS after migration to object storage * Improve method of identifying non-fragmented mp4s in podcast RSS feeds * Don't include fragmented MP4s in podcast RSS feeds * Add experimental support for podcast:categories on the podcast RSS item * Fix undefined category when no videos exist Allows for empty feeds to exist (important for feeds that might only go live) * Add support for podcast:locked -- user has to opt in to show their email * Use comma for podcast:categories delimiter * Make cache clearing async * Fix merge, temporarily test with pfeed-podcast * Syntax changes * Add EXT_MIMETYPE constants for captions * Update & fix tests, fix enclosure mimetypes, remove admin email * Add test for podacst:socialInteract * Add filters hooks for podcast customTags * Remove showdown, updated to pfeed-podcast 6.1.2 * Add 'action:api.live-video.state.updated' hook * Avoid assigning undefined category to podcast feeds * Remove nvmrc * Remove comment * Remove unused podcast config * Remove more unused podcast config * Fix MChannelAccountDefault type hint missed in merge * Remove extra line * Re-add newline in config * Fix lint errors for isEmailPublic * Fix thumbnails in podcast feeds * Requested changes based on review * Provide podcast rss 2.0 only on video channels * Misc cleanup for a less messy PR * Lint fixes * Remove pfeed-podcast * Add peertube version to new hooks * Don't use query include, remove TODO * Remove film medium hack * Clear podcast rss cache before video/channel update hooks * Clear podcast rss cache before video uploaded/deleted hooks * Refactor podcast feed cache clearing * Set correct person name from video channel * Styling * Fix tests --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
2023-05-22 09:00:05 -05:00
AfterCreate,
AfterDestroy,
AfterUpdate,
AllowNull,
BeforeDestroy,
BelongsTo,
Column,
CreatedAt,
DataType,
Default,
DefaultScope,
ForeignKey,
2019-04-11 04:33:44 -05:00
HasMany,
Is,
Model,
Scopes,
2018-08-23 10:58:39 -05:00
Sequelize,
Table,
UpdatedAt
2017-12-12 10:53:50 -06:00
} from 'sequelize-typescript'
import { CONFIG } from '@server/initializers/config'
Add Podcast RSS feeds (#5487) * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Add medium/socialInteract to podcast RSS feeds. Use HTML for description * Change base production image to bullseye, install prosody in image * Add liveItem and trackers to Podcast RSS feeds Remove height from alternateEnclosure, replaced with title. * Clear Podcast RSS feed cache when live streams start/end * Upgrade to Node 16 * Refactor clearCacheRoute to use ApiCache * Remove unnecessary type hint * Update dockerfile to node 16, install python-is-python2 * Use new file paths for captions/playlists * Fix legacy videos in RSS after migration to object storage * Improve method of identifying non-fragmented mp4s in podcast RSS feeds * Don't include fragmented MP4s in podcast RSS feeds * Add experimental support for podcast:categories on the podcast RSS item * Fix undefined category when no videos exist Allows for empty feeds to exist (important for feeds that might only go live) * Add support for podcast:locked -- user has to opt in to show their email * Use comma for podcast:categories delimiter * Make cache clearing async * Fix merge, temporarily test with pfeed-podcast * Syntax changes * Add EXT_MIMETYPE constants for captions * Update & fix tests, fix enclosure mimetypes, remove admin email * Add test for podacst:socialInteract * Add filters hooks for podcast customTags * Remove showdown, updated to pfeed-podcast 6.1.2 * Add 'action:api.live-video.state.updated' hook * Avoid assigning undefined category to podcast feeds * Remove nvmrc * Remove comment * Remove unused podcast config * Remove more unused podcast config * Fix MChannelAccountDefault type hint missed in merge * Remove extra line * Re-add newline in config * Fix lint errors for isEmailPublic * Fix thumbnails in podcast feeds * Requested changes based on review * Provide podcast rss 2.0 only on video channels * Misc cleanup for a less messy PR * Lint fixes * Remove pfeed-podcast * Add peertube version to new hooks * Don't use query include, remove TODO * Remove film medium hack * Clear podcast rss cache before video/channel update hooks * Clear podcast rss cache before video uploaded/deleted hooks * Refactor podcast feed cache clearing * Set correct person name from video channel * Styling * Fix tests --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
2023-05-22 09:00:05 -05:00
import { InternalEventEmitter } from '@server/lib/internal-event-emitter'
import { MAccountHost } from '@server/types/models'
import { forceNumber, pick } from '@shared/core-utils'
import { AttributesOnly } from '@shared/typescript-utils'
2017-12-14 10:38:41 -06:00
import { ActivityPubActor } from '../../../shared/models/activitypub'
2019-02-26 03:55:40 -06:00
import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos'
import {
isVideoChannelDescriptionValid,
isVideoChannelDisplayNameValid,
isVideoChannelSupportValid
} from '../../helpers/custom-validators/video-channels'
import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants'
2020-11-10 09:29:35 -06:00
import { sendDeleteActor } from '../../lib/activitypub/send'
2019-08-15 04:53:26 -05:00
import {
MChannel,
2019-08-15 04:53:26 -05:00
MChannelActor,
2019-08-21 07:31:57 -05:00
MChannelAP,
2021-04-06 10:01:35 -05:00
MChannelBannerAccountDefault,
2019-08-21 07:31:57 -05:00
MChannelFormattable,
Add Podcast RSS feeds (#5487) * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Add medium/socialInteract to podcast RSS feeds. Use HTML for description * Change base production image to bullseye, install prosody in image * Add liveItem and trackers to Podcast RSS feeds Remove height from alternateEnclosure, replaced with title. * Clear Podcast RSS feed cache when live streams start/end * Upgrade to Node 16 * Refactor clearCacheRoute to use ApiCache * Remove unnecessary type hint * Update dockerfile to node 16, install python-is-python2 * Use new file paths for captions/playlists * Fix legacy videos in RSS after migration to object storage * Improve method of identifying non-fragmented mp4s in podcast RSS feeds * Don't include fragmented MP4s in podcast RSS feeds * Add experimental support for podcast:categories on the podcast RSS item * Fix undefined category when no videos exist Allows for empty feeds to exist (important for feeds that might only go live) * Add support for podcast:locked -- user has to opt in to show their email * Use comma for podcast:categories delimiter * Make cache clearing async * Fix merge, temporarily test with pfeed-podcast * Syntax changes * Add EXT_MIMETYPE constants for captions * Update & fix tests, fix enclosure mimetypes, remove admin email * Add test for podacst:socialInteract * Add filters hooks for podcast customTags * Remove showdown, updated to pfeed-podcast 6.1.2 * Add 'action:api.live-video.state.updated' hook * Avoid assigning undefined category to podcast feeds * Remove nvmrc * Remove comment * Remove unused podcast config * Remove more unused podcast config * Fix MChannelAccountDefault type hint missed in merge * Remove extra line * Re-add newline in config * Fix lint errors for isEmailPublic * Fix thumbnails in podcast feeds * Requested changes based on review * Provide podcast rss 2.0 only on video channels * Misc cleanup for a less messy PR * Lint fixes * Remove pfeed-podcast * Add peertube version to new hooks * Don't use query include, remove TODO * Remove film medium hack * Clear podcast rss cache before video/channel update hooks * Clear podcast rss cache before video uploaded/deleted hooks * Refactor podcast feed cache clearing * Set correct person name from video channel * Styling * Fix tests --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
2023-05-22 09:00:05 -05:00
MChannelHost,
2019-08-21 07:31:57 -05:00
MChannelSummaryFormattable
2020-06-18 03:45:25 -05:00
} from '../../types/models/video'
2020-11-10 09:29:35 -06:00
import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
2021-05-11 04:15:29 -05:00
import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor'
import { ActorFollowModel } from '../actor/actor-follow'
import { ActorImageModel } from '../actor/actor-image'
2020-11-10 09:29:35 -06:00
import { ServerModel } from '../server/server'
2023-01-10 04:09:30 -06:00
import {
buildServerIdsFollowedBy,
buildTrigramSearchIndex,
createSimilarityAttribute,
getSort,
setAsUpdated,
throwIfNotValid
} from '../shared'
2020-11-10 09:29:35 -06:00
import { VideoModel } from './video'
import { VideoPlaylistModel } from './video-playlist'
2018-08-23 10:58:39 -05:00
2019-02-26 03:55:40 -06:00
export enum ScopeNames {
2019-08-15 04:53:26 -05:00
FOR_API = 'FOR_API',
2020-03-23 04:14:05 -05:00
SUMMARY = 'SUMMARY',
2017-12-14 03:07:57 -06:00
WITH_ACCOUNT = 'WITH_ACCOUNT',
2017-12-14 10:38:41 -06:00
WITH_ACTOR = 'WITH_ACTOR',
2021-04-06 10:01:35 -05:00
WITH_ACTOR_BANNER = 'WITH_ACTOR_BANNER',
2019-02-26 03:55:40 -06:00
WITH_VIDEOS = 'WITH_VIDEOS',
2020-03-23 04:14:05 -05:00
WITH_STATS = 'WITH_STATS'
2017-12-14 03:07:57 -06:00
}
2018-08-23 10:58:39 -05:00
type AvailableForListOptions = {
actorId: number
search?: string
host?: string
handles?: string[]
forCount?: boolean
2018-08-23 10:58:39 -05:00
}
2020-03-23 04:14:05 -05:00
type AvailableWithStatsOptions = {
daysPrior: number
}
2019-07-31 08:57:32 -05:00
export type SummaryOptions = {
2020-07-07 07:34:16 -05:00
actorRequired?: boolean // Default: true
2019-07-31 08:57:32 -05:00
withAccount?: boolean // Default: false
withAccountBlockerIds?: number[]
}
2019-04-23 02:50:57 -05:00
@DefaultScope(() => ({
2017-12-14 10:38:41 -06:00
include: [
{
2019-04-23 02:50:57 -05:00
model: ActorModel,
2017-12-14 10:38:41 -06:00
required: true
}
]
2019-04-23 02:50:57 -05:00
}))
@Scopes(() => ({
2019-08-15 04:53:26 -05:00
[ScopeNames.FOR_API]: (options: AvailableForListOptions) => {
2018-08-23 10:58:39 -05:00
// Only list local channels OR channels that are on an instance followed by actorId
2019-02-26 03:55:40 -06:00
const inQueryInstanceFollow = buildServerIdsFollowedBy(options.actorId)
2018-08-23 10:58:39 -05:00
const whereActorAnd: WhereOptions[] = [
{
[Op.or]: [
{
serverId: null
},
{
serverId: {
[Op.in]: Sequelize.literal(inQueryInstanceFollow)
}
}
]
}
]
let serverRequired = false
let whereServer: WhereOptions
if (options.host && options.host !== WEBSERVER.HOST) {
serverRequired = true
whereServer = { host: options.host }
}
if (options.host === WEBSERVER.HOST) {
whereActorAnd.push({
serverId: null
})
}
if (Array.isArray(options.handles) && options.handles.length !== 0) {
const or: string[] = []
for (const handle of options.handles || []) {
const [ preferredUsername, host ] = handle.split('@')
const sanitizedPreferredUsername = VideoChannelModel.sequelize.escape(preferredUsername.toLowerCase())
const sanitizedHost = VideoChannelModel.sequelize.escape(host)
if (!host || host === WEBSERVER.HOST) {
or.push(`(LOWER("preferredUsername") = ${sanitizedPreferredUsername} AND "serverId" IS NULL)`)
} else {
or.push(
`(` +
`LOWER("preferredUsername") = ${sanitizedPreferredUsername} ` +
`AND "host" = ${sanitizedHost}` +
`)`
)
}
}
whereActorAnd.push({
id: {
[Op.in]: literal(`(SELECT "actor".id FROM actor LEFT JOIN server on server.id = actor."serverId" WHERE ${or.join(' OR ')})`)
}
})
}
2022-03-21 03:26:48 -05:00
const channelActorInclude: Includeable[] = []
const accountActorInclude: Includeable[] = []
if (options.forCount !== true) {
2022-03-21 03:26:48 -05:00
accountActorInclude.push({
model: ServerModel,
required: false
})
2022-03-21 03:26:48 -05:00
accountActorInclude.push({
model: ActorImageModel,
as: 'Avatars',
required: false
})
2022-03-21 03:26:48 -05:00
channelActorInclude.push({
model: ActorImageModel,
as: 'Avatars',
required: false
})
2022-03-21 03:26:48 -05:00
channelActorInclude.push({
model: ActorImageModel,
as: 'Banners',
required: false
})
}
if (options.forCount !== true || serverRequired) {
2022-03-21 03:26:48 -05:00
channelActorInclude.push({
model: ServerModel,
duplicating: false,
required: serverRequired,
where: whereServer
})
}
2018-08-23 10:58:39 -05:00
return {
include: [
{
attributes: {
exclude: unusedActorAttributesForAPI
},
model: ActorModel.unscoped(),
where: {
[Op.and]: whereActorAnd
},
2022-03-21 03:26:48 -05:00
include: channelActorInclude
2018-08-23 10:58:39 -05:00
},
{
model: AccountModel.unscoped(),
2018-08-23 10:58:39 -05:00
required: true,
include: [
{
attributes: {
exclude: unusedActorAttributesForAPI
},
model: ActorModel.unscoped(),
required: true,
2022-03-21 03:26:48 -05:00
include: accountActorInclude
2018-08-23 10:58:39 -05:00
}
]
}
]
}
},
2020-03-23 04:14:05 -05:00
[ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
2020-12-08 07:30:29 -06:00
const include: Includeable[] = [
{
attributes: [ 'id', 'preferredUsername', 'url', 'serverId' ],
2020-12-08 07:30:29 -06:00
model: ActorModel.unscoped(),
required: options.actorRequired ?? true,
include: [
{
attributes: [ 'host' ],
model: ServerModel.unscoped(),
required: false
},
{
model: ActorImageModel,
as: 'Avatars',
2020-12-08 07:30:29 -06:00
required: false
}
]
}
]
2020-03-23 04:14:05 -05:00
const base: FindOptions = {
2020-12-08 07:30:29 -06:00
attributes: [ 'id', 'name', 'description', 'actorId' ]
2020-03-23 04:14:05 -05:00
}
if (options.withAccount === true) {
2020-12-08 07:30:29 -06:00
include.push({
2020-03-23 04:14:05 -05:00
model: AccountModel.scope({
method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ]
}),
required: true
})
}
2020-12-08 07:30:29 -06:00
base.include = include
2020-03-23 04:14:05 -05:00
return base
},
2018-08-23 10:58:39 -05:00
[ScopeNames.WITH_ACCOUNT]: {
include: [
{
2019-04-23 02:50:57 -05:00
model: AccountModel,
2018-08-23 10:58:39 -05:00
required: true
2017-12-14 03:07:57 -06:00
}
]
},
2020-03-23 04:14:05 -05:00
[ScopeNames.WITH_ACTOR]: {
2017-12-14 03:07:57 -06:00
include: [
2020-03-23 04:14:05 -05:00
ActorModel
2017-12-14 03:07:57 -06:00
]
2017-12-14 10:38:41 -06:00
},
2021-04-06 10:01:35 -05:00
[ScopeNames.WITH_ACTOR_BANNER]: {
include: [
{
model: ActorModel,
include: [
{
model: ActorImageModel,
required: false,
as: 'Banners'
2021-04-06 10:01:35 -05:00
}
]
}
]
},
2020-03-23 04:14:05 -05:00
[ScopeNames.WITH_VIDEOS]: {
2017-12-14 10:38:41 -06:00
include: [
2020-03-23 04:14:05 -05:00
VideoModel
2017-12-14 10:38:41 -06:00
]
2020-03-23 04:14:05 -05:00
},
[ScopeNames.WITH_STATS]: (options: AvailableWithStatsOptions = { daysPrior: 30 }) => {
const daysPrior = forceNumber(options.daysPrior)
return {
attributes: {
include: [
2020-06-16 07:13:01 -05:00
[
literal('(SELECT COUNT(*) FROM "video" WHERE "channelId" = "VideoChannelModel"."id")'),
'videosCount'
],
[
literal(
'(' +
`SELECT string_agg(concat_ws('|', t.day, t.views), ',') ` +
'FROM ( ' +
'WITH ' +
'days AS ( ' +
`SELECT generate_series(date_trunc('day', now()) - '${daysPrior} day'::interval, ` +
`date_trunc('day', now()), '1 day'::interval) AS day ` +
2020-03-23 04:14:05 -05:00
') ' +
'SELECT days.day AS day, COALESCE(SUM("videoView".views), 0) AS views ' +
'FROM days ' +
'LEFT JOIN (' +
'"videoView" INNER JOIN "video" ON "videoView"."videoId" = "video"."id" ' +
'AND "video"."channelId" = "VideoChannelModel"."id"' +
`) ON date_trunc('day', "videoView"."startDate") = date_trunc('day', days.day) ` +
'GROUP BY day ' +
'ORDER BY day ' +
') t' +
')'
),
'viewsPerDay'
],
[
literal(
'(' +
'SELECT COALESCE(SUM("video".views), 0) AS totalViews ' +
'FROM "video" ' +
'WHERE "video"."channelId" = "VideoChannelModel"."id"' +
')'
),
'totalViews'
]
2020-03-23 04:14:05 -05:00
]
}
2020-03-23 04:14:05 -05:00
}
}
2019-04-23 02:50:57 -05:00
}))
2017-12-12 10:53:50 -06:00
@Table({
tableName: 'videoChannel',
2020-01-28 07:45:17 -06:00
indexes: [
buildTrigramSearchIndex('video_channel_name_trigram', 'name'),
{
fields: [ 'accountId' ]
},
{
fields: [ 'actorId' ]
}
]
2017-12-12 10:53:50 -06:00
})
2021-05-12 07:09:04 -05:00
export class VideoChannelModel extends Model<Partial<AttributesOnly<VideoChannelModel>>> {
2017-10-24 12:41:09 -05:00
2017-12-12 10:53:50 -06:00
@AllowNull(false)
@Is('VideoChannelName', value => throwIfNotValid(value, isVideoChannelDisplayNameValid, 'name'))
2017-12-12 10:53:50 -06:00
@Column
name: string
2017-10-24 12:41:09 -05:00
2017-12-12 10:53:50 -06:00
@AllowNull(true)
@Default(null)
2019-04-18 04:28:17 -05:00
@Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max))
2017-12-12 10:53:50 -06:00
description: string
2017-10-24 12:41:09 -05:00
@AllowNull(true)
@Default(null)
2019-04-18 04:28:17 -05:00
@Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max))
support: string
2017-12-12 10:53:50 -06:00
@CreatedAt
createdAt: Date
2017-10-24 12:41:09 -05:00
2017-12-12 10:53:50 -06:00
@UpdatedAt
updatedAt: Date
2017-12-14 04:18:49 -06:00
@ForeignKey(() => ActorModel)
@Column
actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
allowNull: false
},
onDelete: 'cascade'
})
Actor: ActorModel
2017-12-12 10:53:50 -06:00
@ForeignKey(() => AccountModel)
@Column
accountId: number
2017-12-12 10:53:50 -06:00
@BelongsTo(() => AccountModel, {
foreignKey: {
allowNull: false
2021-07-01 09:47:14 -05:00
}
2017-12-12 10:53:50 -06:00
})
Account: AccountModel
2017-10-24 12:41:09 -05:00
2017-12-12 10:53:50 -06:00
@HasMany(() => VideoModel, {
2017-10-24 12:41:09 -05:00
foreignKey: {
2017-12-12 10:53:50 -06:00
name: 'channelId',
2017-10-24 12:41:09 -05:00
allowNull: false
},
onDelete: 'CASCADE',
hooks: true
2017-10-24 12:41:09 -05:00
})
2017-12-12 10:53:50 -06:00
Videos: VideoModel[]
2017-10-24 12:41:09 -05:00
2019-02-26 03:55:40 -06:00
@HasMany(() => VideoPlaylistModel, {
foreignKey: {
2019-02-28 04:14:26 -06:00
allowNull: true
2019-02-26 03:55:40 -06:00
},
2019-03-05 03:58:44 -06:00
onDelete: 'CASCADE',
2019-02-26 03:55:40 -06:00
hooks: true
})
VideoPlaylists: VideoPlaylistModel[]
Add Podcast RSS feeds (#5487) * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Add medium/socialInteract to podcast RSS feeds. Use HTML for description * Change base production image to bullseye, install prosody in image * Add liveItem and trackers to Podcast RSS feeds Remove height from alternateEnclosure, replaced with title. * Clear Podcast RSS feed cache when live streams start/end * Upgrade to Node 16 * Refactor clearCacheRoute to use ApiCache * Remove unnecessary type hint * Update dockerfile to node 16, install python-is-python2 * Use new file paths for captions/playlists * Fix legacy videos in RSS after migration to object storage * Improve method of identifying non-fragmented mp4s in podcast RSS feeds * Don't include fragmented MP4s in podcast RSS feeds * Add experimental support for podcast:categories on the podcast RSS item * Fix undefined category when no videos exist Allows for empty feeds to exist (important for feeds that might only go live) * Add support for podcast:locked -- user has to opt in to show their email * Use comma for podcast:categories delimiter * Make cache clearing async * Fix merge, temporarily test with pfeed-podcast * Syntax changes * Add EXT_MIMETYPE constants for captions * Update & fix tests, fix enclosure mimetypes, remove admin email * Add test for podacst:socialInteract * Add filters hooks for podcast customTags * Remove showdown, updated to pfeed-podcast 6.1.2 * Add 'action:api.live-video.state.updated' hook * Avoid assigning undefined category to podcast feeds * Remove nvmrc * Remove comment * Remove unused podcast config * Remove more unused podcast config * Fix MChannelAccountDefault type hint missed in merge * Remove extra line * Re-add newline in config * Fix lint errors for isEmailPublic * Fix thumbnails in podcast feeds * Requested changes based on review * Provide podcast rss 2.0 only on video channels * Misc cleanup for a less messy PR * Lint fixes * Remove pfeed-podcast * Add peertube version to new hooks * Don't use query include, remove TODO * Remove film medium hack * Clear podcast rss cache before video/channel update hooks * Clear podcast rss cache before video uploaded/deleted hooks * Refactor podcast feed cache clearing * Set correct person name from video channel * Styling * Fix tests --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
2023-05-22 09:00:05 -05:00
@AfterCreate
static notifyCreate (channel: MChannel) {
InternalEventEmitter.Instance.emit('channel-created', { channel })
}
@AfterUpdate
static notifyUpdate (channel: MChannel) {
InternalEventEmitter.Instance.emit('channel-updated', { channel })
}
@AfterDestroy
static notifyDestroy (channel: MChannel) {
InternalEventEmitter.Instance.emit('channel-deleted', { channel })
}
@BeforeDestroy
static async sendDeleteIfOwned (instance: VideoChannelModel, options) {
if (!instance.Actor) {
instance.Actor = await instance.$get('Actor', { transaction: options.transaction })
}
2020-11-10 09:29:35 -06:00
await ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction)
if (instance.Actor.isOwned()) {
return sendDeleteActor(instance.Actor, options.transaction)
}
return undefined
2017-12-12 10:53:50 -06:00
}
2017-10-24 12:41:09 -05:00
2017-12-12 10:53:50 -06:00
static countByAccount (accountId: number) {
const query = {
where: {
accountId
}
2017-10-24 12:41:09 -05:00
}
2017-12-12 10:53:50 -06:00
return VideoChannelModel.unscoped().count(query)
2017-10-24 12:41:09 -05:00
}
static async getStats () {
2022-12-21 03:46:55 -06:00
function getLocalVideoChannelStats (days?: number) {
const options = {
type: QueryTypes.SELECT as QueryTypes.SELECT,
raw: true
}
2022-12-21 03:46:55 -06:00
const videoJoin = days
? `INNER JOIN "video" AS "Videos" ON "VideoChannelModel"."id" = "Videos"."channelId" ` +
`AND ("Videos"."publishedAt" > Now() - interval '${days}d')`
: ''
const query = `
2022-12-21 03:46:55 -06:00
SELECT COUNT(DISTINCT("VideoChannelModel"."id")) AS "count"
FROM "videoChannel" AS "VideoChannelModel"
${videoJoin}
INNER JOIN "account" AS "Account" ON "VideoChannelModel"."accountId" = "Account"."id"
INNER JOIN "actor" AS "Account->Actor" ON "Account"."actorId" = "Account->Actor"."id"
AND "Account->Actor"."serverId" IS NULL`
return VideoChannelModel.sequelize.query<{ count: string }>(query, options)
.then(r => parseInt(r[0].count, 10))
}
2022-12-21 03:46:55 -06:00
const totalLocalVideoChannels = await getLocalVideoChannelStats()
const totalLocalDailyActiveVideoChannels = await getLocalVideoChannelStats(1)
const totalLocalWeeklyActiveVideoChannels = await getLocalVideoChannelStats(7)
const totalLocalMonthlyActiveVideoChannels = await getLocalVideoChannelStats(30)
const totalLocalHalfYearActiveVideoChannels = await getLocalVideoChannelStats(180)
return {
totalLocalVideoChannels,
totalLocalDailyActiveVideoChannels,
totalLocalWeeklyActiveVideoChannels,
totalLocalMonthlyActiveVideoChannels,
2022-12-21 03:46:55 -06:00
totalLocalHalfYearActiveVideoChannels
}
}
2020-12-08 07:30:29 -06:00
static listLocalsForSitemap (sort: string): Promise<MChannelActor[]> {
2018-12-05 10:27:24 -06:00
const query = {
attributes: [ ],
offset: 0,
order: getSort(sort),
include: [
{
attributes: [ 'preferredUsername', 'serverId' ],
model: ActorModel.unscoped(),
where: {
serverId: null
}
}
]
}
return VideoChannelModel
.unscoped()
.findAll(query)
}
2021-07-29 07:17:03 -05:00
static listForApi (parameters: Pick<AvailableForListOptions, 'actorId'> & {
2018-08-23 10:58:39 -05:00
start: number
count: number
sort: string
2021-07-29 07:17:03 -05:00
}) {
const { actorId } = parameters
2021-07-29 07:17:03 -05:00
const query = {
offset: parameters.start,
limit: parameters.count,
order: getSort(parameters.sort)
}
const getScope = (forCount: boolean) => {
return { method: [ ScopeNames.FOR_API, { actorId, forCount } as AvailableForListOptions ] }
}
return Promise.all([
VideoChannelModel.scope(getScope(true)).count(),
VideoChannelModel.scope(getScope(false)).findAll(query)
]).then(([ total, data ]) => ({ total, data }))
2021-07-29 07:17:03 -05:00
}
static searchForApi (options: Pick<AvailableForListOptions, 'actorId' | 'search' | 'host' | 'handles'> & {
start: number
count: number
sort: string
2018-08-23 10:58:39 -05:00
}) {
let attributesInclude: any[] = [ literal('0 as similarity') ]
let where: WhereOptions
2018-08-23 10:58:39 -05:00
if (options.search) {
const escapedSearch = VideoChannelModel.sequelize.escape(options.search)
const escapedLikeSearch = VideoChannelModel.sequelize.escape('%' + options.search + '%')
attributesInclude = [ createSimilarityAttribute('VideoChannelModel.name', options.search) ]
where = {
2019-04-18 04:28:17 -05:00
[Op.or]: [
2018-08-28 08:16:04 -05:00
Sequelize.literal(
'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
),
Sequelize.literal(
'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
2018-08-23 10:58:39 -05:00
)
2018-08-28 08:16:04 -05:00
]
2018-08-23 10:58:39 -05:00
}
}
const query = {
attributes: {
include: attributesInclude
},
offset: options.start,
limit: options.count,
order: getSort(options.sort),
where
}
const getScope = (forCount: boolean) => {
return {
method: [
ScopeNames.FOR_API, {
...pick(options, [ 'actorId', 'host', 'handles' ]),
forCount
} as AvailableForListOptions
]
}
}
return Promise.all([
VideoChannelModel.scope(getScope(true)).count(query),
VideoChannelModel.scope(getScope(false)).findAll(query)
]).then(([ total, data ]) => ({ total, data }))
2017-10-24 12:41:09 -05:00
}
2021-10-19 02:44:43 -05:00
static listByAccountForAPI (options: {
2020-01-31 09:56:52 -06:00
accountId: number
start: number
count: number
sort: string
2020-03-23 04:14:05 -05:00
withStats?: boolean
2020-07-23 14:30:04 -05:00
search?: string
}) {
2020-07-23 14:30:04 -05:00
const escapedSearch = VideoModel.sequelize.escape(options.search)
const escapedLikeSearch = VideoModel.sequelize.escape('%' + options.search + '%')
const where = options.search
? {
[Op.or]: [
Sequelize.literal(
'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
),
Sequelize.literal(
'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
)
]
}
: null
const getQuery = (forCount: boolean) => {
const accountModel = forCount
? AccountModel.unscoped()
: AccountModel
return {
offset: options.start,
limit: options.count,
order: getSort(options.sort),
include: [
{
model: accountModel,
where: {
id: options.accountId
},
required: true
}
],
where
}
2017-12-12 10:53:50 -06:00
}
2017-10-24 12:41:09 -05:00
2022-03-21 03:26:48 -05:00
const findScopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR_BANNER ]
2020-03-23 04:14:05 -05:00
if (options.withStats === true) {
2022-03-21 03:26:48 -05:00
findScopes.push({
2020-03-23 04:14:05 -05:00
method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ]
})
}
return Promise.all([
2022-03-21 03:26:48 -05:00
VideoChannelModel.unscoped().count(getQuery(true)),
VideoChannelModel.scope(findScopes).findAll(getQuery(false))
]).then(([ total, data ]) => ({ total, data }))
2017-10-24 12:41:09 -05:00
}
static listAllByAccount (accountId: number): Promise<MChannel[]> {
2021-10-19 02:44:43 -05:00
const query = {
limit: CONFIG.VIDEO_CHANNELS.MAX_PER_USER,
2021-10-19 02:44:43 -05:00
include: [
{
attributes: [],
model: AccountModel.unscoped(),
2021-10-19 02:44:43 -05:00
where: {
id: accountId
},
required: true
}
]
}
return VideoChannelModel.findAll(query)
}
2021-06-15 02:17:19 -05:00
static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise<MChannelBannerAccountDefault> {
2018-09-04 03:22:10 -05:00
return VideoChannelModel.unscoped()
2021-04-06 10:01:35 -05:00
.scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])
2021-06-15 02:17:19 -05:00
.findByPk(id, { transaction })
2017-12-12 10:53:50 -06:00
}
2017-11-10 07:34:45 -06:00
2021-04-06 10:01:35 -05:00
static loadByUrlAndPopulateAccount (url: string): Promise<MChannelBannerAccountDefault> {
2018-08-23 10:58:39 -05:00
const query = {
include: [
{
model: ActorModel,
required: true,
where: {
url
2021-04-06 10:01:35 -05:00
},
include: [
{
model: ActorImageModel,
required: false,
as: 'Banners'
2021-04-06 10:01:35 -05:00
}
]
2018-08-23 10:58:39 -05:00
}
]
}
return VideoChannelModel
.scope([ ScopeNames.WITH_ACCOUNT ])
2018-08-17 08:45:42 -05:00
.findOne(query)
2017-10-24 12:41:09 -05:00
}
2019-02-21 07:06:10 -06:00
static loadByNameWithHostAndPopulateAccount (nameWithHost: string) {
const [ name, host ] = nameWithHost.split('@')
2019-04-11 04:33:44 -05:00
if (!host || host === WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
2019-02-21 07:06:10 -06:00
return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
}
2021-04-06 10:01:35 -05:00
static loadLocalByNameAndPopulateAccount (name: string): Promise<MChannelBannerAccountDefault> {
2018-08-17 08:45:42 -05:00
const query = {
2017-12-12 10:53:50 -06:00
include: [
2018-08-17 08:45:42 -05:00
{
model: ActorModel,
required: true,
where: {
[Op.and]: [
2023-05-12 02:06:16 -05:00
ActorModel.wherePreferredUsername(name, 'Actor.preferredUsername'),
{ serverId: null }
]
2021-04-06 10:01:35 -05:00
},
include: [
{
model: ActorImageModel,
required: false,
as: 'Banners'
2021-04-06 10:01:35 -05:00
}
]
2018-08-17 08:45:42 -05:00
}
2017-12-12 10:53:50 -06:00
]
}
2017-10-24 12:41:09 -05:00
2018-09-04 03:22:10 -05:00
return VideoChannelModel.unscoped()
2021-04-06 10:01:35 -05:00
.scope([ ScopeNames.WITH_ACCOUNT ])
2018-08-17 08:45:42 -05:00
.findOne(query)
2017-10-24 12:41:09 -05:00
}
2021-04-06 10:01:35 -05:00
static loadByNameAndHostAndPopulateAccount (name: string, host: string): Promise<MChannelBannerAccountDefault> {
const query = {
include: [
{
model: ActorModel,
required: true,
2023-05-12 02:06:16 -05:00
where: ActorModel.wherePreferredUsername(name, 'Actor.preferredUsername'),
2018-08-17 08:45:42 -05:00
include: [
{
model: ServerModel,
required: true,
where: { host }
2021-04-06 10:01:35 -05:00
},
{
model: ActorImageModel,
required: false,
as: 'Banners'
2018-08-17 08:45:42 -05:00
}
]
}
]
}
2018-09-04 03:22:10 -05:00
return VideoChannelModel.unscoped()
2021-04-06 10:01:35 -05:00
.scope([ ScopeNames.WITH_ACCOUNT ])
2018-08-17 08:45:42 -05:00
.findOne(query)
}
2019-08-20 12:05:31 -05:00
toFormattedSummaryJSON (this: MChannelSummaryFormattable): VideoChannelSummary {
const actor = this.Actor.toFormattedSummaryJSON()
return {
id: this.id,
name: actor.name,
displayName: this.getDisplayName(),
url: actor.url,
host: actor.host,
avatars: actor.avatars,
// TODO: remove, deprecated in 4.2
2019-08-20 12:05:31 -05:00
avatar: actor.avatar
}
}
toFormattedJSON (this: MChannelFormattable): VideoChannel {
2020-06-16 07:13:01 -05:00
const viewsPerDayString = this.get('viewsPerDay') as string
const videosCount = this.get('videosCount') as number
let viewsPerDay: { date: Date, views: number }[]
if (viewsPerDayString) {
viewsPerDay = viewsPerDayString.split(',')
.map(v => {
const [ dateString, amount ] = v.split('|')
return {
date: new Date(dateString),
views: +amount
}
})
}
2020-03-23 04:14:05 -05:00
const totalViews = this.get('totalViews') as number
2017-12-14 10:38:41 -06:00
const actor = this.Actor.toFormattedJSON()
2018-04-25 03:21:38 -05:00
const videoChannel = {
2017-12-12 10:53:50 -06:00
id: this.id,
displayName: this.getDisplayName(),
2017-12-12 10:53:50 -06:00
description: this.description,
support: this.support,
2017-12-14 10:38:41 -06:00
isLocal: this.Actor.isOwned(),
updatedAt: this.updatedAt,
2020-03-23 04:14:05 -05:00
ownerAccount: undefined,
2020-06-16 07:13:01 -05:00
videosCount,
viewsPerDay,
totalViews,
avatars: actor.avatars,
// TODO: remove, deprecated in 4.2
avatar: actor.avatar
2018-04-25 03:21:38 -05:00
}
2018-05-23 04:38:00 -05:00
if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()
2017-10-24 12:41:09 -05:00
2018-04-25 03:21:38 -05:00
return Object.assign(actor, videoChannel)
2017-10-24 12:41:09 -05:00
}
async toActivityPubObject (this: MChannelAP): Promise<ActivityPubActor> {
const obj = await this.Actor.toActivityPubObject(this.name)
2017-12-14 10:38:41 -06:00
return Object.assign(obj, {
summary: this.description,
support: this.support,
2017-12-14 10:38:41 -06:00
attributedTo: [
{
type: 'Person' as 'Person',
id: this.Account.Actor.url
}
]
})
2017-10-24 12:41:09 -05:00
}
Add Podcast RSS feeds (#5487) * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Initial test implementation of Podcast RSS This is a pretty simple implementation to add support for The Podcast Namespace in RSS -- instead of affecting the existing RSS implementation, this adds a new UI option. I attempted to retain compatibility with the rest of the RSS feed implementation as much as possible and have created a temporary fork of the "pfeed" library to support this effort. * Update to pfeed-podcast 1.2.2 * Add correct feed image to RSS channel * Prefer HLS videos for podcast RSS Remove video/stream titles, add optional height attribute to podcast RSS * Prefix podcast RSS images with root server URL * Add optional video query support to include captions * Add transcripts & person images to podcast RSS feed * Prefer webseed/webtorrent files over HLS fragmented mp4s * Experimentally adding podcast fields to basic config page * Add validation for new basic config fields * Don't include "content" in podcast feed, use full description for "description" * Add medium/socialInteract to podcast RSS feeds. Use HTML for description * Change base production image to bullseye, install prosody in image * Add liveItem and trackers to Podcast RSS feeds Remove height from alternateEnclosure, replaced with title. * Clear Podcast RSS feed cache when live streams start/end * Upgrade to Node 16 * Refactor clearCacheRoute to use ApiCache * Remove unnecessary type hint * Update dockerfile to node 16, install python-is-python2 * Use new file paths for captions/playlists * Fix legacy videos in RSS after migration to object storage * Improve method of identifying non-fragmented mp4s in podcast RSS feeds * Don't include fragmented MP4s in podcast RSS feeds * Add experimental support for podcast:categories on the podcast RSS item * Fix undefined category when no videos exist Allows for empty feeds to exist (important for feeds that might only go live) * Add support for podcast:locked -- user has to opt in to show their email * Use comma for podcast:categories delimiter * Make cache clearing async * Fix merge, temporarily test with pfeed-podcast * Syntax changes * Add EXT_MIMETYPE constants for captions * Update & fix tests, fix enclosure mimetypes, remove admin email * Add test for podacst:socialInteract * Add filters hooks for podcast customTags * Remove showdown, updated to pfeed-podcast 6.1.2 * Add 'action:api.live-video.state.updated' hook * Avoid assigning undefined category to podcast feeds * Remove nvmrc * Remove comment * Remove unused podcast config * Remove more unused podcast config * Fix MChannelAccountDefault type hint missed in merge * Remove extra line * Re-add newline in config * Fix lint errors for isEmailPublic * Fix thumbnails in podcast feeds * Requested changes based on review * Provide podcast rss 2.0 only on video channels * Misc cleanup for a less messy PR * Lint fixes * Remove pfeed-podcast * Add peertube version to new hooks * Don't use query include, remove TODO * Remove film medium hack * Clear podcast rss cache before video/channel update hooks * Clear podcast rss cache before video uploaded/deleted hooks * Refactor podcast feed cache clearing * Set correct person name from video channel * Styling * Fix tests --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
2023-05-22 09:00:05 -05:00
// Avoid error when running this method on MAccount... | MChannel...
getClientUrl (this: MAccountHost | MChannelHost) {
return WEBSERVER.URL + '/c/' + this.Actor.getIdentifier()
}
getDisplayName () {
return this.name
}
2019-01-14 04:30:15 -06:00
isOutdated () {
return this.Actor.isOutdated()
}
2021-08-30 09:24:25 -05:00
setAsUpdated (transaction?: Transaction) {
2023-01-10 04:09:30 -06:00
return setAsUpdated({ sequelize: this.sequelize, table: 'videoChannel', id: this.id, transaction })
}
2017-10-24 12:41:09 -05:00
}