77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
function curateActor(actor) {
|
|
const curatedActor = {
|
|
...actor,
|
|
origin: actor.originCountry && {
|
|
country: actor.originCountry,
|
|
},
|
|
};
|
|
|
|
if (actor.avatar) curatedActor.avatar = actor.avatar.media;
|
|
|
|
return curatedActor;
|
|
}
|
|
|
|
function curateRelease(release) {
|
|
const curatedRelease = {
|
|
...release,
|
|
actors: release.actors ? release.actors.map(({ actor }) => curateActor(actor)) : [],
|
|
poster: release.poster && release.poster.media,
|
|
tags: release.tags ? release.tags.map(({ tag }) => tag) : [],
|
|
network: release.site.network,
|
|
};
|
|
|
|
if (release.photos) curatedRelease.photos = release.photos.map(({ media }) => media);
|
|
if (release.trailer) curatedRelease.trailer = release.trailer.media;
|
|
|
|
return curatedRelease;
|
|
}
|
|
|
|
function curateSite(site, network) {
|
|
const curatedSite = {
|
|
id: site.id,
|
|
name: site.name,
|
|
slug: site.slug,
|
|
url: site.url,
|
|
};
|
|
|
|
if (site.releases) curatedSite.releases = site.releases.map(release => curateRelease(release));
|
|
if (site.network || network) curatedSite.network = site.network || network;
|
|
|
|
return curatedSite;
|
|
}
|
|
|
|
function curateNetwork(network) {
|
|
const curatedNetwork = {
|
|
id: network.id,
|
|
name: network.name,
|
|
slug: network.slug,
|
|
url: network.url,
|
|
};
|
|
|
|
if (network.sites) {
|
|
curatedNetwork.sites = network.sites.map(site => curateSite(site, curatedNetwork));
|
|
}
|
|
|
|
return curatedNetwork;
|
|
}
|
|
|
|
function curateTag(tag) {
|
|
const curatedTag = {
|
|
...tag,
|
|
};
|
|
|
|
if (tag.releases) curatedTag.releases = tag.releases.map(({ release }) => curateRelease(release));
|
|
if (tag.photos) curatedTag.photos = tag.photos.map(({ media }) => media);
|
|
if (tag.poster) curatedTag.poster = tag.poster.media;
|
|
|
|
return curatedTag;
|
|
}
|
|
|
|
export {
|
|
curateActor,
|
|
curateRelease,
|
|
curateSite,
|
|
curateNetwork,
|
|
curateTag,
|
|
};
|