Added filepath component length limit with truncator. Fixed double extension dot when copying original extension. Moved API keys to local config.
This commit is contained in:
@@ -46,8 +46,6 @@ module.exports = function(posts) {
|
||||
const filepath = post.content.album ? interpolate(config.library.album[type], post.user, post, item) : interpolate(config.library[type], post.user, post, item);
|
||||
|
||||
return Promise.resolve().then(() => {
|
||||
return fs.ensureDir(path.dirname(filepath));
|
||||
}).then(() => {
|
||||
return save(filepath, item.streams || item.stream, item, post);
|
||||
}).then(sourcePaths => {
|
||||
if(item.mux) {
|
||||
|
||||
@@ -64,7 +64,7 @@ function interpolate(pattern, user, post, item) {
|
||||
$itemIndex: item.index + config.library.indexOffset,
|
||||
$extracted: item.extracted ? config.library.booleans.extracted : '',
|
||||
$preview: item.preview ? config.library.booleans.preview : '',
|
||||
$ext: `.${mime.extension(item.type) || path.extname(url.parse(item.url).pathname)}`
|
||||
$ext: item.type ? `.${mime.extension(item.type)}` : path.extname(url.parse(item.url).pathname)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const ffmpeg = require('fluent-ffmpeg');
|
||||
|
||||
function save(filepath, streams, item, post) {
|
||||
function save(requestedFilepath, streams, item, post) {
|
||||
const filepath = requestedFilepath.split('/').map(component => {
|
||||
if(config.library.truncate && component.length > config.library.truncate.limit) {
|
||||
return component.slice(0, config.library.truncate.limit - config.library.truncate.truncator.length) + config.library.truncate.truncator;
|
||||
}
|
||||
|
||||
return component;
|
||||
}).join(path.sep);
|
||||
|
||||
const pathComponents = path.parse(filepath);
|
||||
|
||||
// allow for single stream argument
|
||||
|
||||
Reference in New Issue
Block a user