diff --git a/.gitmodules b/.gitmodules index 2da9723..a0e76f8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "torrent_search"] path = torrent_search - url = git@github.com:KevinMidboe/torrent_search.git + url = https://github.com/KevinMidboe/torrent_search.git diff --git a/.travis.yml b/.travis.yml index f6cc463..db5320c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: '8.7.0' git: - submodules: false + submodules: true script: yarn test before_install: diff --git a/README.md b/README.md index 2f8a9cf..8949108 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [![Known Vulnerabilities](https://snyk.io/test/github/KevinMidboe/seasonedShows/badge.svg?targetFile=seasoned_api/package.json)](https://snyk.io/test/github/KevinMidboe/seasonedShows?targetFile=seasoned_api/package.json) [![DUB](https://img.shields.io/dub/l/vibe-d.svg)]() -Your customly *seasoned* movie and show requester, downloader and organizer. Demo page can be viewed [here](https://kevinmidboe.com/request) +Your customly *seasoned* movie and show requester, downloader and organizer. +📺 [Demo](https://kevinmidboe.com/request) ## About The goal of this project is to create a full custom stack that can to everything surround downloading, organizing and notifiyng of new media. From the top down we have a website using [tmdb](https://www.themoviedb.com) api to search for from over 350k movies and 70k tv shows. Using [hjone72](https://github.com/hjone72/PlexAuth) great PHP reverse proxy we can have a secure way of allowing users to login with their plex credentials which limits request capabilites to only users that are authenticated to use your plex library. diff --git a/seasoned_api/src/plex/requestRepository.js b/seasoned_api/src/plex/requestRepository.js index 94e368c..4695eda 100644 --- a/seasoned_api/src/plex/requestRepository.js +++ b/seasoned_api/src/plex/requestRepository.js @@ -8,12 +8,8 @@ const plexRepository = new PlexRepository(); const cache = new Cache(); const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey')); -const MailTemplate = require('src/plex/mailTemplate'); -const nodemailer = require('nodemailer'); - - class RequestRepository { - constructor(cache, database) { + constructor(database) { this.database = database || establishedDatabase; this.queries = { insertRequest: `INSERT INTO requests(id,title,year,poster_path,background_path,requested_by,ip,user_agent,type) @@ -22,7 +18,7 @@ class RequestRepository { fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ? ORDER BY date DESC LIMIT 25 OFFSET ?*25-25', updateRequestedById: 'UPDATE requests SET status = ? WHERE id is ? AND type is ?', checkIfIdRequested: 'SELECT * FROM requests WHERE id IS ? AND type IS ?', - userRequests: 'SELECT * FROM requests WHERE requested_by IS ?' + userRequests: 'SELECT * FROM requests WHERE requested_by IS ?', }; this.cacheTags = { search: 'se', @@ -51,10 +47,7 @@ class RequestRepository { .then(() => this.database.get(this.queries.checkIfIdRequested, [tmdbMovie.id, tmdbMovie.type])) .then((result, error) => { if (error) { throw new Error(error); } - let already_requested = false; - if (result) { already_requested = true; } - - tmdbMovie.requested = already_requested; + tmdbMovie.requested = result ? true : false; return tmdbMovie; }); } @@ -85,13 +78,15 @@ class RequestRepository { } userRequests(user) { - return Promise.resolve() + return Promise.resolve() .then(() => this.database.all(this.queries.userRequests, user.username)) .catch((error) => { - if (String(error).includes('no such column')) { throw new Error('Username not found'); } - else { throw new Error('Unable to fetch your requests')} + if (String(error).includes('no such column')) { + throw new Error('Username not found'); + } + throw new Error('Unable to fetch your requests'); }) - .then((result) => { return result }) + .then((result) => { return result; }); } updateRequestedById(id, type, status) {