mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add tmp and redundancy directories
This commit is contained in:
@@ -178,9 +178,7 @@ async function fetchAvatarIfExists (actorJSON: ActivityPubActor) {
|
||||
const extension = IMAGE_MIMETYPE_EXT[actorJSON.icon.mediaType]
|
||||
|
||||
const avatarName = uuidv4() + extension
|
||||
const destPath = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)
|
||||
|
||||
await downloadImage(actorJSON.icon.url, destPath, AVATARS_SIZE)
|
||||
await downloadImage(actorJSON.icon.url, CONFIG.STORAGE.AVATARS_DIR, avatarName, AVATARS_SIZE)
|
||||
|
||||
return avatarName
|
||||
}
|
||||
|
||||
@@ -95,9 +95,8 @@ function fetchRemoteVideoStaticFile (video: VideoModel, path: string, reject: Fu
|
||||
|
||||
function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject) {
|
||||
const thumbnailName = video.getThumbnailName()
|
||||
const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, thumbnailName)
|
||||
|
||||
return downloadImage(icon.url, thumbnailPath, THUMBNAILS_SIZE)
|
||||
return downloadImage(icon.url, CONFIG.STORAGE.THUMBNAILS_DIR, thumbnailName, THUMBNAILS_SIZE)
|
||||
}
|
||||
|
||||
function getOrCreateVideoChannelFromVideoObject (videoObject: VideoTorrentObject) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } fro
|
||||
import { extname, join } from 'path'
|
||||
import { VideoFileModel } from '../../../models/video/video-file'
|
||||
import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers'
|
||||
import { doRequestAndSaveToFile, downloadImage } from '../../../helpers/requests'
|
||||
import { downloadImage } from '../../../helpers/requests'
|
||||
import { VideoState } from '../../../../shared'
|
||||
import { JobQueue } from '../index'
|
||||
import { federateVideoIfNeeded } from '../../activitypub'
|
||||
@@ -109,6 +109,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
|
||||
let tempVideoPath: string
|
||||
let videoDestFile: string
|
||||
let videoFile: VideoFileModel
|
||||
|
||||
try {
|
||||
// Download video from youtubeDL
|
||||
tempVideoPath = await downloader()
|
||||
@@ -144,8 +145,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
|
||||
// Process thumbnail
|
||||
if (options.downloadThumbnail) {
|
||||
if (options.thumbnailUrl) {
|
||||
const destThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName())
|
||||
await downloadImage(options.thumbnailUrl, destThumbnailPath, THUMBNAILS_SIZE)
|
||||
await downloadImage(options.thumbnailUrl, CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName(), THUMBNAILS_SIZE)
|
||||
} else {
|
||||
await videoImport.Video.createThumbnail(videoFile)
|
||||
}
|
||||
@@ -156,8 +156,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
|
||||
// Process preview
|
||||
if (options.downloadPreview) {
|
||||
if (options.thumbnailUrl) {
|
||||
const destPreviewPath = join(CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName())
|
||||
await downloadImage(options.thumbnailUrl, destPreviewPath, PREVIEWS_SIZE)
|
||||
await downloadImage(options.thumbnailUrl, CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName(), PREVIEWS_SIZE)
|
||||
} else {
|
||||
await videoImport.Video.createPreview(videoFile)
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ async function processVideosViews () {
|
||||
for (const videoId of videoIds) {
|
||||
try {
|
||||
const views = await Redis.Instance.getVideoViews(videoId, hour)
|
||||
if (isNaN(views)) {
|
||||
logger.error('Cannot process videos views of video %d in hour %d: views number is NaN (%s).', videoId, hour, views)
|
||||
} else {
|
||||
if (views) {
|
||||
logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour)
|
||||
|
||||
try {
|
||||
|
||||
@@ -121,7 +121,14 @@ class Redis {
|
||||
const key = this.generateVideoViewKey(videoId, hour)
|
||||
|
||||
const valueString = await this.getValue(key)
|
||||
return parseInt(valueString, 10)
|
||||
const valueInt = parseInt(valueString, 10)
|
||||
|
||||
if (isNaN(valueInt)) {
|
||||
logger.error('Cannot get videos views of video %d in hour %d: views number is NaN (%s).', videoId, hour, valueString)
|
||||
return undefined
|
||||
}
|
||||
|
||||
return valueInt
|
||||
}
|
||||
|
||||
async getVideosIdViewed (hour: number) {
|
||||
|
||||
Reference in New Issue
Block a user