Skip to content

Commit

Permalink
updates logging
Browse files Browse the repository at this point in the history
  • Loading branch information
petersem committed Mar 26, 2024
1 parent 36e9760 commit 37a0be1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
36 changes: 28 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require("path");
const app = express();
const radarr = require("./classes/radarr");
const sonarr = require("./classes/sonarr");
const pjson = require("./package.json");
let movies = "";
let shows = "";
let distinctMovieGenres = [];
Expand All @@ -13,8 +14,17 @@ const radarrUrl = process.env.RADARR_URL;
const sonarrToken = process.env.SONARR_TOKEN;
const sonarrUrl = process.env.SONARR_URL;
const token = process.env.TOKEN || "";
let radarrEnabled = true;
let sonarrEnabled = true;


console.log(`******************************`);
console.log(` Exportarr - By Matt Petersen`);
console.log(` Brisbane, Australia `);
console.log(` Version: ` + pjson.version );
console.log(`******************************`);
console.log(` `);

let movieClock;
let showClock;

Expand Down Expand Up @@ -51,15 +61,17 @@ if(radarrUrl != null && radarrToken != null){
GetMovies();
}
else{
console.log('Radarr not enabled')
console.log('* Radarr not enabled')
radarrEnabled = false;
}

// get shows
if(sonarrUrl != null && sonarrToken != null){
GetShows();
}
else{
console.log('Sonarr not enabled')
console.log('* Sonarr not enabled')
radarrEnabled = false;
}

//use ejs templating engine
Expand All @@ -79,11 +91,19 @@ app.use(express.static(path.join(__dirname, "public")));

// set routes
app.get("/", (req, res) => {
if(req.query.token !== token && token !== ""){
res.sendStatus(401);
if(sonarrEnabled && radarrEnabled){
if(req.query.token !== token && token !== ""){
res.sendStatus(401);
}
else{
res.render('index',{radarr: distinctMovieGenres, sonarr: distinctShowGenres, token: token, movies: movies, shows: shows});
}
}
else{
res.render('index',{radarr: distinctMovieGenres, sonarr: distinctShowGenres, token: token, movies: movies, shows: shows});
res.writeHead(200);
res.end("** SONARR and/or RADARR not configured in environment variables - cannot start Exportarr");
console.log(" ");
console.log("** SONARR and/or RADARR not configured in environment variables - cannot start Exportarr");
}
});

Expand All @@ -98,7 +118,7 @@ app.get("/radarr", (req, res) => {
});

app.get("/radarr/:genre", (req, res) => {
console.log(req.query.token);
//console.log("selected movie genre: " + req.params.genre.toLowerCase());
if(req.query.token !== token && token !== ""){
res.sendStatus(401);
}
Expand All @@ -121,7 +141,7 @@ app.get("/sonarr", (req, res) => {
});

app.get("/sonarr/:genre", (req, res) => {
console.log(req.query.token);
//console.log("selected show genre: " + req.params.genre.toLowerCase());
if(req.query.token !== token && token !== ""){
res.sendStatus(401);
}
Expand All @@ -137,4 +157,4 @@ app.get("/sonarr", (req, res) => {
// start listening on port 3000
app.listen(3000, () => {
console.log(`✅ Web server started on internal port 3000 `);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "exportarr",
"version": "1.1.0",
"version": "1.1.2",
"description": "Export radarr list as custom stephen lu format feeds, for import into other radarr apps",
"main": "index.js",
"nodemonConfig": {
Expand Down

0 comments on commit 37a0be1

Please sign in to comment.