目前,我能够检索Netflix提供的节目列表。
但是我的分数过滤器没有返回我想要的。我想返回tmdb:score为8或更大的列表。由于数据结构将provider_type和value分开,因此我现在得到的得分都在8以上。
有没有办法做到这一点?如果可能,将其与我的Netflix提供程序功能结合使用,以返回tmdb:score为8或更高的Netflix节目?
谢谢。
Node JS文件
const JustWatch = require("justwatch-api")
const netflixId = 8;
function print_result (name, result) {
console.log(name+":");
console.log(JSON.stringify(result, null, 4));
console.log("\n\n\n\n");
}
(async function(){
var justwatch = new JustWatch();
var searchResult = await justwatch.search('a');
searchResult.items.map(function(movie){
movie.offers.forEach(offer => {
if(offer.provider_id === netflixId){
print_result("search", searchResult)
}
})
})
searchResult.items.map(function(movie){
movie.scoring.filter(score =>{
if(score.provider_type ==="tmdb:score" && score.value > 8) {
print_result("search", searchResult)
}
})
})
}) ();
数据结构
{
"total_results": 27476,
"items": [
{
"jw_entity_id": "ts80908",
"id": 80908,
"title": "A Very English Scandal",
"full_path": "/us/tv-show/a-very-english-scandal",
"full_paths": {
"SHOW_DETAIL_OVERVIEW": "/us/tv-show/a-very-english-scandal"
},
"poster": "/poster/60368458/{profile}",
"original_release_year": 2018,
"tmdb_popularity": 3.422,
"object_type": "show",
"offers": [
{
"type": "aggregated",
"monetization_type": "flatrate",
"provider_id": 9,
"currency": "USD",
"subtitle_languages": [
"en"
],
"presentation_type": "sd",
"element_count": 1,
"new_element_count": 1,
"date_provider_id": "2019-09-14_9",
"date_created": "2019-09-14"
},
{
"type": "aggregated",
"monetization_type": "flatrate",
"provider_id": 9,
"currency": "USD",
"subtitle_languages": [
"en"
],
"presentation_type": "hd",
"element_count": 1,
"new_element_count": 1,
"date_provider_id": "2019-09-14_9",
"date_created": "2019-09-14"
}
],
"scoring": [
{
"provider_type": "imdb:score",
"value": 7.8
},
{
"provider_type": "tmdb:popularity",
"value": 3.422
},
{
"provider_type": "tmdb:score",
"value": 8.1
}
]
},
{
"jw_entity_id": "tm205151",
"id": 205151,
"title": "Alpha",
"full_path": "/us/movie/alpha-2015",
"full_paths": {
"MOVIE_DETAIL_OVERVIEW": "/us/movie/alpha-2015"
},
....
据我了解,您想使用8或更高的tmdb:score过滤Netflix节目吗?那么我们可以只使用filter
来过滤项目吗?
searchResult.items.filter(function(movie){
var scorings = movie.scoring;
var filterScores =
scorings.filter(score => score.provider_type ==="tmdb:score" && score.value > 8);
return filterScores.length > 0;
})