Skip to content

Commit

Permalink
Even better linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aunefyren committed Oct 4, 2023
1 parent bf5e7de commit 76fe793
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 53 deletions.
13 changes: 6 additions & 7 deletions Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
// Select connection type
let connection_type = null;
try {
if (SSL == 'http') {
connection_type = http
if (SSL === 'http') {
connection_type = http;
} else {
connection_type = https
connection_type = https;
}
} catch (e) {
//console.log(`Failed to compare SSL string. Error: ${e}`);

Check failure on line 146 in Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-20.04)

Expected exception block, space or tab after '//' in comment
connection_type = http
connection_type = http;
}

// Try to split file path to retrieve series folder name
Expand All @@ -155,7 +155,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
} catch (e) {
//console.log(`Failed to split file name. Error: '${e}'.\\n`);

Check failure on line 156 in Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-20.04)

Expected exception block, space or tab after '//' in comment
response.infoLog += `\\nFailed to split file name. Error: '${e}'.`;
return response
return response;
}

//console.log(`Searching for series '${term}'.`);

Check failure on line 161 in Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-20.04)

Expected exception block, space or tab after '//' in comment
Expand All @@ -164,7 +164,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
// Create variables for API call
const url1 = `${SSL}://${IP}:${port}${APIPathLookup}?term=${termUri}&apikey=${APIKey}`;
let url1_body = '';
let url2 = ``;
let url2 = '';
let SeriesID = 0;

// API call to search for Series ID using the folder name
Expand All @@ -181,7 +181,6 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
res.on('end', function () {

Check warning on line 181 in Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-20.04)

Prefer using arrow functions over plain functions

Check warning on line 181 in Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-20.04)

