mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
lint fixes
This commit is contained in:
parent
b13ae8cc29
commit
f0109f2bfe
9 changed files with 40 additions and 10 deletions
|
|
@ -114,12 +114,16 @@ function plugin(file, librarySettings, inputs) {
|
|||
let bitrateSettings = '';
|
||||
// Work out currentBitrate using "Bitrate = file size / (number of minutes * .0075)"
|
||||
// Used from here https://blog.frame.io/2017/03/06/calculate-video-bitrates/
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const currentBitrate = ~~(file.file_size / (duration * 0.0075));
|
||||
// Use the same calculation used for currentBitrate but divide it in half to get targetBitrate.
|
||||
// Logic of h265 can be half the bitrate as h264 without losing quality.
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const targetBitrate = ~~(file.file_size / (duration * 0.0075) / 2);
|
||||
// Allow some leeway under and over the targetBitrate.
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const minimumBitrate = ~~(targetBitrate * 0.7);
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const maximumBitrate = ~~(targetBitrate * 1.3);
|
||||
|
||||
// If targetBitrate comes out as 0 then something has gone wrong and bitrates could not be calculated.
|
||||
|
|
@ -250,7 +254,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
}
|
||||
|
||||
// Set bitrateSettings variable using bitrate information calulcated earlier.
|
||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k -maxrate ${maximumBitrate}k -bufsize ${currentBitrate}k`;
|
||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k `
|
||||
+ `-maxrate ${maximumBitrate}k -bufsize ${currentBitrate}k`;
|
||||
// Print to infoLog information around file & bitrate settings.
|
||||
response.infoLog += `Container for output selected as ${inputs.container}. \n`;
|
||||
response.infoLog += `Current bitrate = ${currentBitrate} \n`;
|
||||
|
|
@ -278,7 +283,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
response.preset = '-c:v vp8_cuvid';
|
||||
}
|
||||
|
||||
response.preset += `,-map 0 -c:v hevc_nvenc -rc:v vbr_hq -cq:v 19 ${bitrateSettings} -spatial_aq:v 1 -rc-lookahead:v 32 -c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
|
||||
response.preset += `,-map 0 -c:v hevc_nvenc -rc:v vbr_hq -cq:v 19 ${bitrateSettings} `
|
||||
+ `-spatial_aq:v 1 -rc-lookahead:v 32 -c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
|
||||
response.processFile = true;
|
||||
response.infoLog += 'File is not hevc or vp9. Transcoding. \n';
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -101,12 +101,16 @@ function plugin(file, librarySettings, inputs) {
|
|||
let bitrateSettings = '';
|
||||
// Work out currentBitrate using "Bitrate = file size / (number of minutes * .0075)"
|
||||
// Used from here https://blog.frame.io/2017/03/06/calculate-video-bitrates/
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const currentBitrate = ~~(file.file_size / (duration * 0.0075));
|
||||
// Use the same calculation used for currentBitrate but divide it in half to get targetBitrate.
|
||||
// Logic of h265 can be half the bitrate as h264 without losing quality.
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const targetBitrate = ~~(file.file_size / (duration * 0.0075) / 2);
|
||||
// Allow some leeway under and over the targetBitrate.
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const minimumBitrate = ~~(targetBitrate * 0.7);
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const maximumBitrate = ~~(targetBitrate * 1.3);
|
||||
|
||||
// If targetBitrate comes out as 0 then something has gone wrong and bitrates could not be calculcated.
|
||||
|
|
@ -124,7 +128,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
// If so then cancel plugin without touching original files.
|
||||
if (currentBitrate <= inputs.bitrate_cutoff) {
|
||||
response.processFile = false;
|
||||
response.infoLog += `Current bitrate is below set bitrate cutoff of ${inputs.bitrate_cutoff}. Nothing to do, cancelling plugin. \n`;
|
||||
response.infoLog += 'Current bitrate is below set bitrate cutoff '
|
||||
+ `of ${inputs.bitrate_cutoff}. Nothing to do, cancelling plugin. \n`;
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -218,7 +223,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
}
|
||||
|
||||
// Set bitrateSettings variable using bitrate information calulcated earlier.
|
||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k -maxrate ${maximumBitrate}k -bufsize ${currentBitrate}k`;
|
||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k `
|
||||
+ `-maxrate ${maximumBitrate}k -bufsize ${currentBitrate}k`;
|
||||
// Print to infoLog information around file & bitrate settings.
|
||||
response.infoLog += `Container for output selected as ${inputs.container}. \n`;
|
||||
response.infoLog += `Current bitrate = ${currentBitrate} \n`;
|
||||
|
|
@ -227,7 +233,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
response.infoLog += `Minimum = ${minimumBitrate} \n`;
|
||||
response.infoLog += `Maximum = ${maximumBitrate} \n`;
|
||||
|
||||
response.preset += `,-map 0 -c:v libx265 ${bitrateSettings} -c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
|
||||
response.preset += `,-map 0 -c:v libx265 ${bitrateSettings} `
|
||||
+ `-c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
|
||||
response.processFile = true;
|
||||
response.infoLog += 'File is not hevc or vp9. Transcoding. \n';
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
response.processFile = true;
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
module.exports.details = details;
|
||||
module.exports.plugin = plugin;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ function plugin(file, librarySettings, inputs) {
|
|||
|
||||
// Check if file is a video. If it isn't then exit plugin.
|
||||
if (file.fileMedium !== 'video') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('File is not video');
|
||||
response.infoLog += '☒File is not video \n';
|
||||
response.processFile = false;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ function plugin(file, librarySettings, inputs) {
|
|||
|
||||
// Check if file is a video. If it isn't then exit plugin.
|
||||
if (file.fileMedium !== 'video') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('File is not video');
|
||||
response.infoLog += '☒File is not video \n';
|
||||
response.processFile = false;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ function plugin(file, librarySettings, inputs) {
|
|||
|
||||
// Check if file is a video. If it isn't then exit plugin.
|
||||
if (file.fileMedium !== 'video') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('File is not video');
|
||||
response.infoLog += '☒File is not video \n';
|
||||
response.processFile = false;
|
||||
|
|
@ -65,7 +66,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
|
||||
// Check if inputs.language has been configured. If it hasn't then exit plugin.
|
||||
if (inputs.language === '') {
|
||||
response.infoLog += '☒Language/s to keep have not been configured, please configure required options. Skipping this plugin. \n';
|
||||
response.infoLog += '☒Language/s to keep have not been configured, '
|
||||
+ 'please configure required options. Skipping this plugin. \n';
|
||||
response.processFile = false;
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ function plugin(file, librarySettings, inputs) {
|
|||
|
||||
// Check if file is a video. If it isn't then exit plugin.
|
||||
if (file.fileMedium !== 'video') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('File is not video');
|
||||
response.infoLog += '☒File is not video. \n';
|
||||
response.processFile = false;
|
||||
|
|
@ -145,7 +146,8 @@ function plugin(file, librarySettings, inputs) {
|
|||
// Convert file if convert variable is set to true.
|
||||
if (convert === true) {
|
||||
response.processFile = true;
|
||||
response.preset = `, -map 0 -c:v copy -c:a copy ${ffmpegCommandInsert} -strict -2 -c:s copy -max_muxing_queue_size 9999 `;
|
||||
response.preset = `, -map 0 -c:v copy -c:a copy ${ffmpegCommandInsert} `
|
||||
+ '-strict -2 -c:s copy -max_muxing_queue_size 9999 ';
|
||||
} else {
|
||||
response.infoLog += '☑File contains all required audio formats. \n';
|
||||
response.processFile = false;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function details() {
|
|||
};
|
||||
}
|
||||
|
||||
function plugin(file, librarySettings) {
|
||||
function plugin(file) {
|
||||
const response = {
|
||||
processFile: false,
|
||||
preset: '',
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// eslint-disable-next-line import/no-unresolved
|
||||
const request = require('request');
|
||||
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
module.exports.details = function details() {
|
||||
return {
|
||||
|
|
@ -45,12 +48,11 @@ module.exports.details = function details() {
|
|||
|
||||
module.exports.plugin = function plugin(file, librarySettings, inputs) {
|
||||
// Set up required variables.
|
||||
const request = require('request');
|
||||
const ADDRESS = inputs.autoscan_address;
|
||||
const PORT = inputs.autoscan_port;
|
||||
const PASSKEY = inputs.autoscan_passkey;
|
||||
let filepath = '';
|
||||
const response = '';
|
||||
const response = {};
|
||||
filepath = `${file.file}`;
|
||||
|
||||
// Check if all inputs have been configured. If they haven't then exit plugin.
|
||||
|
|
@ -78,12 +80,19 @@ module.exports.plugin = function plugin(file, librarySettings, inputs) {
|
|||
},
|
||||
(error, res, body) => {
|
||||
if (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`statusCode: ${res.statusCode}`);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(body);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('request next');
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(request.post);
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue