]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-streaming-playlist.ts
Dissociate video file names and video uuid
[github/Chocobozzz/PeerTube.git] / server / models / video / video-streaming-playlist.ts
index 148768c210a8c73183fbc6288651970cbb1254ba..c9375b4338ac419c31e26411a6cfc5c11187b42a 100644 (file)
@@ -1,28 +1,18 @@
+import * as memoizee from 'memoizee'
+import { join } from 'path'
+import { Op, QueryTypes } from 'sequelize'
 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
-import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
-import { throwIfNotValid } from '../utils'
-import { VideoModel } from './video'
-import { VideoRedundancyModel } from '../redundancy/video-redundancy'
+import { VideoFileModel } from '@server/models/video/video-file'
+import { MStreamingPlaylist } from '@server/types/models'
 import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
-import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
-import {
-  CONSTRAINTS_FIELDS,
-  MEMOIZE_LENGTH,
-  MEMOIZE_TTL,
-  P2P_MEDIA_LOADER_PEER_VERSION,
-  STATIC_DOWNLOAD_PATHS,
-  STATIC_PATHS
-} from '../../initializers/constants'
-import { join } from 'path'
 import { sha1 } from '../../helpers/core-utils'
+import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
 import { isArrayOf } from '../../helpers/custom-validators/misc'
-import { Op, QueryTypes } from 'sequelize'
-import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideoFile } from '@server/types/models'
-import { VideoFileModel } from '@server/models/video/video-file'
-import { getTorrentFileName, getTorrentFilePath, getVideoFilename } from '@server/lib/video-paths'
-import * as memoizee from 'memoizee'
-import { remove } from 'fs-extra'
-import { logger } from '@server/helpers/logger'
+import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
+import { CONSTRAINTS_FIELDS, MEMOIZE_LENGTH, MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, STATIC_PATHS } from '../../initializers/constants'
+import { VideoRedundancyModel } from '../redundancy/video-redundancy'
+import { throwIfNotValid } from '../utils'
+import { VideoModel } from './video'
 
 @Table({
   tableName: 'videoStreamingPlaylist',
@@ -196,26 +186,6 @@ export class VideoStreamingPlaylistModel extends Model {
     return 'unknown'
   }
 
-  getVideoRedundancyUrl (baseUrlHttp: string) {
-    return baseUrlHttp + STATIC_PATHS.REDUNDANCY + this.getStringType() + '/' + this.Video.uuid
-  }
-
-  getTorrentDownloadUrl (videoFile: MVideoFile, baseUrlHttp: string) {
-    return baseUrlHttp + STATIC_DOWNLOAD_PATHS.TORRENTS + getTorrentFileName(this, videoFile)
-  }
-
-  getVideoFileDownloadUrl (videoFile: MVideoFile, baseUrlHttp: string) {
-    return baseUrlHttp + STATIC_DOWNLOAD_PATHS.HLS_VIDEOS + getVideoFilename(this, videoFile)
-  }
-
-  getVideoFileUrl (videoFile: MVideoFile, baseUrlHttp: string) {
-    return baseUrlHttp + join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, this.Video.uuid, getVideoFilename(this, videoFile))
-  }
-
-  getTorrentUrl (videoFile: MVideoFile, baseUrlHttp: string) {
-    return baseUrlHttp + join(STATIC_PATHS.TORRENTS, getTorrentFileName(this, videoFile))
-  }
-
   getTrackerUrls (baseUrlHttp: string, baseUrlWs: string) {
     return [ baseUrlWs + '/tracker/socket', baseUrlHttp + '/tracker/announce' ]
   }
@@ -224,10 +194,4 @@ export class VideoStreamingPlaylistModel extends Model {
     return this.type === other.type &&
       this.videoId === other.videoId
   }
-
-  removeTorrent (this: MStreamingPlaylistVideo, videoFile: MVideoFile) {
-    const torrentPath = getTorrentFilePath(this, videoFile)
-    return remove(torrentPath)
-      .catch(err => logger.warn('Cannot delete torrent %s.', torrentPath, { err }))
-  }
 }