spee.ch/helpers/libraries/publishHelpers.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

const logger = require('winston');
const config = require('config');
const fs = require('fs');
module.exports = {
createPublishParams: (name, filePath, license, nsfw) => {
logger.debug(`Creating Publish Parameters for "${name}"`);
// const payAddress = config.get('WalletConfig.LbryPayAddress');
const claimAddress = config.get('WalletConfig.LbryClaimAddress');
// const changeAddress = config.get('WalletConfig.LbryChangeAddress');
2017-06-29 21:35:36 +02:00
// filter nsfw and ensure it is a boolean
2017-06-27 04:39:12 +02:00
if (nsfw === false) {
nsfw = false;
} else if (nsfw.toLowerCase === 'false') {
nsfw = false;
} else if (nsfw.toLowerCase === 'off') {
2017-06-27 00:01:41 +02:00
nsfw = false;
} else if (nsfw === 0) {
nsfw = false;
} else if (nsfw === '0') {
nsfw = false;
} else {
nsfw = true;
2017-06-27 00:01:41 +02:00
}
const publishParams = {
name,
file_path: filePath,
bid : 0.01,
metadata : {
description: `${name} published via spee.ch`,
title : name,
author : 'spee.ch',
language : 'en',
license,
nsfw,
},
claim_address: claimAddress,
2017-06-29 21:35:36 +02:00
// change_address: changeAddress,
};
logger.debug('publishParams:', publishParams);
return publishParams;
},
deleteTemporaryFile: (filePath) => {
fs.unlink(filePath, err => {
if (err) throw err;
logger.debug(`successfully deleted ${filePath}`);
});
},
};