mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-09-11 13:37:10 +03:00
Allow to bulk force transcoding
This commit is contained in:
parent
9784e93dc7
commit
57c94fb51c
@ -351,7 +351,7 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private runTranscoding (videos: Video[], type: 'hls' | 'web-video') {
|
private runTranscoding (videos: Video[], type: 'hls' | 'web-video') {
|
||||||
this.videoService.runTranscoding({ videoIds: videos.map(v => v.id), type, askForForceTranscodingIfNeeded: false })
|
this.videoService.runTranscoding({ videos, type, askForForceTranscodingIfNeeded: true })
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notifier.success($localize`Transcoding jobs created.`)
|
this.notifier.success($localize`Transcoding jobs created.`)
|
||||||
|
@ -270,7 +270,7 @@ export class Video implements VideoServerModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canRunTranscoding (user: AuthUser) {
|
canRunTranscoding (user: AuthUser) {
|
||||||
return this.canRunForcedTranscoding(user) && this.state.id !== VideoState.TO_TRANSCODE
|
return this.canRunForcedTranscoding(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
canRunForcedTranscoding (user: AuthUser) {
|
canRunForcedTranscoding (user: AuthUser) {
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { SortMeta } from 'primeng/api'
|
|
||||||
import { from, Observable, of, throwError } from 'rxjs'
|
|
||||||
import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
|
|
||||||
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
|
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core'
|
import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core'
|
||||||
@ -16,7 +13,6 @@ import {
|
|||||||
UserVideoRate,
|
UserVideoRate,
|
||||||
UserVideoRateType,
|
UserVideoRateType,
|
||||||
UserVideoRateUpdate,
|
UserVideoRateUpdate,
|
||||||
Video as VideoServerModel,
|
|
||||||
VideoChannel as VideoChannelServerModel,
|
VideoChannel as VideoChannelServerModel,
|
||||||
VideoConstant,
|
VideoConstant,
|
||||||
VideoDetails as VideoDetailsServerModel,
|
VideoDetails as VideoDetailsServerModel,
|
||||||
@ -24,20 +20,24 @@ import {
|
|||||||
VideoIncludeType,
|
VideoIncludeType,
|
||||||
VideoPrivacy,
|
VideoPrivacy,
|
||||||
VideoPrivacyType,
|
VideoPrivacyType,
|
||||||
|
Video as VideoServerModel,
|
||||||
VideoSortField,
|
VideoSortField,
|
||||||
VideoSource,
|
VideoSource,
|
||||||
VideoTranscodingCreate,
|
VideoTranscodingCreate,
|
||||||
VideoUpdate
|
VideoUpdate
|
||||||
} from '@peertube/peertube-models'
|
} from '@peertube/peertube-models'
|
||||||
|
import { SortMeta } from 'primeng/api'
|
||||||
|
import { from, Observable, of, throwError } from 'rxjs'
|
||||||
|
import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
|
||||||
import { environment } from '../../../../environments/environment'
|
import { environment } from '../../../../environments/environment'
|
||||||
import { Account } from '../account/account.model'
|
import { Account } from '../account/account.model'
|
||||||
import { AccountService } from '../account/account.service'
|
import { AccountService } from '../account/account.service'
|
||||||
|
import { VideoChannel } from '../video-channel/video-channel.model'
|
||||||
|
import { VideoChannelService } from '../video-channel/video-channel.service'
|
||||||
import { VideoDetails } from './video-details.model'
|
import { VideoDetails } from './video-details.model'
|
||||||
import { VideoEdit } from './video-edit.model'
|
import { VideoEdit } from './video-edit.model'
|
||||||
import { VideoPasswordService } from './video-password.service'
|
import { VideoPasswordService } from './video-password.service'
|
||||||
import { Video } from './video.model'
|
import { Video } from './video.model'
|
||||||
import { VideoChannel } from '../video-channel/video-channel.model'
|
|
||||||
import { VideoChannelService } from '../video-channel/video-channel.service'
|
|
||||||
|
|
||||||
export type CommonVideoParams = {
|
export type CommonVideoParams = {
|
||||||
videoPagination?: ComponentPaginationLight
|
videoPagination?: ComponentPaginationLight
|
||||||
@ -332,27 +332,23 @@ export class VideoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runTranscoding (options: {
|
runTranscoding (options: {
|
||||||
videoIds: (number | string)[]
|
videos: Video[]
|
||||||
type: 'hls' | 'web-video'
|
type: 'hls' | 'web-video'
|
||||||
askForForceTranscodingIfNeeded: boolean
|
askForForceTranscodingIfNeeded: boolean
|
||||||
forceTranscoding?: boolean
|
forceTranscoding?: boolean
|
||||||
}): Observable<any> {
|
}): Observable<any> {
|
||||||
const { videoIds, type, askForForceTranscodingIfNeeded, forceTranscoding } = options
|
const { videos, type, askForForceTranscodingIfNeeded, forceTranscoding } = options
|
||||||
|
|
||||||
if (askForForceTranscodingIfNeeded && videoIds.length !== 1) {
|
|
||||||
throw new Error('Cannot ask to force transcoding on multiple videos')
|
|
||||||
}
|
|
||||||
|
|
||||||
const body: VideoTranscodingCreate = { transcodingType: type, forceTranscoding }
|
const body: VideoTranscodingCreate = { transcodingType: type, forceTranscoding }
|
||||||
|
|
||||||
return from(videoIds)
|
return from(videos)
|
||||||
.pipe(
|
.pipe(
|
||||||
concatMap(id => {
|
concatMap(video => {
|
||||||
return this.authHttp.post(VideoService.BASE_VIDEO_URL + '/' + id + '/transcoding', body)
|
return this.authHttp.post(VideoService.BASE_VIDEO_URL + '/' + video.uuid + '/transcoding', body)
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
if (askForForceTranscodingIfNeeded && err.error?.code === ServerErrorCode.VIDEO_ALREADY_BEING_TRANSCODED) {
|
if (askForForceTranscodingIfNeeded && err.error?.code === ServerErrorCode.VIDEO_ALREADY_BEING_TRANSCODED) {
|
||||||
const message = $localize`PeerTube considers this video is already being transcoded.` +
|
const message = $localize`PeerTube considers video "${video.name}" is already being transcoded.` +
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
$localize` If you think PeerTube is wrong (video in broken state after a crash etc.), you can force transcoding on this video.` +
|
$localize` If you think PeerTube is wrong (video in broken state after a crash etc.), you can force transcoding on this video.` +
|
||||||
` Do you still want to run transcoding?`
|
` Do you still want to run transcoding?`
|
||||||
@ -362,7 +358,12 @@ export class VideoService {
|
|||||||
switchMap(res => {
|
switchMap(res => {
|
||||||
if (res === false) return throwError(() => err)
|
if (res === false) return throwError(() => err)
|
||||||
|
|
||||||
return this.runTranscoding({ videoIds, type, askForForceTranscodingIfNeeded: false, forceTranscoding: true })
|
return this.runTranscoding({
|
||||||
|
videos: [ video ],
|
||||||
|
type,
|
||||||
|
askForForceTranscodingIfNeeded: false,
|
||||||
|
forceTranscoding: true
|
||||||
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runTranscoding (video: Video, type: 'hls' | 'web-video') {
|
runTranscoding (video: Video, type: 'hls' | 'web-video') {
|
||||||
this.videoService.runTranscoding({ videoIds: [ video.id ], type, askForForceTranscodingIfNeeded: true })
|
this.videoService.runTranscoding({ videos: [ video ], type, askForForceTranscodingIfNeeded: true })
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notifier.success($localize`Transcoding jobs created for "${video.name}".`)
|
this.notifier.success($localize`Transcoding jobs created for "${video.name}".`)
|
||||||
|
Loading…
Reference in New Issue
Block a user