-import * as Bluebird from 'bluebird'
import * as magnetUtil from 'magnet-uri'
import { join } from 'path'
import * as request from 'request'
import { getOrCreateActorAndServerAndModel } from './actor'
function fetchRemoteVideoPreview (video: VideoModel, reject: Function) {
- // FIXME: use url
const host = video.VideoChannel.Account.Actor.Server.host
const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
+ // We need to provide a callback, if no we could have an uncaught exception
return request.get(REMOTE_SCHEME.HTTP + '://' + host + path, err => {
if (err) reject(err)
})
}
async function fetchRemoteVideoDescription (video: VideoModel) {
- // FIXME: use url
const host = video.VideoChannel.Account.Actor.Server.host
const path = video.getDescriptionPath()
const options = {
return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width
})
- if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.url)
+ if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href)
- const parsed = magnetUtil.decode(magnet.url)
- if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.url)
+ const parsed = magnetUtil.decode(magnet.href)
+ if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.href)
const attribute = {
extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ],
throw new Error('Cannot find valid files for video %s ' + videoObject.url)
}
- const tasks: Bluebird<any>[] = videoFileAttributes.map(f => VideoFileModel.create(f, { transaction: t }))
+ const tasks = videoFileAttributes.map(f => VideoFileModel.create(f, { transaction: t }))
await Promise.all(tasks)
const tags = videoObject.tag.map(t => t.name)