Display appropriate message on bad req

pull/6527/head
Chocobozzz 2024-07-02 11:02:56 +02:00
parent bd87b4271b
commit ad9eb48bab
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 8 additions and 8 deletions

View File

@ -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.`)

View File

@ -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
}) })
}) })

View File

@ -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)