mirror of
https://codeberg.org/teddit/teddit
synced 2024-12-22 16:39:24 +01:00
fix media downloading paths
This commit is contained in:
parent
bc93da2a31
commit
4edeaf45f9
2
app.js
2
app.js
@ -103,4 +103,4 @@ redis.on('error', (error) => {
|
||||
if(config.https_enabled) {
|
||||
https.listen(config.ssl_port, '::', () => console.log(`Teddit running on https://${config.domain}`))
|
||||
}
|
||||
http.listen(config.nonssl_port, '::', () => console.log(`Teddit running on http://${config.domain}:${config.nonssl_port}`))
|
||||
http.listen(config.nonssl_port, '::', () => console.log(`Teddit running on http://${config.domain}`))
|
||||
|
@ -49,8 +49,8 @@ module.exports = function(tools) {
|
||||
resolve('')
|
||||
} else {
|
||||
let filename = `${temp_url.pathname.substr(1).split('/')[0]}.${file_ext}`
|
||||
let path = `${__dirname}/../dist/vids/${filename}`
|
||||
let temp_path = `${__dirname}/../dist/vids/temp_${filename}`
|
||||
let path = `./dist/vids/${filename}`
|
||||
let temp_path = `./dist/vids/temp_${filename}`
|
||||
if(!fs.existsSync(path)) {
|
||||
const download = await downloadFile(cleanUrl(url))
|
||||
if(download.success === true) {
|
||||
@ -65,13 +65,13 @@ module.exports = function(tools) {
|
||||
}
|
||||
const download_audio = await downloadFile(cleanUrl(audio_url))
|
||||
if(download_audio.success === true) {
|
||||
let audio_path = `${__dirname}/../dist/vids/temp_audio_${filename}`
|
||||
let audio_path = `./dist/vids/temp_audio_${filename}`
|
||||
const write_audio = await writeToDisk(download_audio.data, audio_path)
|
||||
if(write_audio.success === true) {
|
||||
let processVideo = spawn('ffmpeg', ['-y', '-i', temp_path, '-i', audio_path, '-c', 'copy', path])
|
||||
processVideo.on('exit', (code) => {
|
||||
if(code === 0) {
|
||||
let final_url = `${protocol}${config.domain}/vids/${filename}`
|
||||
let final_url = `/vids/${filename}`
|
||||
let temp_files = [temp_path, audio_path]
|
||||
deleteFiles(temp_files, (error) => {
|
||||
if(error) {
|
||||
@ -97,7 +97,7 @@ module.exports = function(tools) {
|
||||
if(error) {
|
||||
console.log(`Error while renaming the temp video file: ${temp_path} => ${path}.`, error)
|
||||
} else {
|
||||
let final_url = `${protocol}${config.domain}/vids/${filename}`
|
||||
let final_url = `/vids/${filename}`
|
||||
resolve(final_url)
|
||||
}
|
||||
})
|
||||
@ -111,7 +111,7 @@ module.exports = function(tools) {
|
||||
resolve('')
|
||||
}
|
||||
} else {
|
||||
resolve(`${protocol}${config.domain}/vids/${filename}`)
|
||||
resolve(`/vids/${filename}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -126,13 +126,13 @@ module.exports = function(tools) {
|
||||
}
|
||||
filename = `${file_prefix}w:${temp_url.searchParams.get('width')}_${temp_url.pathname.split('/').slice(-1)}`
|
||||
}
|
||||
path = `${__dirname}/../dist/pics/${filename}`
|
||||
path = `./dist/pics/${filename}`
|
||||
if(!fs.existsSync(path)) {
|
||||
const download = await downloadFile(cleanUrl(url))
|
||||
if(download.success === true) {
|
||||
const write = await writeToDisk(download.data, path)
|
||||
if(write.success === true) {
|
||||
let final_url = `${protocol}${config.domain}/pics/${filename}`
|
||||
let final_url = `/pics/${filename}`
|
||||
resolve(final_url)
|
||||
} else {
|
||||
console.log(`Error while writing image file.`, write)
|
||||
@ -143,7 +143,7 @@ module.exports = function(tools) {
|
||||
resolve('')
|
||||
}
|
||||
} else {
|
||||
resolve(`${protocol}${config.domain}/pics/${filename}`)
|
||||
resolve(`/pics/${filename}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user