Fix: Tests lint and src folder #138
@@ -1,4 +1,3 @@
|
||||
const request = require("request");
|
||||
const configuration = require("../config/configuration").getInstance();
|
||||
|
||||
class SMSUnexpectedError extends Error {
|
||||
@@ -20,23 +19,21 @@ const sendSMS = message => {
|
||||
|
||||
const sender = configuration.get("sms", "sender");
|
||||
const recipient = configuration.get("sms", "recipient");
|
||||
const smsRequestHeaders = { "Content-Type": "application/json" };
|
||||
const smsRequestBody = {
|
||||
sender,
|
||||
message,
|
||||
recipients: [{ msisdn: `47${recipient}` }]
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post(
|
||||
{
|
||||
url: `https://gatewayapi.com/rest/mtsms?token=${apiKey}`,
|
||||
json: true,
|
||||
body: {
|
||||
sender,
|
||||
message,
|
||||
recipients: [{ msisdn: `47${recipient}` }]
|
||||
}
|
||||
},
|
||||
(err, r, body) => {
|
||||
if (err) reject(new SMSUnexpectedError(err || body));
|
||||
resolve(body);
|
||||
}
|
||||
);
|
||||
fetch(`https://gatewayapi.com/rest/mtsms?token=${apiKey}`, {
|
||||
body: JSON.stringify(smsRequestBody),
|
||||
headers: smsRequestHeaders
|
||||
})
|
||||
.then(resp => resp.json())
|
||||
.then(response => resolve(response))
|
||||
.catch(error => reject(new SMSUnexpectedError(error)));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const fetch = require("node-fetch");
|
||||
const convertPlexToMovie = require("./convertPlexToMovie");
|
||||
const convertPlexToShow = require("./convertPlexToShow");
|
||||
const convertPlexToEpisode = require("./convertPlexToEpisode");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const rp = require("request-promise");
|
||||
const convertPlexToSeasoned = require("./convertPlexToSeasoned");
|
||||
const convertPlexToStream = require("./convertPlexToStream");
|
||||
|
||||
@@ -35,8 +34,9 @@ function mapResults(response) {
|
||||
}
|
||||
|
||||
class PlexRepository {
|
||||
constructor(plexIP) {
|
||||
constructor(plexIP, plexToken) {
|
||||
this.plexIP = plexIP;
|
||||
this.plexToken = plexToken;
|
||||
}
|
||||
|
||||
inPlex(_tmdbResult) {
|
||||
@@ -56,19 +56,17 @@ class PlexRepository {
|
||||
}
|
||||
|
||||
search(query) {
|
||||
const queryUri = encodeURIComponent(query);
|
||||
const uri = encodeURI(
|
||||
`http://${this.plexIP}:32400/search?query=${queryUri}`
|
||||
const url = encodeURI(
|
||||
`http://${this.plexIP}:32400/search?query=${encodeURIComponent(
|
||||
query
|
||||
)}&X-Plex-Token=${this.plexToken}`
|
||||
);
|
||||
const options = {
|
||||
uri,
|
||||
headers: {
|
||||
Accept: "application/json"
|
||||
},
|
||||
json: true
|
||||
headers: { Accept: "application/json" }
|
||||
};
|
||||
|
||||
return rp(options)
|
||||
return fetch(url, options)
|
||||
.then(resp => resp.json())
|
||||
.then(result => mapResults(result))
|
||||
.then(([mappedResults, resultCount]) => ({
|
||||
results: mappedResults,
|
||||
@@ -77,15 +75,13 @@ class PlexRepository {
|
||||
}
|
||||
|
||||
nowPlaying() {
|
||||
const url = `http://${this.plexIP}:32400/status/sessions?X-Plex-Token=${this.plexToken}`;
|
||||
const options = {
|
||||
uri: `http://${this.plexIP}:32400/status/sessions`,
|
||||
headers: {
|
||||
Accept: "application/json"
|
||||
},
|
||||
json: true
|
||||
headers: { Accept: "application/json" }
|
||||
};
|
||||
|
||||
return rp(options)
|
||||
return fetch(url, options)
|
||||
.then(resp => resp.json())
|
||||
.then(result => {
|
||||
if (result.MediaContainer.size > 0) {
|
||||
const playing =
|
||||
|
||||
@@ -3,7 +3,10 @@ const configuration = require("../config/configuration").getInstance();
|
||||
const TMDB = require("../tmdb/tmdb");
|
||||
const establishedDatabase = require("../database/database");
|
||||
|
||||
const plexRepository = new PlexRepository(configuration.get("plex", "ip"));
|
||||
const plexRepository = new PlexRepository(
|
||||
configuration.get("plex", "ip"),
|
||||
configuration.get("plex", "token")
|
||||
);
|
||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||
|
||||
class RequestRepository {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
class TautulliUnexpectedError extends Error {
|
||||
constructor(errorMessage) {
|
||||
const message = "Unexpected error fetching from tautulli.";
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
const PlexRepository = require("../../../plex/plexRepository");
|
||||
const configuration = require("../../../config/configuration").getInstance();
|
||||
|
||||
const plexRepository = new PlexRepository(configuration.get("plex", "ip"));
|
||||
const plexRepository = new PlexRepository(
|
||||
configuration.get("plex", "ip"),
|
||||
configuration.get("plex", "token")
|
||||
);
|
||||
|
||||
function playingController(req, res) {
|
||||
plexRepository
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
const PlexRepository = require("../../../plex/plexRepository");
|
||||
const configuration = require("../../../config/configuration").getInstance();
|
||||
|
||||
const plexRepository = new PlexRepository(configuration.get("plex", "ip"));
|
||||
const plexRepository = new PlexRepository(
|
||||
configuration.get("plex", "ip"),
|
||||
configuration.get("plex", "token")
|
||||
);
|
||||
|
||||
/**
|
||||
* Controller: Search for media and check existence
|
||||
|
||||
@@ -4,8 +4,6 @@ const app = require("./app");
|
||||
module.exports = app.listen(config.get("webserver", "port"), () => {
|
||||
/* eslint-disable no-console */
|
||||
console.log("seasonedAPI");
|
||||
/* eslint-disable no-console */
|
||||
console.log(`Database is located at ${config.get("database", "host")}`);
|
||||
/* eslint-disable no-console */
|
||||
console.log(`Webserver is listening on ${config.get("webserver", "port")}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user