Merge pull request #31 from KevinMidboe/fix/seasonedApiSearch
Fix/seasoned api search
This commit is contained in:
		| @@ -2,7 +2,10 @@ const Movie = require('src/media_classes/movie'); | |||||||
| const Show = require('src/media_classes/show'); | const Show = require('src/media_classes/show'); | ||||||
|  |  | ||||||
| function convertTmdbToSeasoned(tmdbObject, strictType=undefined) { | function convertTmdbToSeasoned(tmdbObject, strictType=undefined) { | ||||||
| 	const mediaType = strictType || tmdbObject.media_type; | 	if (strictType === undefined) | ||||||
|  | 		var mediaType = tmdbObject.media_type; | ||||||
|  | 	else | ||||||
|  | 		var mediaType = strictType;	 | ||||||
|  |  | ||||||
| 	// There are many diff types of content, we only want to look at movies and tv shows | 	// There are many diff types of content, we only want to look at movies and tv shows | ||||||
| 	if (mediaType === 'movie') { | 	if (mediaType === 'movie') { | ||||||
| @@ -47,4 +50,5 @@ function convertTmdbToSeasoned(tmdbObject, strictType=undefined) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| module.exports = convertTmdbToSeasoned; | module.exports = convertTmdbToSeasoned; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,7 +31,12 @@ class TMDB { | |||||||
|  |  | ||||||
| 		 		// Here we convert the filtered result from the tmdb api to seaonsed objects | 		 		// Here we convert the filtered result from the tmdb api to seaonsed objects | ||||||
| 		 		let seasonedItems = filteredTmdbItems.map((tmdbItem) => { | 		 		let seasonedItems = filteredTmdbItems.map((tmdbItem) => { | ||||||
| 		 			return convertTmdbToSeasoned(tmdbItem); | 					if (type === 'movie') | ||||||
|  | 						return convertTmdbToSeasoned(tmdbItem, 'movie'); | ||||||
|  | 					else if (type === 'show') | ||||||
|  | 						return convertTmdbToSeaosned(tmdbItem, 'show'); | ||||||
|  | 					else | ||||||
|  | 		 				return convertTmdbToSeasoned(tmdbItem); | ||||||
| 		 		}); | 		 		}); | ||||||
| 		 		 | 		 		 | ||||||
| 		 		// TODO add page number if results are larger than 20 | 		 		// TODO add page number if results are larger than 20 | ||||||
| @@ -294,4 +299,4 @@ class TMDB { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| module.exports = TMDB; | module.exports = TMDB; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user