mirror of https://github.com/Chocobozzz/PeerTube
Display appropriate message on bad req
parent
bd87b4271b
commit
ad9eb48bab
|
@ -404,7 +404,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({ videos, type, askForForceTranscodingIfNeeded: true })
|
this.videoService.runTranscoding({ videos, type })
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notifier.success($localize`Transcoding jobs created.`)
|
this.notifier.success($localize`Transcoding jobs created.`)
|
||||||
|
|
|
@ -334,10 +334,9 @@ export class VideoService {
|
||||||
runTranscoding (options: {
|
runTranscoding (options: {
|
||||||
videos: Video[]
|
videos: Video[]
|
||||||
type: 'hls' | 'web-video'
|
type: 'hls' | 'web-video'
|
||||||
askForForceTranscodingIfNeeded: boolean
|
|
||||||
forceTranscoding?: boolean
|
forceTranscoding?: boolean
|
||||||
}): Observable<any> {
|
}): Observable<any> {
|
||||||
const { videos, type, askForForceTranscodingIfNeeded, forceTranscoding } = options
|
const { videos, type, forceTranscoding } = options
|
||||||
|
|
||||||
const body: VideoTranscodingCreate = { transcodingType: type, forceTranscoding }
|
const body: VideoTranscodingCreate = { transcodingType: type, forceTranscoding }
|
||||||
|
|
||||||
|
@ -347,7 +346,7 @@ export class VideoService {
|
||||||
return this.authHttp.post(VideoService.BASE_VIDEO_URL + '/' + video.uuid + '/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 (err.error?.code === ServerErrorCode.VIDEO_ALREADY_BEING_TRANSCODED && !forceTranscoding) {
|
||||||
const message = $localize`PeerTube considers video "${video.name}" 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.` +
|
||||||
|
@ -361,7 +360,6 @@ export class VideoService {
|
||||||
return this.runTranscoding({
|
return this.runTranscoding({
|
||||||
videos: [ video ],
|
videos: [ video ],
|
||||||
type,
|
type,
|
||||||
askForForceTranscodingIfNeeded: false,
|
|
||||||
forceTranscoding: true
|
forceTranscoding: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -342,7 +342,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
runTranscoding (video: Video, type: 'hls' | 'web-video') {
|
runTranscoding (video: Video, type: 'hls' | 'web-video') {
|
||||||
this.videoService.runTranscoding({ videos: [ video ], type, askForForceTranscodingIfNeeded: true })
|
this.videoService.runTranscoding({ videos: [ video ], type })
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notifier.success($localize`Transcoding job created for "${video.name}".`)
|
this.notifier.success($localize`Transcoding job created for "${video.name}".`)
|
||||||
|
@ -356,8 +356,10 @@ export class VideoActionsDropdownComponent implements OnChanges {
|
||||||
generateCaption (video: Video) {
|
generateCaption (video: Video) {
|
||||||
this.videoCaptionService.generateCaption([ video.id ])
|
this.videoCaptionService.generateCaption([ video.id ])
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: result => {
|
||||||
this.notifier.success($localize`Transcription job created for "${video.name}".`)
|
if (result.success) this.notifier.success($localize`Transcription job created for "${video.name}".`)
|
||||||
|
else if (result.alreadyBeingTranscribed) this.notifier.info($localize`This video is already being transcribed.`)
|
||||||
|
else if (result.alreadyHasCaptions) this.notifier.info($localize`This video already has captions.`)
|
||||||
},
|
},
|
||||||
|
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
|
|
Loading…
Reference in New Issue