2020-02-07 18:53:16 +00:00
|
|
|
'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;
|
|
|
|
}
|
|
|
|
|
2020-02-11 03:58:18 +00:00
|
|
|
async function networkFetchScene(url, site, release) {
|
|
|
|
const scene = await fetchScene(url, site, release);
|
2020-02-07 18:53:16 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
};
|