मैं tmdb_popularity को प्रिंट करने में सक्षम हूं लेकिन प्रदाता (नेटफ्लिक्स) के साथ मैप/प्रिंट आउट करने में असमर्थ हूं। मेरा मानना है कि मैं {} के माध्यम से गलत तरीके से मैपिंग कर रहा हूं। Movie.offers[0].provider_id भी विफल रहा।
साथ ही, उदाहरण के लिए 'provider_type:tmdb:score'>8 द्वारा केवल स्कोरिंग को मैप करने का कोई तरीका है? चूंकि tmdb: स्कोर ऑब्जेक्ट है। कुंजी के बजाय मूल्य क्या यह संभव नहीं है?
धन्यवाद।
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){
if(movie.offers.provider_id == netflixId){
print_result("search", searchResult)
}
})
searchResult.items.map(function(movie){
if(movie.tmdb_popularity > 20){
print_result("search",searchResult)
}
})
}) ();
JSON डेटा कैसा दिखता है (जस्टवॉच एपीआई)
{
"total_results": 27468,
"items": [
{
"jw_entity_id": "ts80908",
"id": 80908,
"title": "A Very English Scandal",
"tmdb_popularity": 3.422,
"object_type": "show",
"offers": [
{
"type": "aggregated",
"monetization_type": "flatrate",
"provider_id": 9,
"currency": "USD",
"urls": {
"standard_web": "https://www.amazon.com/gp/product/B07DX9DKP5?camp=1789&creativeASIN=B07DX9DKP5&ie=UTF8&linkCode=xm2&tag=justwatch09-20",
"deeplink_android_tv": "intent://watch.amazon.com/watch?asin=B07DX9DKP5&time=0&territory=US#Intent;package=com.amazon.amazonvideo.livingroom;scheme=https;end"
},
"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",
"urls": {
"standard_web": "https://www.amazon.com/gp/product/B07DX9DKP5?camp=1789&creativeASIN=B07DX9DKP5&ie=UTF8&linkCode=xm2&tag=justwatch09-20",
"deeplink_android_tv": "intent://watch.amazon.com/watch?asin=B07DX9DKP5&time=0&territory=US#Intent;package=com.amazon.amazonvideo.livingroom;scheme=https;end"
},
"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"
},
{
"type": "aggregated",
"monetization_type": "flatrate",
"provider_id": 9,
"currency": "USD",
"urls": {
"standard_web": "https://www.amazon.com/gp/product/B07DX8CSSQ?camp=1789&creativeASIN=B07DX8CSSQ&ie=UTF8&linkCode=xm2&tag=justwatch09-20",
"deeplink_android_tv": "intent://watch.amazon.com/watch?asin=B07DX8CSSQ&time=0&territory=US#Intent;package=com.amazon.amazonvideo.livingroom;scheme=https;end",
"deeplink_fire_tv": "intent://com.amazon.tv.launcher/detail?provider=aiv&providerId=B07DX8CSSQ#Intent;package=com.amazon.tv.launcher;scheme=amzn;end",
"deeplink_tvos": "aiv://aiv/watch?asin=B07DX8CSSQ&territory=US&time=auto"
},
"subtitle_languages": [
"en"
],
"presentation_type": "4k",
"element_count": 1,
"new_element_count": 1,
"date_provider_id": "2019-09-06_9",
"date_created": "2019-09-06"
}
],
"scoring": [
{
"provider_type": "tmdb:score",
"value": 8.1
},
{
"provider_type": "imdb:score",
"value": 7.8
},
{
"provider_type": "tmdb:popularity",
"value": 3.422
}
]
},
{
"jw_entity_id": "tm205151",
"id": 205151,
"title": "Alpha",
"full_path": "/us/movie/alpha-2015",
"full_paths": {
"MOVIE_DETAIL_OVERVIEW": "/us/movie/alpha-2015"
},
"poster": "/poster/139203407/{profile}",
"original_release_year": 2015,
"tmdb_popularity": 0.878,
"object_type": "movie",
"offers": [
{
"monetization_type": "flatrate",
"provider_id": 25,
"urls": {
"standard_web": "https://www.fandor.com/films/alpha"
},
"presentation_type": "hd",
"date_provider_id": "2016-06-13_25",
"date_created": "2016-06-13"
},
{
"monetization_type": "flatrate",
"provider_id": 25,
"urls": {
"standard_web": "https://www.fandor.com/films/alpha"
},
"presentation_type": "sd",
"date_provider_id": "2016-06-13_25",
"date_created": "2016-06-13"
},
{
"monetization_type": "flatrate",
"provider_id": 199,
"currency": "USD",
"urls": {
"standard_web": "https://www.amazon.com/gp/product/B01M7O3UQU?camp=1789&creativeASIN=B01M7O3UQU&ie=UTF8&linkCode=xm2&tag=justwatch09-20",
"deeplink_android_tv": "intent://watch.amazon.com/watch?asin=B01M7O3UQU&time=0&territory=US#Intent;package=com.amazon.amazonvideo.livingroom;scheme=https;end",
"deeplink_fire_tv": "intent://com.amazon.tv.launcher/detail?provider=aiv&providerId=B01M7O3UQU#Intent;package=com.amazon.tv.launcher;scheme=amzn;end",
"deeplink_tvos": "aiv://aiv/watch?asin=B01M7O3UQU&territory=US&time=auto"
},
"presentation_type": "sd",
"date_provider_id": "2019-06-19_199",
"date_created": "2019-06-19"
}
],
"scoring": [
{
"provider_type": "tmdb:popularity",
"value": 0.878
},
{
"provider_type": "tmdb:id",
"value": 333465
},
{
"provider_type": "tmdb:score",
"value": 7
},
{
"provider_type": "imdb:score",
"value": 7.7
}
]
},
....
0
YLO
16 मार्च 2020, 08:21
2 जवाब
यहां इसे आजमाएं
searchResult.items.map(function(movie){
movie.offers.forEach(offer => {
if(offer.provider_id == netflixId){
print_result("search", searchResult)
}
})
})
0
Biswa Bhusan
16 मार्च 2020, 08:52
map
के बजाय यहां forEach
बेहतर है क्योंकि आप मैप फ़ंक्शन में वापस नहीं आ रहे हैं। ऑफ़र खोजने के लिए खोज फ़ंक्शन का उपयोग करें।
searchResult.items.forEach(function(movie) {
const offer = movie.offers.find(offer => offer.provider_id == netflixId);
if(offer){
print_result("search", movie)
print_result("offer", offer)
}
})
0
Siva K V
16 मार्च 2020, 09:18
movie.offers
एक सरणी है, इसे एक और लूप की आवश्यकता होगी जैसेsearchResult.items
के लिए उपयोग किया जाता है.map()
का उपयोग एक नई सरणी को वापस करने के लिए किया जाता है जिसका उदाहरण कोड में उपयोग नहीं किया जा रहा है, आप इसके बजाय.forEach()
का उपयोग कर सकते हैं।