1 import * as Bluebird from 'bluebird'
2 import * as sequelize from 'sequelize'
3 import * as magnetUtil from 'magnet-uri'
4 import * as request from 'request'
6 ActivityPlaylistSegmentHashesObject,
7 ActivityPlaylistUrlObject,
9 ActivityVideoUrlObject,
11 } from '../../../shared/index'
12 import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
13 import { VideoPrivacy } from '../../../shared/models/videos'
14 import { sanitizeAndCheckVideoTorrentObject } from '../../helpers/custom-validators/activitypub/videos'
15 import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
16 import { resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils'
17 import { logger } from '../../helpers/logger'
18 import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
22 P2P_MEDIA_LOADER_PEER_VERSION,
26 } from '../../initializers/constants'
27 import { ActorModel } from '../../models/activitypub/actor'
28 import { TagModel } from '../../models/video/tag'
29 import { VideoModel } from '../../models/video/video'
30 import { VideoChannelModel } from '../../models/video/video-channel'
31 import { VideoFileModel } from '../../models/video/video-file'
32 import { getOrCreateActorAndServerAndModel } from './actor'
33 import { addVideoComments } from './video-comments'
34 import { crawlCollectionPage } from './crawl'
35 import { sendCreateVideo, sendUpdateVideo } from './send'
36 import { isArray } from '../../helpers/custom-validators/misc'
37 import { VideoCaptionModel } from '../../models/video/video-caption'
38 import { JobQueue } from '../job-queue'
39 import { ActivitypubHttpFetcherPayload } from '../job-queue/handlers/activitypub-http-fetcher'
40 import { createRates } from './video-rates'
41 import { addVideoShares, shareVideoByServerAndChannel } from './share'
42 import { AccountModel } from '../../models/account/account'
43 import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video'
44 import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
45 import { Notifier } from '../notifier'
46 import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
47 import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
48 import { AccountVideoRateModel } from '../../models/account/account-video-rate'
49 import { VideoShareModel } from '../../models/video/video-share'
50 import { VideoCommentModel } from '../../models/video/video-comment'
51 import { sequelizeTypescript } from '../../initializers/database'
52 import { createPlaceholderThumbnail, createVideoMiniatureFromUrl } from '../thumbnail'
53 import { ThumbnailModel } from '../../models/video/thumbnail'
54 import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type'
55 import { join } from 'path'
56 import { FilteredModelAttributes } from '../../typings/sequelize'
57 import { Hooks } from '../plugins/hooks'
58 import { autoBlacklistVideoIfNeeded } from '../video-blacklist'
60 async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
61 // If the video is not private and is published, we federate it
62 if (video.privacy !== VideoPrivacy.PRIVATE && video.state === VideoState.PUBLISHED) {
63 // Fetch more attributes that we will need to serialize in AP object
64 if (isArray(video.VideoCaptions) === false) {
65 video.VideoCaptions = await video.$get('VideoCaptions', {
66 attributes: [ 'language' ],
68 }) as VideoCaptionModel[]
72 // Now we'll add the video's meta data to our followers
73 await sendCreateVideo(video, transaction)
74 await shareVideoByServerAndChannel(video, transaction)
76 await sendUpdateVideo(video, transaction)
81 async function fetchRemoteVideo (videoUrl: string): Promise<{ response: request.RequestResponse, videoObject: VideoTorrentObject }> {
89 logger.info('Fetching remote video %s.', videoUrl)
91 const { response, body } = await doRequest(options)
93 if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) {
94 logger.debug('Remote video JSON is not valid.', { body })
95 return { response, videoObject: undefined }
98 return { response, videoObject: body }
101 async function fetchRemoteVideoDescription (video: VideoModel) {
102 const host = video.VideoChannel.Account.Actor.Server.host
103 const path = video.getDescriptionAPIPath()
105 uri: REMOTE_SCHEME.HTTP + '://' + host + path,
109 const { body } = await doRequest(options)
110 return body.description ? body.description : ''
113 function fetchRemoteVideoStaticFile (video: VideoModel, path: string, destPath: string) {
114 const url = buildRemoteBaseUrl(video, path)
116 // We need to provide a callback, if no we could have an uncaught exception
117 return doRequestAndSaveToFile({ uri: url }, destPath)
120 function buildRemoteBaseUrl (video: VideoModel, path: string) {
121 const host = video.VideoChannel.Account.Actor.Server.host
123 return REMOTE_SCHEME.HTTP + '://' + host + path
126 function getOrCreateVideoChannelFromVideoObject (videoObject: VideoTorrentObject) {
127 const channel = videoObject.attributedTo.find(a => a.type === 'Group')
128 if (!channel) throw new Error('Cannot find associated video channel to video ' + videoObject.url)
130 if (checkUrlsSameHost(channel.id, videoObject.id) !== true) {
131 throw new Error(`Video channel url ${channel.id} does not have the same host than video object id ${videoObject.id}`)
134 return getOrCreateActorAndServerAndModel(channel.id, 'all')
143 refreshVideo?: boolean
145 async function syncVideoExternalAttributes (video: VideoModel, fetchedVideo: VideoTorrentObject, syncParam: SyncParam) {
146 logger.info('Adding likes/dislikes/shares/comments of video %s.', video.uuid)
148 const jobPayloads: ActivitypubHttpFetcherPayload[] = []
150 if (syncParam.likes === true) {
151 const handler = items => createRates(items, video, 'like')
152 const cleaner = crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, 'like' as 'like', crawlStartDate)
154 await crawlCollectionPage<string>(fetchedVideo.likes, handler, cleaner)
155 .catch(err => logger.error('Cannot add likes of video %s.', video.uuid, { err }))
157 jobPayloads.push({ uri: fetchedVideo.likes, videoId: video.id, type: 'video-likes' as 'video-likes' })
160 if (syncParam.dislikes === true) {
161 const handler = items => createRates(items, video, 'dislike')
162 const cleaner = crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, 'dislike' as 'dislike', crawlStartDate)
164 await crawlCollectionPage<string>(fetchedVideo.dislikes, handler, cleaner)
165 .catch(err => logger.error('Cannot add dislikes of video %s.', video.uuid, { err }))
167 jobPayloads.push({ uri: fetchedVideo.dislikes, videoId: video.id, type: 'video-dislikes' as 'video-dislikes' })
170 if (syncParam.shares === true) {
171 const handler = items => addVideoShares(items, video)
172 const cleaner = crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate)
174 await crawlCollectionPage<string>(fetchedVideo.shares, handler, cleaner)
175 .catch(err => logger.error('Cannot add shares of video %s.', video.uuid, { err }))
177 jobPayloads.push({ uri: fetchedVideo.shares, videoId: video.id, type: 'video-shares' as 'video-shares' })
180 if (syncParam.comments === true) {
181 const handler = items => addVideoComments(items, video)
182 const cleaner = crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate)
184 await crawlCollectionPage<string>(fetchedVideo.comments, handler, cleaner)
185 .catch(err => logger.error('Cannot add comments of video %s.', video.uuid, { err }))
187 jobPayloads.push({ uri: fetchedVideo.comments, videoId: video.id, type: 'video-comments' as 'video-comments' })
190 await Bluebird.map(jobPayloads, payload => JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }))
193 async function getOrCreateVideoAndAccountAndChannel (options: {
194 videoObject: { id: string } | string,
195 syncParam?: SyncParam,
196 fetchType?: VideoFetchByUrlType,
197 allowRefresh?: boolean // true by default
200 const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }
201 const fetchType = options.fetchType || 'all'
202 const allowRefresh = options.allowRefresh !== false
205 const videoUrl = getAPId(options.videoObject)
207 let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
208 if (videoFromDatabase) {
209 if (videoFromDatabase.isOutdated() && allowRefresh === true) {
210 const refreshOptions = {
211 video: videoFromDatabase,
212 fetchedType: fetchType,
216 if (syncParam.refreshVideo === true) videoFromDatabase = await refreshVideoIfNeeded(refreshOptions)
217 else await JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: videoFromDatabase.url } })
220 return { video: videoFromDatabase, created: false }
223 const { videoObject: fetchedVideo } = await fetchRemoteVideo(videoUrl)
224 if (!fetchedVideo) throw new Error('Cannot fetch remote video with url: ' + videoUrl)
226 const channelActor = await getOrCreateVideoChannelFromVideoObject(fetchedVideo)
227 const { autoBlacklisted, videoCreated } = await retryTransactionWrapper(createVideo, fetchedVideo, channelActor, syncParam.thumbnail)
229 await syncVideoExternalAttributes(videoCreated, fetchedVideo, syncParam)
231 return { video: videoCreated, created: true, autoBlacklisted }
234 async function updateVideoFromAP (options: {
236 videoObject: VideoTorrentObject,
237 account: AccountModel,
238 channel: VideoChannelModel,
239 overrideTo?: string[]
241 const { video, videoObject, account, channel, overrideTo } = options
243 logger.debug('Updating remote video "%s".', options.videoObject.uuid)
245 let videoFieldsSave: any
246 const wasPrivateVideo = video.privacy === VideoPrivacy.PRIVATE
247 const wasUnlistedVideo = video.privacy === VideoPrivacy.UNLISTED
250 let thumbnailModel: ThumbnailModel
253 thumbnailModel = await createVideoMiniatureFromUrl(videoObject.icon.url, video, ThumbnailType.MINIATURE)
255 logger.warn('Cannot generate thumbnail of %s.', videoObject.id, { err })
258 await sequelizeTypescript.transaction(async t => {
259 const sequelizeOptions = { transaction: t }
261 videoFieldsSave = video.toJSON()
263 // Check actor has the right to update the video
264 const videoChannel = video.VideoChannel
265 if (videoChannel.Account.id !== account.id) {
266 throw new Error('Account ' + account.Actor.url + ' does not own video channel ' + videoChannel.Actor.url)
269 const to = overrideTo ? overrideTo : videoObject.to
270 const videoData = await videoActivityObjectToDBAttributes(channel, videoObject, to)
271 video.name = videoData.name
272 video.uuid = videoData.uuid
273 video.url = videoData.url
274 video.category = videoData.category
275 video.licence = videoData.licence
276 video.language = videoData.language
277 video.description = videoData.description
278 video.support = videoData.support
279 video.nsfw = videoData.nsfw
280 video.commentsEnabled = videoData.commentsEnabled
281 video.downloadEnabled = videoData.downloadEnabled
282 video.waitTranscoding = videoData.waitTranscoding
283 video.state = videoData.state
284 video.duration = videoData.duration
285 video.createdAt = videoData.createdAt
286 video.publishedAt = videoData.publishedAt
287 video.originallyPublishedAt = videoData.originallyPublishedAt
288 video.privacy = videoData.privacy
289 video.channelId = videoData.channelId
290 video.views = videoData.views
292 await video.save(sequelizeOptions)
294 if (thumbnailModel) await video.addAndSaveThumbnail(thumbnailModel, t)
296 // FIXME: use icon URL instead
297 const previewUrl = buildRemoteBaseUrl(video, join(STATIC_PATHS.PREVIEWS, video.getPreview().filename))
298 const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)
299 await video.addAndSaveThumbnail(previewModel, t)
302 const videoFileAttributes = videoFileActivityUrlToDBAttributes(video, videoObject)
303 const newVideoFiles = videoFileAttributes.map(a => new VideoFileModel(a))
305 // Remove video files that do not exist anymore
306 const destroyTasks = video.VideoFiles
307 .filter(f => !newVideoFiles.find(newFile => newFile.hasSameUniqueKeysThan(f)))
308 .map(f => f.destroy(sequelizeOptions))
309 await Promise.all(destroyTasks)
311 // Update or add other one
312 const upsertTasks = videoFileAttributes.map(a => {
313 return VideoFileModel.upsert<VideoFileModel>(a, { returning: true, transaction: t })
314 .then(([ file ]) => file)
317 video.VideoFiles = await Promise.all(upsertTasks)
321 const streamingPlaylistAttributes = streamingPlaylistActivityUrlToDBAttributes(video, videoObject, video.VideoFiles)
322 const newStreamingPlaylists = streamingPlaylistAttributes.map(a => new VideoStreamingPlaylistModel(a))
324 // Remove video files that do not exist anymore
325 const destroyTasks = video.VideoStreamingPlaylists
326 .filter(f => !newStreamingPlaylists.find(newPlaylist => newPlaylist.hasSameUniqueKeysThan(f)))
327 .map(f => f.destroy(sequelizeOptions))
328 await Promise.all(destroyTasks)
330 // Update or add other one
331 const upsertTasks = streamingPlaylistAttributes.map(a => {
332 return VideoStreamingPlaylistModel.upsert<VideoStreamingPlaylistModel>(a, { returning: true, transaction: t })
333 .then(([ streamingPlaylist ]) => streamingPlaylist)
336 video.VideoStreamingPlaylists = await Promise.all(upsertTasks)
341 const tags = videoObject.tag.map(tag => tag.name)
342 const tagInstances = await TagModel.findOrCreateTags(tags, t)
343 await video.$set('Tags', tagInstances, sequelizeOptions)
348 await VideoCaptionModel.deleteAllCaptionsOfRemoteVideo(video.id, t)
350 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
351 return VideoCaptionModel.insertOrReplaceLanguage(video.id, c.identifier, t)
353 video.VideoCaptions = await Promise.all(videoCaptionsPromises)
357 const autoBlacklisted = await autoBlacklistVideoIfNeeded({
362 transaction: undefined
365 if (autoBlacklisted) Notifier.Instance.notifyOnVideoAutoBlacklist(video)
366 else if (!wasPrivateVideo || wasUnlistedVideo) Notifier.Instance.notifyOnNewVideo(video) // Notify our users?
368 logger.info('Remote video with uuid %s updated', videoObject.uuid)
370 if (video !== undefined && videoFieldsSave !== undefined) {
371 resetSequelizeInstance(video, videoFieldsSave)
374 // This is just a debug because we will retry the insert
375 logger.debug('Cannot update the remote video.', { err })
380 async function refreshVideoIfNeeded (options: {
382 fetchedType: VideoFetchByUrlType,
384 }): Promise<VideoModel> {
385 if (!options.video.isOutdated()) return options.video
387 // We need more attributes if the argument video was fetched with not enough joints
388 const video = options.fetchedType === 'all'
390 : await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
393 const { response, videoObject } = await fetchRemoteVideo(video.url)
394 if (response.statusCode === 404) {
395 logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url)
397 // Video does not exist anymore
398 await video.destroy()
402 if (videoObject === undefined) {
403 logger.warn('Cannot refresh remote video %s: invalid body.', video.url)
405 await video.setAsRefreshed()
409 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
410 const account = await AccountModel.load(channelActor.VideoChannel.accountId)
412 const updateOptions = {
416 channel: channelActor.VideoChannel
418 await retryTransactionWrapper(updateVideoFromAP, updateOptions)
419 await syncVideoExternalAttributes(video, videoObject, options.syncParam)
423 logger.warn('Cannot refresh video %s.', options.video.url, { err })
425 // Don't refresh in loop
426 await video.setAsRefreshed()
433 refreshVideoIfNeeded,
434 federateVideoIfNeeded,
436 getOrCreateVideoAndAccountAndChannel,
437 fetchRemoteVideoStaticFile,
438 fetchRemoteVideoDescription,
439 getOrCreateVideoChannelFromVideoObject
442 // ---------------------------------------------------------------------------
444 function isAPVideoUrlObject (url: ActivityUrlObject): url is ActivityVideoUrlObject {
445 const mimeTypes = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
447 const urlMediaType = url.mediaType || url.mimeType
448 return mimeTypes.indexOf(urlMediaType) !== -1 && urlMediaType.startsWith('video/')
451 function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject {
452 const urlMediaType = url.mediaType || url.mimeType
454 return urlMediaType === 'application/x-mpegURL'
457 function isAPPlaylistSegmentHashesUrlObject (tag: any): tag is ActivityPlaylistSegmentHashesObject {
458 const urlMediaType = tag.mediaType || tag.mimeType
460 return tag.name === 'sha256' && tag.type === 'Link' && urlMediaType === 'application/json'
463 async function createVideo (videoObject: VideoTorrentObject, channelActor: ActorModel, waitThumbnail = false) {
464 logger.debug('Adding remote video %s.', videoObject.id)
466 const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to)
467 const video = VideoModel.build(videoData)
469 const promiseThumbnail = createVideoMiniatureFromUrl(videoObject.icon.url, video, ThumbnailType.MINIATURE)
471 let thumbnailModel: ThumbnailModel
472 if (waitThumbnail === true) {
473 thumbnailModel = await promiseThumbnail
476 const { autoBlacklisted, videoCreated } = await sequelizeTypescript.transaction(async t => {
477 const sequelizeOptions = { transaction: t }
479 const videoCreated = await video.save(sequelizeOptions)
480 videoCreated.VideoChannel = channelActor.VideoChannel
482 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t)
484 // FIXME: use icon URL instead
485 const previewUrl = buildRemoteBaseUrl(videoCreated, join(STATIC_PATHS.PREVIEWS, video.generatePreviewName()))
486 const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)
487 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(previewModel, t)
490 const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoCreated, videoObject)
491 if (videoFileAttributes.length === 0) {
492 throw new Error('Cannot find valid files for video %s ' + videoObject.url)
495 const videoFilePromises = videoFileAttributes.map(f => VideoFileModel.create(f, { transaction: t }))
496 const videoFiles = await Promise.all(videoFilePromises)
498 const videoStreamingPlaylists = streamingPlaylistActivityUrlToDBAttributes(videoCreated, videoObject, videoFiles)
499 const playlistPromises = videoStreamingPlaylists.map(p => VideoStreamingPlaylistModel.create(p, { transaction: t }))
500 await Promise.all(playlistPromises)
503 const tags = videoObject.tag
504 .filter(t => t.type === 'Hashtag')
506 const tagInstances = await TagModel.findOrCreateTags(tags, t)
507 await videoCreated.$set('Tags', tagInstances, sequelizeOptions)
510 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
511 return VideoCaptionModel.insertOrReplaceLanguage(videoCreated.id, c.identifier, t)
513 await Promise.all(videoCaptionsPromises)
515 const autoBlacklisted = await autoBlacklistVideoIfNeeded({
523 logger.info('Remote video with uuid %s inserted.', videoObject.uuid)
525 return { autoBlacklisted, videoCreated }
528 if (waitThumbnail === false) {
529 promiseThumbnail.then(thumbnailModel => {
530 thumbnailModel = videoCreated.id
532 return thumbnailModel.save()
536 return { autoBlacklisted, videoCreated }
539 async function videoActivityObjectToDBAttributes (
540 videoChannel: VideoChannelModel,
541 videoObject: VideoTorrentObject,
544 const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED
545 const duration = videoObject.duration.replace(/[^\d]+/, '')
547 let language: string | undefined
548 if (videoObject.language) {
549 language = videoObject.language.identifier
552 let category: number | undefined
553 if (videoObject.category) {
554 category = parseInt(videoObject.category.identifier, 10)
557 let licence: number | undefined
558 if (videoObject.licence) {
559 licence = parseInt(videoObject.licence.identifier, 10)
562 const description = videoObject.content || null
563 const support = videoObject.support || null
566 name: videoObject.name,
567 uuid: videoObject.uuid,
574 nsfw: videoObject.sensitive,
575 commentsEnabled: videoObject.commentsEnabled,
576 downloadEnabled: videoObject.downloadEnabled,
577 waitTranscoding: videoObject.waitTranscoding,
578 state: videoObject.state,
579 channelId: videoChannel.id,
580 duration: parseInt(duration, 10),
581 createdAt: new Date(videoObject.published),
582 publishedAt: new Date(videoObject.published),
583 originallyPublishedAt: videoObject.originallyPublishedAt ? new Date(videoObject.originallyPublishedAt) : null,
584 // FIXME: updatedAt does not seems to be considered by Sequelize
585 updatedAt: new Date(videoObject.updated),
586 views: videoObject.views,
594 function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: VideoTorrentObject) {
595 const fileUrls = videoObject.url.filter(u => isAPVideoUrlObject(u)) as ActivityVideoUrlObject[]
597 if (fileUrls.length === 0) {
598 throw new Error('Cannot find video files for ' + video.url)
601 const attributes: FilteredModelAttributes<VideoFileModel>[] = []
602 for (const fileUrl of fileUrls) {
603 // Fetch associated magnet uri
604 const magnet = videoObject.url.find(u => {
605 const mediaType = u.mediaType || u.mimeType
606 return mediaType === 'application/x-bittorrent;x-scheme-handler/magnet' && (u as any).height === fileUrl.height
609 if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href)
611 const parsed = magnetUtil.decode(magnet.href)
612 if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) {
613 throw new Error('Cannot parse magnet URI ' + magnet.href)
616 const mediaType = fileUrl.mediaType || fileUrl.mimeType
618 extname: MIMETYPES.VIDEO.MIMETYPE_EXT[ mediaType ],
619 infoHash: parsed.infoHash,
620 resolution: fileUrl.height,
623 fps: fileUrl.fps || -1
626 attributes.push(attribute)
632 function streamingPlaylistActivityUrlToDBAttributes (video: VideoModel, videoObject: VideoTorrentObject, videoFiles: VideoFileModel[]) {
633 const playlistUrls = videoObject.url.filter(u => isAPStreamingPlaylistUrlObject(u)) as ActivityPlaylistUrlObject[]
634 if (playlistUrls.length === 0) return []
636 const attributes: FilteredModelAttributes<VideoStreamingPlaylistModel>[] = []
637 for (const playlistUrlObject of playlistUrls) {
638 const segmentsSha256UrlObject = playlistUrlObject.tag
640 return isAPPlaylistSegmentHashesUrlObject(t)
641 }) as ActivityPlaylistSegmentHashesObject
642 if (!segmentsSha256UrlObject) {
643 logger.warn('No segment sha256 URL found in AP playlist object.', { playlistUrl: playlistUrlObject })
648 type: VideoStreamingPlaylistType.HLS,
649 playlistUrl: playlistUrlObject.href,
650 segmentsSha256Url: segmentsSha256UrlObject.href,
651 p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrlObject.href, videoFiles),
652 p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION,
656 attributes.push(attribute)