mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add ability to list and delete original file
In admin
This commit is contained in:
@@ -27,6 +27,7 @@ export type VideoFormattingJSONOptions = {
|
||||
scheduledUpdate?: boolean
|
||||
blacklistInfo?: boolean
|
||||
files?: boolean
|
||||
source?: boolean
|
||||
blockedOwner?: boolean
|
||||
}
|
||||
}
|
||||
@@ -41,6 +42,7 @@ export function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfte
|
||||
scheduledUpdate: !!(query.include & VideoInclude.NOT_PUBLISHED_STATE),
|
||||
blacklistInfo: !!(query.include & VideoInclude.BLACKLISTED),
|
||||
files: !!(query.include & VideoInclude.FILES),
|
||||
source: !!(query.include & VideoInclude.SOURCE),
|
||||
blockedOwner: !!(query.include & VideoInclude.BLOCKED_OWNER)
|
||||
}
|
||||
}
|
||||
@@ -310,5 +312,9 @@ function buildAdditionalAttributes (video: MVideoFormattable, options: VideoForm
|
||||
result.files = videoFilesModelToFormattedJSON(video, video.VideoFiles)
|
||||
}
|
||||
|
||||
if (add?.source === true) {
|
||||
result.videoSource = video.VideoSource?.toFormattedJSON() || null
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -247,6 +247,18 @@ export class AbstractVideoQueryBuilder extends AbstractRunQuery {
|
||||
}
|
||||
}
|
||||
|
||||
protected includeVideoSource () {
|
||||
this.addJoin(
|
||||
'LEFT OUTER JOIN "videoSource" AS "VideoSource" ON "video"."id" = "VideoSource"."videoId"'
|
||||
)
|
||||
|
||||
this.attributes = {
|
||||
...this.attributes,
|
||||
|
||||
...this.buildAttributesObject('VideoSource', this.tables.getVideoSourceAttributes())
|
||||
}
|
||||
}
|
||||
|
||||
protected includeTrackers () {
|
||||
this.addJoin(
|
||||
'LEFT OUTER JOIN (' +
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js'
|
||||
import { ServerModel } from '@server/models/server/server.js'
|
||||
import { TrackerModel } from '@server/models/server/tracker.js'
|
||||
import { UserVideoHistoryModel } from '@server/models/user/user-video-history.js'
|
||||
import { VideoSourceModel } from '@server/models/video/video-source.js'
|
||||
import { ScheduleVideoUpdateModel } from '../../../schedule-video-update.js'
|
||||
import { TagModel } from '../../../tag.js'
|
||||
import { ThumbnailModel } from '../../../thumbnail.js'
|
||||
@@ -39,6 +40,7 @@ export class VideoModelBuilder {
|
||||
private accountBlocklistDone: Set<any>
|
||||
private serverBlocklistDone: Set<any>
|
||||
private liveDone: Set<any>
|
||||
private sourceDone: Set<any>
|
||||
private redundancyDone: Set<any>
|
||||
private scheduleVideoUpdateDone: Set<any>
|
||||
|
||||
@@ -108,6 +110,10 @@ export class VideoModelBuilder {
|
||||
this.setBlockedOwner(row, videoModel)
|
||||
this.setBlockedServer(row, videoModel)
|
||||
}
|
||||
|
||||
if (include & VideoInclude.SOURCE) {
|
||||
this.setSource(row, videoModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +133,7 @@ export class VideoModelBuilder {
|
||||
this.historyDone = new Set()
|
||||
this.blacklistDone = new Set()
|
||||
this.liveDone = new Set()
|
||||
this.sourceDone = new Set()
|
||||
this.redundancyDone = new Set()
|
||||
this.scheduleVideoUpdateDone = new Set()
|
||||
|
||||
@@ -391,6 +398,16 @@ export class VideoModelBuilder {
|
||||
this.liveDone.add(id)
|
||||
}
|
||||
|
||||
private setSource (row: SQLRow, videoModel: VideoModel) {
|
||||
const id = row['VideoSource.id']
|
||||
if (!id || this.sourceDone.has(id)) return
|
||||
|
||||
const attributes = this.grab(row, this.tables.getVideoSourceAttributes(), 'VideoSource')
|
||||
videoModel.VideoSource = new VideoSourceModel(attributes, this.buildOpts)
|
||||
|
||||
this.sourceDone.add(id)
|
||||
}
|
||||
|
||||
private grab (row: SQLRow, attributes: string[], prefix: string) {
|
||||
const result: { [ id: string ]: string | number } = {}
|
||||
|
||||
|
||||
@@ -168,6 +168,21 @@ export class VideoTableAttributes {
|
||||
]
|
||||
}
|
||||
|
||||
getVideoSourceAttributes () {
|
||||
return [
|
||||
'id',
|
||||
'inputFilename',
|
||||
'keptOriginalFilename',
|
||||
'resolution',
|
||||
'size',
|
||||
'width',
|
||||
'height',
|
||||
'fps',
|
||||
'metadata',
|
||||
'createdAt'
|
||||
]
|
||||
}
|
||||
|
||||
getTrackerAttributes () {
|
||||
return [ 'id', 'url' ]
|
||||
}
|
||||
|
||||
@@ -702,9 +702,11 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
|
||||
'(SELECT COALESCE(SUM(size), 0) FROM "videoFile" WHERE "videoFile"."videoId" = "video"."id")' +
|
||||
' + ' +
|
||||
'(SELECT COALESCE(SUM(size), 0) FROM "videoFile" ' +
|
||||
'INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' +
|
||||
'AND "videoStreamingPlaylist"."videoId" = "video"."id"' +
|
||||
'INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' +
|
||||
'AND "videoStreamingPlaylist"."videoId" = "video"."id"' +
|
||||
')' +
|
||||
' + ' +
|
||||
'(SELECT COALESCE(SUM(size), 0) FROM "videoSource" WHERE "videoSource"."videoId" = "video"."id")' +
|
||||
') END' +
|
||||
') AS "localVideoFilesSize"'
|
||||
)
|
||||
|
||||
@@ -96,6 +96,10 @@ export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder {
|
||||
this.includeBlockedOwnerAndServer(options.serverAccountIdForBlock, options.user)
|
||||
}
|
||||
|
||||
if (options.include & VideoInclude.SOURCE) {
|
||||
this.includeVideoSource()
|
||||
}
|
||||
|
||||
const select = this.buildSelect()
|
||||
|
||||
this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins} ${this.innerSort}`
|
||||
|
||||
@@ -117,7 +117,9 @@ export class VideoSourceModel extends SequelizeModel<VideoSourceModel> {
|
||||
|
||||
resolution: {
|
||||
id: this.resolution,
|
||||
label: getResolutionLabel(this.resolution)
|
||||
label: this.resolution !== null
|
||||
? getResolutionLabel(this.resolution)
|
||||
: null
|
||||
},
|
||||
size: this.size,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user