Unexpected unnamed function
resolve();
});

}).on('error', (e) => {
//console.log(`Failed to search for series. Error: '${e}'.`);
response.infoLog += `\\nFailed to search for series. Error: '${e}'.`;
Expand Down
33 changes: 16 additions & 17 deletions Community/Tdarr_Plugin_f4k3_aune_rename_files_in_sonarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const details = () => ({
Name: 'Rename files in Sonarr',
Type: 'Video',
Operation: 'Transcode',
Description: `Renames the files in the current show in Sonarr according to naming format. This is done using the Sonarr API. To do this action it needs the Show ID. This code attempts to retrieve the Show ID by using the folder name of the series. To rename the correct file we need the season and episode number. To find this SXXEXX needs to be present in the file name.`,
Description: `Renames the files in the current show in Sonarr according to naming format. This is done using the Sonarr API.
To do this action it needs the Show ID. This code attempts to retrieve the Show ID by using the folder name of the series.
To rename the correct file we need the season and episode number. To find this SXXEXX needs to be present in the file name.`,
Version: '1.0',
Tags: '3rd party,post-processing,configurable',

Expand Down Expand Up @@ -95,7 +97,6 @@ function sleep(ms) {

// eslint-disable-next-line no-unused-vars
const plugin = async (file, librarySettings, inputs, otherArguments) => {

const response = {
file,
removeFromDB: false,
Expand All @@ -104,7 +105,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
infoLog: 'Rename Sonarr files starting.',
};

//console.log("Rename Sonarr files starting.")
//console.log('Rename Sonarr files starting.')

const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
Expand All @@ -113,7 +114,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
const https = require('https');
const axios = require('axios');

//console.log("Loaded required packages.")
//console.log('Loaded required packages.')

// Defines variables
const SSL = inputs.Url_Protocol;
Expand All @@ -122,9 +123,9 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
const APIKey = inputs.Sonarr_APIKey;
const sleepInterval = inputs.After_Sleep;
const regex = '(S[0-9]{1,4}E[0-9]{1,2})';
let seasonEpisodeMatch = "";
let term = "";
let termUri = "";
let seasonEpisodeMatch = '';
let term = '';
let termUri = '';
const APIPathLookup = '/api/v3/series/lookup';
const APIPathEpisodefile = '/api/v3/episodefile';
const APIPathCommand = '/api/v3/command';
Expand All @@ -138,14 +139,14 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
// Select connection type
let connection_type = null;
try {
if (SSL == "http") {
connection_type = http
if (SSL === 'http') {
connection_type = http;
} else {
connection_type = https
connection_type = https;
}
} catch (e) {
//console.log(`Failed to compare SSL string. Error: ${e}`);
connection_type = http
connection_type = http;
}

// Try to split file path to retrieve series folder name and season-episode number
Expand Down Expand Up @@ -180,18 +181,17 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
let url2 = ``;
let url3 = ``;
let SeriesID = 0;
let url1_body = "";
let url2_body = "";
let url1_body = '';
let url2_body = '';

// API call to search for folder name to get Series ID
try {
await new Promise((resolve) => {
connection_type.get(url1, (res) => {

//console.log(`Got status code '${res.statusCode}'.`)
response.infoLog += `\\nGot status code '${res.statusCode}'.`;

res.on("data", function (chunk) {
res.on('data', function (chunk) {
url1_body += chunk;
});

Expand Down Expand Up @@ -233,11 +233,10 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
try {
await new Promise((resolve) => {
connection_type.get(url2, (res) => {

//console.log(`Got status code '${res.statusCode}'.`)
response.infoLog += `\\nGot status code '${res.statusCode}'.`;

res.on("data", function (chunk) {
res.on('data', function (chunk) {
url2_body += chunk;
});

Expand Down
24 changes: 11 additions & 13 deletions Community/Tdarr_Plugin_f4k4_aune_refresh_files_in_radarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const details = () => ({

// eslint-disable-next-line no-unused-vars
const plugin = async (file, librarySettings, inputs, otherArguments) => {

const response = {
file,
removeFromDB: false,
Expand All @@ -98,7 +97,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
infoLog: 'Refresh Radarr files starting.',
};

//console.log("Refresh Radarr files starting.")
//console.log('Refresh Radarr files starting.')

const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
Expand All @@ -107,16 +106,16 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
const https = require('https');
const axios = require('axios');

//console.log("Loaded required packages.")
//console.log('Loaded required packages.')

// Create variables
const SSL = inputs.Url_Protocol;
const IP = inputs.Url_Radarr;
const port = inputs.Radarr_Port;
const APIKey = inputs.Radarr_APIKey;
const sleepInterval = inputs.After_Sleep;
let term = "";
let termUri = "";
let term = '';
let termUri = '';
const APIPathLookup = '/api/v3/movie/lookup';
const APIPathCommand = '/api/v3/command';
const APICommand = 'RefreshMovie';
Expand All @@ -129,14 +128,14 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
// Select connection type
let connection_type = null;
try {
if (SSL == "http") {
connection_type = http
if (SSL == 'http') {
connection_type = http;
} else {
connection_type = https
connection_type = https;
}
} catch (e) {
//console.log(`Failed to compare SSL string. Error: ${e}`);
connection_type = http
connection_type = http;
}

// Try to split file path to retrieve movie folder name
Expand All @@ -155,19 +154,18 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {

// Create variables for API call
const url1 = `${SSL}://${IP}:${port}${APIPathLookup}?term=${termUri}&apikey=${APIKey}`;
let url1_body = "";
let url2 = ``;
let url1_body = '';
let url2 = '';
let MovieID = 0;

// API call to search for Movie ID using the folder name
try {
await new Promise((resolve) => {
connection_type.get(url1, (res) => {

//console.log(`Got status code '${res.statusCode}'.`)
response.infoLog += `\\nGot status code '${res.statusCode}'.`;

res.on("data", function (chunk) {
res.on('data', function (chunk) {
url1_body += chunk;
});

Expand Down
30 changes: 14 additions & 16 deletions Community/Tdarr_Plugin_f4k5_aune_rename_files_in_radarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const details = () => ({
Name: 'Rename files in Radarr',
Type: 'Video',
Operation: 'Transcode',
Description: `Renames the files in the current movie in Radarr according to naming format. This is done using the Radarr API. To do this action it needs the Movie ID. This code attempts to retrieve the Movie ID by using the folder name of the movie.`,
Description: `Renames the files in the current movie in Radarr according to naming format. This is done using the Radarr API.
To do this action it needs the Movie ID. This code attempts to retrieve the Movie ID by using the folder name of the movie.`,
Version: '1.0',
Tags: '3rd party,post-processing,configurable',

Expand Down Expand Up @@ -98,7 +99,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
infoLog: 'Rename Radarr files starting.',
};

//console.log("Rename Radarr files starting.")
//console.log('Rename Radarr files starting.')

const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
Expand All @@ -107,7 +108,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
const https = require('https');
const axios = require('axios');

//console.log("Loaded required packages.")
//console.log('Loaded required packages.')

// Defines variables
const SSL = inputs.Url_Protocol;
Expand All @@ -116,8 +117,8 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
const APIKey = inputs.Radarr_APIKey;
const sleepInterval = inputs.After_Sleep;
const regex = '(S[0-9]{1,4}E[0-9]{1,2})';
let term = "";
let termUri = "";
let term = '';
let termUri = '';
const APIPathLookup = '/api/v3/movie/lookup';
const APIPathMoviefile = '/api/v3/moviefile';
const APIPathCommand = '/api/v3/command';
Expand All @@ -131,14 +132,14 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
// Select connection type
let connection_type = null;
try {
if (SSL == "http") {
connection_type = http
if (SSL == 'http') {
connection_type = http;
} else {
connection_type = https
connection_type = https;
}
} catch (e) {
//console.log(`Failed to compare SSL string. Error: ${e}`);
connection_type = http
connection_type = http;
}

// Try to split file path to retrieve movie folder name
Expand All @@ -160,25 +161,23 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
let url2 = ``;
let url3 = ``;
let MovieID = 0;
let url1_body = "";
let url2_body = "";
let url1_body = '';
let url2_body = '';

// API call to search for folder name to get Movie ID
try {
await new Promise((resolve) => {
connection_type.get(url1, (res) => {

//console.log(`Got status code '${res.statusCode}'.`)
response.infoLog += `\\nGot status code '${res.statusCode}'.`;

res.on("data", function (chunk) {
res.on('data', function (chunk) {
url1_body += chunk;
});

res.on('end', function () {
resolve();
});

}).on('error', (e) => {
//console.log(`Failed to search for movie. Error: '${e}'.`)
response.infoLog += `\\nFailed to search for movie. Error: '${e}'.`;
Expand Down Expand Up @@ -213,11 +212,10 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
try {
await new Promise((resolve) => {
connection_type.get(url2, (res) => {

//console.log(`Got status code '${res.statusCode}'.`)
response.infoLog += `\\nGot status code '${res.statusCode}'.`;

res.on("data", function (chunk) {
res.on('data', function (chunk) {
url2_body += chunk;
});

Expand Down

0 comments on commit 76fe793

Please sign in to comment.