]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/video-caption/video-caption.service.ts
Add simple subtitle edition from video captions tab
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / video-caption / video-caption.service.ts
index 97b79d84268c0489bbdb25650a44fef9a49f2114..67eb09e4d5e7bcfcc3be9a575ab2ab16b66106ff 100644 (file)
@@ -8,6 +8,7 @@ import { VideoService } from '@app/shared/shared-main/video'
 import { peertubeTranslate } from '@shared/core-utils/i18n'
 import { ResultList, VideoCaption } from '@shared/models'
 import { VideoCaptionEdit } from './video-caption-edit.model'
+import { environment } from '../../../../environments/environment'
 
 @Injectable()
 export class VideoCaptionService {
@@ -57,7 +58,7 @@ export class VideoCaptionService {
     let obs: Observable<any> = of(undefined)
 
     for (const videoCaption of videoCaptions) {
-      if (videoCaption.action === 'CREATE') {
+      if (videoCaption.action === 'CREATE' || videoCaption.action === 'UPDATE') {
         obs = obs.pipe(switchMap(() => this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile)))
       } else if (videoCaption.action === 'REMOVE') {
         obs = obs.pipe(switchMap(() => this.removeCaption(videoId, videoCaption.language.id)))
@@ -66,4 +67,8 @@ export class VideoCaptionService {
 
     return obs
   }
+
+  getCaptionContent ({ captionPath }: Pick<VideoCaption, 'captionPath'>) {
+    return this.authHttp.get(`${environment.originServerUrl}${captionPath}`, { responseType: 'text' })
+  }
 }