40 lines
926 B
JavaScript
40 lines
926 B
JavaScript
'use strict';
|
|
|
|
const { fetchApiLatest, fetchApiUpcoming, fetchScene, fetchApiProfile } = require('./gamma');
|
|
|
|
function curateRelease(release, site) {
|
|
if (['bubblegumdungeon', 'ladygonzo'].includes(site.slug)) {
|
|
return {
|
|
...release,
|
|
title: release.title.split(/:|\|/)[1].trim(),
|
|
};
|
|
}
|
|
|
|
return release;
|
|
}
|
|
|
|
async function networkFetchScene(url, site, release) {
|
|
const scene = await fetchScene(url, site, release);
|
|
|
|
return curateRelease(scene, site);
|
|
}
|
|
|
|
async function fetchLatest(site, page = 1) {
|
|
const releases = await fetchApiLatest(site, page, false);
|
|
|
|
return releases.map(release => curateRelease(release, site));
|
|
}
|
|
|
|
async function fetchUpcoming(site, page = 1) {
|
|
const releases = await fetchApiUpcoming(site, page, false);
|
|
|
|
return releases.map(release => curateRelease(release, site));
|
|
}
|
|
|
|
module.exports = {
|
|
fetchLatest,
|
|
fetchProfile: fetchApiProfile,
|
|
fetchScene: networkFetchScene,
|
|
fetchUpcoming,
|
|
};
|