9 Commits

Author SHA1 Message Date
451b67630a Merge pull request #95 from KevinMidboe/docs_testing
Improved testing, more linting and added paging to request/all endpoint
2018-03-21 23:53:29 +01:00
096bbdf085 Merge branch 'master' into docs_testing 2018-03-21 23:51:31 +01:00
e914e4ab45 Added ORDER BY date that was missing in sql stmt 2018-03-21 23:44:59 +01:00
c1461e1f41 Merge pull request #93 from KevinMidboe/travis
Updated travis to pull submodules
2018-03-21 14:43:36 +01:00
91bf2c1e2a Updated travis to pull submodules 2018-03-21 14:30:26 +01:00
da3df383ed Update gitmodule torrent_search url to be https 2018-03-21 14:29:51 +01:00
9816b978d3 Updated demo on readme 2018-03-21 12:13:57 +01:00
0581813ee3 Merge pull request #92 from KevinMidboe/api_filterBug
Fixes api not filtering requests/all query when filtering
2018-03-20 13:17:17 +01:00
edf1de223e When filtering the request on status the sql query for the db did not sort DESC. 2018-03-20 13:11:26 +01:00
4 changed files with 14 additions and 18 deletions

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "torrent_search"] [submodule "torrent_search"]
path = torrent_search path = torrent_search
url = git@github.com:KevinMidboe/torrent_search.git url = https://github.com/KevinMidboe/torrent_search.git

View File

@@ -1,7 +1,7 @@
language: node_js language: node_js
node_js: '8.7.0' node_js: '8.7.0'
git: git:
submodules: false submodules: true
script: script:
yarn test yarn test
before_install: before_install:

View File

@@ -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) [![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)]() [![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 ## 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. 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.

View File

@@ -8,21 +8,17 @@ const plexRepository = new PlexRepository();
const cache = new Cache(); const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey')); const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
const MailTemplate = require('src/plex/mailTemplate');
const nodemailer = require('nodemailer');
class RequestRepository { class RequestRepository {
constructor(cache, database) { constructor(database) {
this.database = database || establishedDatabase; this.database = database || establishedDatabase;
this.queries = { this.queries = {
insertRequest: `INSERT INTO requests(id,title,year,poster_path,background_path,requested_by,ip,user_agent,type) insertRequest: `INSERT INTO requests(id,title,year,poster_path,background_path,requested_by,ip,user_agent,type)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
fetchRequestedItems: 'SELECT * FROM requests ORDER BY date DESC LIMIT 25 OFFSET ?*25-25', fetchRequestedItems: 'SELECT * FROM requests ORDER BY date DESC LIMIT 25 OFFSET ?*25-25',
fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ? DESC LIMIT 25 OFFSET ?*25-25', 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 ?', updateRequestedById: 'UPDATE requests SET status = ? WHERE id is ? AND type is ?',
checkIfIdRequested: 'SELECT * FROM requests 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 = { this.cacheTags = {
search: 'se', search: 'se',
@@ -51,10 +47,7 @@ class RequestRepository {
.then(() => this.database.get(this.queries.checkIfIdRequested, [tmdbMovie.id, tmdbMovie.type])) .then(() => this.database.get(this.queries.checkIfIdRequested, [tmdbMovie.id, tmdbMovie.type]))
.then((result, error) => { .then((result, error) => {
if (error) { throw new Error(error); } if (error) { throw new Error(error); }
let already_requested = false; tmdbMovie.requested = result ? true : false;
if (result) { already_requested = true; }
tmdbMovie.requested = already_requested;
return tmdbMovie; return tmdbMovie;
}); });
} }
@@ -85,13 +78,15 @@ class RequestRepository {
} }
userRequests(user) { userRequests(user) {
return Promise.resolve() return Promise.resolve()
.then(() => this.database.all(this.queries.userRequests, user.username)) .then(() => this.database.all(this.queries.userRequests, user.username))
.catch((error) => { .catch((error) => {
if (String(error).includes('no such column')) { throw new Error('Username not found'); } if (String(error).includes('no such column')) {
else { throw new Error('Unable to fetch your requests')} 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) { updateRequestedById(id, type, status) {