'use strict';

const bhttp = require('bhttp');

const { fetchLatest, fetchUpcoming, scrapeScene, fetchProfile } = require('./gamma');

async function fetchScene(url, site) {
    const res = await bhttp.get(url);

    const release = await scrapeScene(res.body.toString(), url, site);

    const siteDomain = release.$('meta[name="twitter:domain"]').attr('content') || 'allblackx.com'; // only AllBlackX has no twitter domain, no other useful hints available
    const siteSlug = siteDomain && siteDomain.split('.')[0].toLowerCase();
    // const siteUrl = siteDomain && `https://www.${siteDomain}`;

    release.channel = siteSlug;

    return release;
}

module.exports = {
    fetchLatest,
    fetchProfile,
    fetchUpcoming,
    fetchScene,
};
