Compare commits
	
		
			24 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 71e9a5a46e | |||
| fce6dc7658 | |||
| baff59181c | |||
| 490d015f80 | |||
| f1cc2c4ebe | |||
| 2f4421d9e0 | |||
| 92cc094787 | |||
| f30b46c384 | |||
| d9f679603a | |||
| 64bd9d1e14 | |||
| 721826d454 | |||
| 242fe3515c | |||
| ccf40d2161 | |||
| 832b8ba539 | |||
|  | 0477e49eca | ||
| 451b67630a | |||
| 096bbdf085 | |||
| e914e4ab45 | |||
| c1461e1f41 | |||
| 91bf2c1e2a | |||
| da3df383ed | |||
| 9816b978d3 | |||
| 0581813ee3 | |||
| edf1de223e | 
							
								
								
									
										2
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -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 | ||||||
|   | |||||||
| @@ -1,9 +1,10 @@ | |||||||
| 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 | ||||||
|  |    - yarn coverage  | ||||||
| before_install: | before_install: | ||||||
|    - cd seasoned_api |    - cd seasoned_api | ||||||
| before_script: yarn | before_script: yarn | ||||||
|   | |||||||
| @@ -1,9 +1,12 @@ | |||||||
| # 🌶 seasonedShows | # 🌶 seasonedShows | ||||||
| [](https://travis-ci.org/KevinMidboe/seasonedShows) | [](https://travis-ci.org/KevinMidboe/seasonedShows) | ||||||
|  | [](https://coveralls.io/github/KevinMidboe/seasonedShows?branch=coverage) | ||||||
|  | [](https://www.versioneye.com/user/projects/5ac541370fb24f4489396e02) | ||||||
| [](https://snyk.io/test/github/KevinMidboe/seasonedShows?targetFile=seasoned_api/package.json) | [](https://snyk.io/test/github/KevinMidboe/seasonedShows?targetFile=seasoned_api/package.json) | ||||||
| []() | [](https://opensource.org/licenses/MIT) | ||||||
|  |  | ||||||
| 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.  | ||||||
|   | |||||||
| @@ -61,7 +61,7 @@ class strayEpisode(object): | |||||||
| 		return hashlib.md5("b'{}'".format(self.parent).encode()).hexdigest()[:8] | 		return hashlib.md5("b'{}'".format(self.parent).encode()).hexdigest()[:8] | ||||||
|  |  | ||||||
| 	def findSeriesName(self): | 	def findSeriesName(self): | ||||||
| 		find = re.compile("^[a-zA-Z. ]*") | 		find = re.compile("^[a-zA-Z0-9. ]*") | ||||||
| 		m = re.match(find, self.parent) | 		m = re.match(find, self.parent) | ||||||
| 		if m: | 		if m: | ||||||
| 			name, hit = process.extractOne(m.group(0), getShowNames().keys()) | 			name, hit = process.extractOne(m.group(0), getShowNames().keys()) | ||||||
|   | |||||||
| @@ -1,38 +1,42 @@ | |||||||
| { | { | ||||||
|     "name": "seasoned-api", |   "name": "seasoned-api", | ||||||
|     "main": "webserver/server.js", |   "description": "Packages needed to build and commands to run seasoned api node server.", | ||||||
|     "scripts": { |   "license": { | ||||||
|         "start": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. node src/webserver/server.js", |     "type": "MIT", | ||||||
|         "test": "cross-env SEASONED_CONFIG=conf/test.json NODE_PATH=. mocha --recursive test", |     "url": "https://www.opensource.org/licenses/mit-license.php" | ||||||
|         "coverage": "cross-env SEASONED_CONFIG=conf/test.json NODE_PATH=. istanbul cover -x script/autogenerate-documentation.js --include-all-sources --dir test/.coverage node_modules/mocha/bin/_mocha --recursive test/**/* -- --report lcovonly && cat test/.coverage/lcov.info | coveralls && rm -rf test/.coverage", |   }, | ||||||
|         "lint": "./node_modules/.bin/eslint src/" |   "main": "webserver/server.js", | ||||||
|     }, |   "scripts": { | ||||||
|     "dependencies": { |     "start": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. node src/webserver/server.js", | ||||||
|         "bcrypt-nodejs": "^0.0.3", |     "test": "cross-env SEASONED_CONFIG=conf/test.json NODE_PATH=. mocha --recursive test", | ||||||
|         "blanket": "^1.2.3", |     "coverage": "cross-env SEASONED_CONFIG=conf/test.json NODE_PATH=. nyc mocha --recursive test && nyc report --reporter=text-lcov | coveralls", | ||||||
|         "body-parser": "~1.0.1", |     "lint": "./node_modules/.bin/eslint src/" | ||||||
|         "codecov": "^3.0.0", |   }, | ||||||
|         "cross-env": "^3.1.3", |   "dependencies": { | ||||||
|         "express": "~4.11.0", |     "bcrypt-nodejs": "^0.0.3", | ||||||
|         "jsonwebtoken": "^8.0.1", |     "body-parser": "~1.18.2", | ||||||
|         "mocha-lcov-reporter": "^1.3.0", |     "cross-env": "~5.1.4", | ||||||
|         "mongoose": "^3.6.13", |     "express": "~4.16.0", | ||||||
|         "moviedb": "^0.2.10", |     "jsonwebtoken": "^8.0.1", | ||||||
|         "node-cache": "^4.1.1", |     "mongoose": "~5.0.11", | ||||||
|         "nodemailer": "^4.0.1", |     "moviedb": "^0.2.10", | ||||||
|         "python-shell": "^0.4.0", |     "node-cache": "^4.1.1", | ||||||
|         "raven": "^2.2.1", |     "python-shell": "^0.5.0", | ||||||
|         "request": "^2.81.0", |     "request": "^2.85.0", | ||||||
|         "request-promise": "^4.2", |     "request-promise": "^4.2", | ||||||
|         "sqlite3": "3.1.13" |     "sqlite3": "4.0.0" | ||||||
|     }, |   }, | ||||||
|     "devDependencies": { |   "devDependencies": { | ||||||
|         "eslint": "^4.9.0", |     "coveralls": "^3.0.0", | ||||||
|         "eslint-config-airbnb-base": "^12.1.0", |     "eslint": "^4.9.0", | ||||||
|         "eslint-plugin-import": "^2.8.0", |     "eslint-config-airbnb-base": "^12.1.0", | ||||||
|         "istanbul": "^0.4.5", |     "eslint-plugin-import": "^2.8.0", | ||||||
|         "mocha": "^5.0.4", |     "istanbul": "^0.4.5", | ||||||
|         "supertest": "^2.0.1", |     "mocha": "^5.0.4", | ||||||
|         "supertest-as-promised": "^4.0.1" |     "mocha-lcov-reporter": "^1.3.0", | ||||||
|     } |     "nyc": "^11.6.0", | ||||||
|  |     "raven": "^2.4.2", | ||||||
|  |     "supertest": "^3.0.0", | ||||||
|  |     "supertest-as-promised": "^4.0.1" | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user