Display appropriate message on bad req

This commit is contained in:
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') {
this.videoService.runTranscoding({ videos, type, askForForceTranscodingIfNeeded: true })
this.videoService.runTranscoding({ videos, type })
.subscribe({
next: () => {
this.notifier.success($localize`Transcoding jobs created.`)

View File

@ -334,10 +334,9 @@ export class VideoService {
runTranscoding (options: {
videos: Video[]
type: 'hls' | 'web-video'
askForForceTranscodingIfNeeded: boolean
forceTranscoding?: boolean
}): Observable<any> {
const { videos, type, askForForceTranscodingIfNeeded, forceTranscoding } = options
const { videos, type, forceTranscoding } = options
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)
.pipe(
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.` +
// 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.` +
@ -361,7 +360,6 @@ export class VideoService {
return this.runTranscoding({
videos: [ video ],
type,
askForForceTranscodingIfNeeded: false,
forceTranscoding: true
})
})

View File

@ -342,7 +342,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
}
runTranscoding (video: Video, type: 'hls' | 'web-video') {
this.videoService.runTranscoding({ videos: [ video ], type, askForForceTranscodingIfNeeded: true })
this.videoService.runTranscoding({ videos: [ video ], type })
.subscribe({
next: () => {
this.notifier.success($localize`Transcoding job created for "${video.name}".`)
@ -356,8 +356,10 @@ export class VideoActionsDropdownComponent implements OnChanges {
generateCaption (video: Video) {
this.videoCaptionService.generateCaption([ video.id ])
.subscribe({
next: () => {
this.notifier.success($localize`Transcription job created for "${video.name}".`)
next: result => {
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)