2017-06-26 19:02:14 +02:00
|
|
|
const logger = require('winston');
|
|
|
|
const config = require('config');
|
|
|
|
const walletAddress = config.get('WalletConfig.LbryAddress');
|
2017-06-28 00:53:53 +02:00
|
|
|
const fs = require('fs');
|
2017-06-26 19:02:14 +02:00
|
|
|
|
|
|
|
module.exports = {
|
2017-06-28 00:53:53 +02:00
|
|
|
createPublishParams: (name, filePath, license, nsfw) => {
|
2017-06-26 19:02:14 +02:00
|
|
|
logger.debug(`Creating Publish Parameters for "${name}"`);
|
2017-06-27 00:01:41 +02:00
|
|
|
// ensure nsfw is a boolean
|
2017-06-27 04:39:12 +02:00
|
|
|
if (nsfw === false) {
|
|
|
|
nsfw = false;
|
|
|
|
} else if (nsfw.toLowerCase === 'false') {
|
2017-06-27 04:26:37 +02:00
|
|
|
nsfw = false;
|
|
|
|
} else if (nsfw.toLowerCase === 'off') {
|
2017-06-27 00:01:41 +02:00
|
|
|
nsfw = false;
|
2017-06-27 04:26:37 +02:00
|
|
|
} else if (nsfw === 0) {
|
|
|
|
nsfw = false;
|
|
|
|
} else if (nsfw === '0') {
|
|
|
|
nsfw = false;
|
|
|
|
} else {
|
|
|
|
nsfw = true;
|
2017-06-27 00:01:41 +02:00
|
|
|
}
|
2017-06-26 19:02:14 +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 : walletAddress,
|
|
|
|
change_address: walletAddress,
|
|
|
|
};
|
|
|
|
logger.debug('publishParams:', publishParams);
|
|
|
|
return publishParams;
|
|
|
|
},
|
2017-06-28 00:53:53 +02:00
|
|
|
deleteTemporaryFile: (filePath) => {
|
|
|
|
fs.unlink(filePath, err => {
|
|
|
|
if (err) throw err;
|
|
|
|
logger.debug(`successfully deleted ${filePath}`);
|
|
|
|
});
|
|
|
|
},
|
2017-06-26 19:02:14 +02:00
|
|
|
};
|