Skip to content

Commit

Permalink
Linting and new-line fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aunefyren committed Oct 4, 2023
1 parent ba698f9 commit bf5e7de
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
try {
// Skip if the codec_type is filtered out
if (
codecTypeFilter.length !== 0 &&
!codecTypeFilter.includes(String(file.ffProbeData.streams[i].codec_type))) {
codecTypeFilter.length !== 0
&& !codecTypeFilter.includes(String(file.ffProbeData.streams[i].codec_type))) {
continue;

Check failure on line 117 in Community/Tdarr_Plugin_00td_action_remove_stream_by_specified_property.js

View workflow job for this annotation

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

Unexpected use of continue statement
}

Expand All @@ -125,8 +125,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
is ${file.ffProbeData.streams[i][removeIfPropertyMissing[j]]} \n`;

if (
file.ffProbeData.streams[i][removeIfPropertyMissing[j]] === 'undefined' ||
file.ffProbeData.streams[i][removeIfPropertyMissing[j]] === null) {
file.ffProbeData.streams[i][removeIfPropertyMissing[j]] === 'undefined'
|| file.ffProbeData.streams[i][removeIfPropertyMissing[j]] === null) {
emptyValue = true;
response.infoLog += ` Removing stream ${i} which is has ${removeIfPropertyMissing[j]} missing`;
break;
Expand All @@ -140,8 +140,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {

// Log the old message if the reason is not empty values
if (!emptyValue) {
response.infoLog += ` Removing stream ${i} which is has ${propertyToCheck} or` +
` of ${file.ffProbeData.streams[i][propertyToCheck]} \n`;
response.infoLog += ` Removing stream ${i} which is has ${propertyToCheck} or`
+ ` of ${file.ffProbeData.streams[i][propertyToCheck]} \n`;
}

streamToRemove = true;
Expand All @@ -165,4 +165,4 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
};

module.exports.details = details;
module.exports.plugin = plugin;
module.exports.plugin = plugin;
65 changes: 32 additions & 33 deletions Community/Tdarr_Plugin_f4k2_aune_refresh_files_in_sonarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
infoLog: 'Refresh Sonarr files starting.',
};

console.log("Refresh Sonarr files starting.")
//console.log('Refresh Sonarr files starting.');

Check failure on line 109 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

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

Check failure on line 116 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)

Unable to resolve path to module 'axios'

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

Check failure on line 118 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

// Create variables
const SSL = inputs.Url_Protocol;
const IP = inputs.Url_Sonarr;
const port = inputs.Sonarr_Port;
const APIKey = inputs.Sonarr_APIKey;
const sleepInterval = inputs.After_Sleep;
let term = "";
let termUri = "";
let term = '';
let termUri = '';
const APIPathLookup = '/api/v3/series/lookup';
const APIPathCommand = '/api/v3/command';
const APICommand = 'RefreshSeries';
Expand All @@ -137,13 +137,13 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
// Select connection type
let connection_type = null;
try {
if (SSL == "http") {
if (SSL == 'http') {

Check failure on line 140 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 '===' and instead saw '=='
connection_type = http

Check failure on line 141 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)

Missing semicolon
} else {
connection_type = https

Check failure on line 143 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)

Missing semicolon
}
} catch (e) {
console.log(`Failed to compare SSL string. Error: ${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
}

Expand All @@ -153,29 +153,28 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
term = term[term.length - 3];
termUri = encodeURI(term);
} catch (e) {
console.log(`Failed to split file name. Error: '${e}'.\n`)
response.infoLog += `\nFailed to split file name. Error: '${e}'.`;
//console.log(`Failed to split file name. Error: '${e}'.\\n`);
response.infoLog += `\\nFailed to split file name. Error: '${e}'.`;
return response
}

console.log(`Searching for series '${term}'.`)
response.infoLog += `\nSearching for series '${term}'.`;
//console.log(`Searching for series '${term}'.`);
response.infoLog += `\\nSearching for series '${term}'.`;

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

// API call to search for Series 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}'.`;

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

res.on("data", function (chunk) {
res.on('data', function (chunk) {

Check warning on line 177 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 177 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
url1_body += chunk;
});

Expand All @@ -184,14 +183,14 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
});

}).on('error', (e) => {
console.log(`Failed to search for series. Error: '${e}'.`)
response.infoLog += `\nFailed to search for series. Error: '${e}'.`;
//console.log(`Failed to search for series. Error: '${e}'.`);
response.infoLog += `\\nFailed to search for series. Error: '${e}'.`;
resolve();
});
});
} catch (e) {
console.log(`Failed API call. Error: '${e}'.`);
response.infoLog += `\nFailed API call. Error: '${e}'.`;
//console.log(`Failed API call. Error: '${e}'.`);
response.infoLog += `\\nFailed API call. Error: '${e}'.`;
return response;
}

Expand All @@ -201,45 +200,45 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
SeriesID = APIresponse[0].id;
url2 = `${SSL}://${IP}:${port}${APIPathCommand}?apikey=${APIKey}`;
} catch (e) {
console.log(`Failed make JSON payload. Error: '${e}'.`);
response.infoLog += `\nFailed make JSON payload. Error: '${e}'.`;
//console.log(`Failed make JSON payload. Error: '${e}'.`);
response.infoLog += `\\nFailed make JSON payload. Error: '${e}'.`;
return response;
}

console.log(`Refreshing series '${SeriesID}'.`);
response.infoLog += `\nRefreshing series '${SeriesID}'.`;
//console.log(`Refreshing series '${SeriesID}'.`);
response.infoLog += `\\nRefreshing series '${SeriesID}'.`;

// API request to send a command to refresh the files for the found Series ID
try {
await new Promise((resolve) => {
axios.post(url2, {
name: APICommand,
seriesId: SeriesID
seriesId: SeriesID,
})
.then(function (res) {

Check warning on line 218 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 218 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
console.log(`Got status code '${res.status}'.`)
response.infoLog += `\n☑ Got status code '${res.status}'.`;
//console.log(`Got status code '${res.status}'.`);
response.infoLog += `\\n☑ Got status code '${res.status}'.`;
resolve();
})
.catch(function (error) {

Check warning on line 223 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 223 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
console.log(`Got error: ${error}`)
response.infoLog += `\nGot error: ${error}`;
//console.log(`Got error: ${error}`);
response.infoLog += `\\nGot error: ${error}`;
resolve();
});
});
} catch (e) {
console.log(`Failed API call. Error: '${e}'.`);
response.infoLog += `\nFailed API call. Error: '${e}'.`;
// console.log(`Failed API call. Error: '${e}'.`);
response.infoLog += `\\nFailed API call. Error: '${e}'.`;
return response;
}

// Sleep for set amount of time
console.log(`Sleeping '${sleepInterval}' ms.`);
response.infoLog += `\nSleeping '${sleepInterval}' ms.`;
// console.log(`Sleeping '${sleepInterval}' ms.`);
response.infoLog += `\\nSleeping '${sleepInterval}' ms.`;
await sleep(sleepInterval);

return response;
};

module.exports.details = details;
module.exports.plugin = plugin;
module.exports.plugin = plugin;
Loading

0 comments on commit bf5e7de

Please sign in to comment.