Skip to content

Instantly share code, notes, and snippets.

@nagyadam2092
Last active December 7, 2020 11:55
Show Gist options
  • Save nagyadam2092/3e0441f9c9b637d7aacb4033162cdd23 to your computer and use it in GitHub Desktop.
Save nagyadam2092/3e0441f9c9b637d7aacb4033162cdd23 to your computer and use it in GitHub Desktop.
var movieLists = [
{
name: "Instant Queue",
videos: [
{
id: 70111470,
title: "Die Hard",
boxarts: [
{
width: 150,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/DieHard150.jpg"
},
{
width: 200,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/DieHard200.jpg"
}
],
url: "http://api.netflix.com/catalog/titles/movies/70111470",
rating: 4.0,
bookmark: []
},
{
id: 654356453,
title: "Bad Boys",
boxarts: [
{
width: 200,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/BadBoys200.jpg"
},
{
width: 150,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/BadBoys150.jpg"
}
],
url: "http://api.netflix.com/catalog/titles/movies/70111470",
rating: 5.0,
bookmark: [
{
id: 432534,
time: 65876586
}
]
}
]
},
{
name: "New Releases",
videos: [
{
id: 65432445,
title: "The Chamber",
boxarts: [
{
width: 150,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/TheChamber150.jpg"
},
{
width: 200,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/TheChamber200.jpg"
}
],
url: "http://api.netflix.com/catalog/titles/movies/70111470",
rating: 4.0,
bookmark: []
},
{
id: 675465,
title: "Fracture",
boxarts: [
{
width: 200,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/Fracture200.jpg"
},
{
width: 150,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/Fracture150.jpg"
},
{
width: 300,
height: 200,
url: "http://cdn-0.nflximg.com/images/2891/Fracture300.jpg"
}
],
url: "http://api.netflix.com/catalog/titles/movies/70111470",
rating: 5.0,
bookmark: [
{
id: 432534,
time: 65876586
}
]
}
]
}
];
var result = movieLists.flatMap(function(movieList) {
return movieList.videos.flatMap(function(video) {
return video.boxarts
.filter(function(boxart) {
return boxart.width === 150 && boxart.height === 200;
})
.map(function(boxart) {
return {
id: video.id,
title: video.title,
boxart: boxart.url
};
});
});
});
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment