Added latest and scene scrapers to BAM Visions.
This commit is contained in:
parent
37e188a0df
commit
25795e2cce
|
@ -498,7 +498,7 @@ const sites = [
|
||||||
{
|
{
|
||||||
slug: 'bamvisions',
|
slug: 'bamvisions',
|
||||||
name: 'BAM Visions',
|
name: 'BAM Visions',
|
||||||
url: 'https://www.bamvisions.com',
|
url: 'https://tour.bamvisions.com',
|
||||||
network: 'bamvisions',
|
network: 'bamvisions',
|
||||||
},
|
},
|
||||||
// BANG
|
// BANG
|
||||||
|
|
|
@ -1,26 +1,81 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { geta } = require('../utils/qu');
|
const { get, geta, formatDate } = require('../utils/qu');
|
||||||
|
const slugify = require('../utils/slugify');
|
||||||
|
|
||||||
function scrapeLatest(scenes, _site) {
|
function scrapeLatest(scenes, site) {
|
||||||
return scenes.map(( qu ) => {
|
return scenes.map(({ qu }) => {
|
||||||
const release = {};
|
const release = {};
|
||||||
|
|
||||||
release.title = qu.q('h3 a', true);
|
release.title = qu.q('h3 a', true);
|
||||||
release.url = qu.url('h3 a');
|
release.url = qu.url('h3 a');
|
||||||
|
|
||||||
console.log(release);
|
release.date = qu.date('.item-meta li', 'MMMM D, YYYY', /\w+ \d{1,2}, \d{4}/);
|
||||||
|
release.duration = qu.dur('.item-meta li:nth-child(2)');
|
||||||
|
release.description = qu.q('.description', true);
|
||||||
|
|
||||||
|
release.actors = qu.all('a[href*="/models"]', true);
|
||||||
|
[release.poster, ...release.photos] = qu.all('.item-thumbs img')
|
||||||
|
.map(source => [
|
||||||
|
source.getAttribute('src0_3x'),
|
||||||
|
source.getAttribute('src0_2x'),
|
||||||
|
source.getAttribute('src0_1x'),
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(fallback => (/^http/.test(fallback) ? fallback : `${site.url}${fallback}`)));
|
||||||
|
|
||||||
|
release.entryId = `${formatDate(release.date, 'YYYY-MM-DD')}-${slugify(release.title)}`;
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrapeScene({ html, qu }, url, site) {
|
||||||
|
const release = { url };
|
||||||
|
|
||||||
|
release.title = qu.q('.item-episode h4 a', true);
|
||||||
|
release.date = qu.date('.item-meta li', 'MMMM D, YYYY', /\w+ \d{1,2}, \d{4}/);
|
||||||
|
release.duration = qu.dur('.item-meta li:nth-child(2)');
|
||||||
|
release.description = qu.q('.description', true);
|
||||||
|
|
||||||
|
release.actors = qu.all('.item-episode a[href*="/models"]', true);
|
||||||
|
|
||||||
|
const posterPath = html.match(/poster="(.*.jpg)"/)?.[1];
|
||||||
|
const trailerPath = html.match(/video src="(.*.mp4)"/)?.[1];
|
||||||
|
|
||||||
|
if (posterPath) {
|
||||||
|
const poster = /^http/.test(posterPath) ? posterPath : `${site.url}${posterPath}`;
|
||||||
|
release.poster = [
|
||||||
|
poster.replace('-1x', '-3x'),
|
||||||
|
poster.replace('-1x', '-2x'),
|
||||||
|
poster,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trailerPath) {
|
||||||
|
const trailer = /^http/.test(trailerPath) ? trailerPath : `${site.url}${trailerPath}`;
|
||||||
|
release.trailer = { src: trailer };
|
||||||
|
}
|
||||||
|
|
||||||
|
release.entryId = `${formatDate(release.date, 'YYYY-MM-DD')}-${slugify(release.title)}`;
|
||||||
|
|
||||||
|
return release;
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchLatest(site, page = 1) {
|
async function fetchLatest(site, page = 1) {
|
||||||
const url = `https://tour.bamvisions.com/categories/movies/${page}/latest/`;
|
const url = `${site.url}/categories/movies/${page}/latest/`;
|
||||||
const res = geta(url, '.item-episode');
|
const res = await geta(url, '.item-episode');
|
||||||
|
|
||||||
return res.ok ? scrapeLatest(res.items, site) : res.status;
|
return res.ok ? scrapeLatest(res.items, site) : res.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchScene(url, site) {
|
||||||
|
const res = await get(url);
|
||||||
|
|
||||||
|
return res.ok ? scrapeScene(res.item, url, site) : res.status;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
fetchLatest,
|
fetchLatest,
|
||||||
|
fetchScene,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue