mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Prefer web videos in favour of webtorrent
This commit is contained in:
parent
c3030e944a
commit
784e2ad5c3
102 changed files with 579 additions and 570 deletions
|
@ -9,12 +9,12 @@ function generateHLSObjectBaseStorageKey (playlist: MStreamingPlaylistVideo) {
|
|||
return join(playlist.getStringType(), playlist.Video.uuid)
|
||||
}
|
||||
|
||||
function generateWebTorrentObjectStorageKey (filename: string) {
|
||||
function generateWebVideoObjectStorageKey (filename: string) {
|
||||
return filename
|
||||
}
|
||||
|
||||
export {
|
||||
generateHLSObjectStorageKey,
|
||||
generateHLSObjectBaseStorageKey,
|
||||
generateWebTorrentObjectStorageKey
|
||||
generateWebVideoObjectStorageKey
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ import { GetObjectCommand } from '@aws-sdk/client-s3'
|
|||
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { MStreamingPlaylistVideo, MVideoFile } from '@server/types/models'
|
||||
import { generateHLSObjectStorageKey, generateWebTorrentObjectStorageKey } from './keys'
|
||||
import { generateHLSObjectStorageKey, generateWebVideoObjectStorageKey } from './keys'
|
||||
import { buildKey, getClient } from './shared'
|
||||
import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from './urls'
|
||||
import { getHLSPublicFileUrl, getWebVideoPublicFileUrl } from './urls'
|
||||
|
||||
export async function generateWebVideoPresignedUrl (options: {
|
||||
file: MVideoFile
|
||||
|
@ -12,7 +12,7 @@ export async function generateWebVideoPresignedUrl (options: {
|
|||
}) {
|
||||
const { file, downloadFilename } = options
|
||||
|
||||
const key = generateWebTorrentObjectStorageKey(file.filename)
|
||||
const key = generateWebVideoObjectStorageKey(file.filename)
|
||||
|
||||
const command = new GetObjectCommand({
|
||||
Bucket: CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME,
|
||||
|
@ -22,7 +22,7 @@ export async function generateWebVideoPresignedUrl (options: {
|
|||
|
||||
const url = await getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 })
|
||||
|
||||
return getWebTorrentPublicFileUrl(url)
|
||||
return getWebVideoPublicFileUrl(url)
|
||||
}
|
||||
|
||||
export async function generateHLSFilePresignedUrl (options: {
|
||||
|
|
|
@ -7,19 +7,19 @@ import { StreamReplacer } from '@server/helpers/stream-replacer'
|
|||
import { MStreamingPlaylist, MVideo } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { injectQueryToPlaylistUrls } from '../hls'
|
||||
import { getHLSFileReadStream, getWebTorrentFileReadStream } from './videos'
|
||||
import { getHLSFileReadStream, getWebVideoFileReadStream } from './videos'
|
||||
|
||||
export async function proxifyWebTorrentFile (options: {
|
||||
export async function proxifyWebVideoFile (options: {
|
||||
req: express.Request
|
||||
res: express.Response
|
||||
filename: string
|
||||
}) {
|
||||
const { req, res, filename } = options
|
||||
|
||||
logger.debug('Proxifying WebTorrent file %s from object storage.', filename)
|
||||
logger.debug('Proxifying Web Video file %s from object storage.', filename)
|
||||
|
||||
try {
|
||||
const { response: s3Response, stream } = await getWebTorrentFileReadStream({
|
||||
const { response: s3Response, stream } = await getWebVideoFileReadStream({
|
||||
filename,
|
||||
rangeHeader: req.header('range')
|
||||
})
|
||||
|
|
|
@ -9,7 +9,7 @@ function getInternalUrl (config: BucketInfo, keyWithoutPrefix: string) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function getWebTorrentPublicFileUrl (fileUrl: string) {
|
||||
function getWebVideoPublicFileUrl (fileUrl: string) {
|
||||
const baseUrl = CONFIG.OBJECT_STORAGE.VIDEOS.BASE_URL
|
||||
if (!baseUrl) return fileUrl
|
||||
|
||||
|
@ -29,7 +29,7 @@ function getHLSPrivateFileUrl (video: MVideoUUID, filename: string) {
|
|||
return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS + video.uuid + `/${filename}`
|
||||
}
|
||||
|
||||
function getWebTorrentPrivateFileUrl (filename: string) {
|
||||
function getWebVideoPrivateFileUrl (filename: string) {
|
||||
return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + filename
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,11 @@ function getWebTorrentPrivateFileUrl (filename: string) {
|
|||
export {
|
||||
getInternalUrl,
|
||||
|
||||
getWebTorrentPublicFileUrl,
|
||||
getWebVideoPublicFileUrl,
|
||||
getHLSPublicFileUrl,
|
||||
|
||||
getHLSPrivateFileUrl,
|
||||
getWebTorrentPrivateFileUrl,
|
||||
getWebVideoPrivateFileUrl,
|
||||
|
||||
replaceByBaseUrl
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { CONFIG } from '@server/initializers/config'
|
|||
import { MStreamingPlaylistVideo, MVideo, MVideoFile } from '@server/types/models'
|
||||
import { getHLSDirectory } from '../paths'
|
||||
import { VideoPathManager } from '../video-path-manager'
|
||||
import { generateHLSObjectBaseStorageKey, generateHLSObjectStorageKey, generateWebTorrentObjectStorageKey } from './keys'
|
||||
import { generateHLSObjectBaseStorageKey, generateHLSObjectStorageKey, generateWebVideoObjectStorageKey } from './keys'
|
||||
import {
|
||||
createObjectReadStream,
|
||||
listKeysOfPrefix,
|
||||
|
@ -55,10 +55,10 @@ function storeHLSFileFromContent (playlist: MStreamingPlaylistVideo, path: strin
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function storeWebTorrentFile (video: MVideo, file: MVideoFile) {
|
||||
function storeWebVideoFile (video: MVideo, file: MVideoFile) {
|
||||
return storeObject({
|
||||
inputPath: VideoPathManager.Instance.getFSVideoFileOutputPath(video, file),
|
||||
objectStorageKey: generateWebTorrentObjectStorageKey(file.filename),
|
||||
objectStorageKey: generateWebVideoObjectStorageKey(file.filename),
|
||||
bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS,
|
||||
isPrivate: video.hasPrivateStaticPath()
|
||||
})
|
||||
|
@ -66,9 +66,9 @@ function storeWebTorrentFile (video: MVideo, file: MVideoFile) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function updateWebTorrentFileACL (video: MVideo, file: MVideoFile) {
|
||||
async function updateWebVideoFileACL (video: MVideo, file: MVideoFile) {
|
||||
await updateObjectACL({
|
||||
objectStorageKey: generateWebTorrentObjectStorageKey(file.filename),
|
||||
objectStorageKey: generateWebVideoObjectStorageKey(file.filename),
|
||||
bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS,
|
||||
isPrivate: video.hasPrivateStaticPath()
|
||||
})
|
||||
|
@ -102,8 +102,8 @@ function removeHLSFileObjectStorageByFullKey (key: string) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function removeWebTorrentObjectStorage (videoFile: MVideoFile) {
|
||||
return removeObject(generateWebTorrentObjectStorageKey(videoFile.filename), CONFIG.OBJECT_STORAGE.VIDEOS)
|
||||
function removeWebVideoObjectStorage (videoFile: MVideoFile) {
|
||||
return removeObject(generateWebVideoObjectStorageKey(videoFile.filename), CONFIG.OBJECT_STORAGE.VIDEOS)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -122,10 +122,10 @@ async function makeHLSFileAvailable (playlist: MStreamingPlaylistVideo, filename
|
|||
return destination
|
||||
}
|
||||
|
||||
async function makeWebTorrentFileAvailable (filename: string, destination: string) {
|
||||
const key = generateWebTorrentObjectStorageKey(filename)
|
||||
async function makeWebVideoFileAvailable (filename: string, destination: string) {
|
||||
const key = generateWebVideoObjectStorageKey(filename)
|
||||
|
||||
logger.info('Fetching WebTorrent file %s from object storage to %s.', key, destination, lTags())
|
||||
logger.info('Fetching Web Video file %s from object storage to %s.', key, destination, lTags())
|
||||
|
||||
await makeAvailable({
|
||||
key,
|
||||
|
@ -138,13 +138,13 @@ async function makeWebTorrentFileAvailable (filename: string, destination: strin
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function getWebTorrentFileReadStream (options: {
|
||||
function getWebVideoFileReadStream (options: {
|
||||
filename: string
|
||||
rangeHeader: string
|
||||
}) {
|
||||
const { filename, rangeHeader } = options
|
||||
|
||||
const key = generateWebTorrentObjectStorageKey(filename)
|
||||
const key = generateWebVideoObjectStorageKey(filename)
|
||||
|
||||
return createObjectReadStream({
|
||||
key,
|
||||
|
@ -174,12 +174,12 @@ function getHLSFileReadStream (options: {
|
|||
export {
|
||||
listHLSFileKeysOf,
|
||||
|
||||
storeWebTorrentFile,
|
||||
storeWebVideoFile,
|
||||
storeHLSFileFromFilename,
|
||||
storeHLSFileFromPath,
|
||||
storeHLSFileFromContent,
|
||||
|
||||
updateWebTorrentFileACL,
|
||||
updateWebVideoFileACL,
|
||||
updateHLSFilesACL,
|
||||
|
||||
removeHLSObjectStorage,
|
||||
|
@ -187,11 +187,11 @@ export {
|
|||
removeHLSFileObjectStorageByPath,
|
||||
removeHLSFileObjectStorageByFullKey,
|
||||
|
||||
removeWebTorrentObjectStorage,
|
||||
removeWebVideoObjectStorage,
|
||||
|
||||
makeWebTorrentFileAvailable,
|
||||
makeWebVideoFileAvailable,
|
||||
makeHLSFileAvailable,
|
||||
|
||||
getWebTorrentFileReadStream,
|
||||
getWebVideoFileReadStream,
|
||||
getHLSFileReadStream
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue