diff --git a/src/scrapers/bang.js b/src/scrapers/bang.js index df3a9b52..6ce81297 100644 --- a/src/scrapers/bang.js +++ b/src/scrapers/bang.js @@ -263,6 +263,71 @@ async function fetchLatest(site, page = 1) { return scrapeAll(res.body.hits.hits, site); } +async function fetchUpcoming(site, page = 1) { + const res = await http.post(`https://${clusterId}.us-east-1.aws.found.io/videos/video/_search`, { + size: 50, + from: (page - 1) * 50, + query: { + bool: { + must: [ + { + match: { + status: 'ok', + }, + }, + { + range: { + releaseDate: { + lte: 'now+7d', + }, + }, + }, + { + nested: { + path: 'series', + query: { + bool: { + must: [ + { + match: { + 'series.id': { + operator: 'AND', + query: site.parameters.siteId, + }, + }, + }, + ], + }, + }, + }, + }, + ], + must_not: [ + { + match: { + type: 'trailer', + }, + }, + ], + }, + }, + sort: [ + { + releaseDate: { + order: 'desc', + }, + }, + ], + }, { + encodeJSON: true, + headers: { + Authorization: `Basic ${authKey}`, + }, + }); + + return scrapeAll(res.body.hits.hits, site); +} + async function fetchScene(url) { const encodedId = new URL(url).pathname.split('/')[2]; const entryId = decodeId(encodedId); @@ -327,4 +392,5 @@ module.exports = { fetchLatest, fetchProfile, fetchScene, + fetchUpcoming, };