diff options
Diffstat (limited to 'server/models/video/video-streaming-playlist.ts')
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index b147aca36..0333755c5 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -6,7 +6,7 @@ import * as Sequelize from 'sequelize' | |||
6 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' | 6 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' |
7 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' | 7 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' |
8 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 8 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
9 | import { CONSTRAINTS_FIELDS, STATIC_PATHS } from '../../initializers' | 9 | import { CONSTRAINTS_FIELDS, STATIC_PATHS, P2P_MEDIA_LOADER_PEER_VERSION } from '../../initializers' |
10 | import { VideoFileModel } from './video-file' | 10 | import { VideoFileModel } from './video-file' |
11 | import { join } from 'path' | 11 | import { join } from 'path' |
12 | import { sha1 } from '../../helpers/core-utils' | 12 | import { sha1 } from '../../helpers/core-utils' |
@@ -50,6 +50,10 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod | |||
50 | p2pMediaLoaderInfohashes: string[] | 50 | p2pMediaLoaderInfohashes: string[] |
51 | 51 | ||
52 | @AllowNull(false) | 52 | @AllowNull(false) |
53 | @Column | ||
54 | p2pMediaLoaderPeerVersion: number | ||
55 | |||
56 | @AllowNull(false) | ||
53 | @Is('VideoStreamingSegmentsSha256Url', value => throwIfNotValid(value, isActivityPubUrlValid, 'segments sha256 url')) | 57 | @Is('VideoStreamingSegmentsSha256Url', value => throwIfNotValid(value, isActivityPubUrlValid, 'segments sha256 url')) |
54 | @Column | 58 | @Column |
55 | segmentsSha256Url: string | 59 | segmentsSha256Url: string |
@@ -92,14 +96,26 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod | |||
92 | static buildP2PMediaLoaderInfoHashes (playlistUrl: string, videoFiles: VideoFileModel[]) { | 96 | static buildP2PMediaLoaderInfoHashes (playlistUrl: string, videoFiles: VideoFileModel[]) { |
93 | const hashes: string[] = [] | 97 | const hashes: string[] = [] |
94 | 98 | ||
95 | // https://github.com/Novage/p2p-media-loader/blob/master/p2p-media-loader-core/lib/p2p-media-manager.ts#L97 | 99 | // https://github.com/Novage/p2p-media-loader/blob/master/p2p-media-loader-core/lib/p2p-media-manager.ts#L115 |
96 | for (let i = 0; i < videoFiles.length; i++) { | 100 | for (let i = 0; i < videoFiles.length; i++) { |
97 | hashes.push(sha1(`1${playlistUrl}+V${i}`)) | 101 | hashes.push(sha1(`${P2P_MEDIA_LOADER_PEER_VERSION}${playlistUrl}+V${i}`)) |
98 | } | 102 | } |
99 | 103 | ||
100 | return hashes | 104 | return hashes |
101 | } | 105 | } |
102 | 106 | ||
107 | static listByIncorrectPeerVersion () { | ||
108 | const query = { | ||
109 | where: { | ||
110 | p2pMediaLoaderPeerVersion: { | ||
111 | [Sequelize.Op.ne]: P2P_MEDIA_LOADER_PEER_VERSION | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | return VideoStreamingPlaylistModel.findAll(query) | ||
117 | } | ||
118 | |||
103 | static loadWithVideo (id: number) { | 119 | static loadWithVideo (id: number) { |
104 | const options = { | 120 | const options = { |
105 | include: [ | 121 | include: [ |