Refactored media module to generalize avatar and poster storage into photo storage.

This commit is contained in:
2019-12-13 03:28:52 +01:00
parent 20011a74e8
commit 77307d2d13
7 changed files with 183 additions and 142 deletions

View File

@@ -204,6 +204,21 @@ async function scrapeScene(html, url, site) {
};
}
function scrapeMovie(html, url, site) {
const { document } = new JSDOM(html).window;
const movie = { url, site };
console.log(url);
movie.entryId = document.querySelector('.dvd_details_overview .rating_box').dataset.id;
movie.title = document.querySelector('.title_bar span').textContent;
movie.covers = Array.from(document.querySelectorAll('#dvd-cover-flip > a'), el => el.href);
movie.channel = document.querySelector('.update_date a').textContent;
movie.date = new Date();
return movie;
}
function scrapeProfile(html, url, actorName) {
const { document } = new JSDOM(html).window;
@@ -257,6 +272,12 @@ async function fetchScene(url, site) {
return scrapeScene(res.body.toString(), url, site);
}
async function fetchMovie(url, site) {
const res = await bhttp.get(url);
return scrapeMovie(res.body.toString(), url, site);
}
async function fetchProfile(actorName) {
const actorSlugA = actorName.toLowerCase().replace(/\s+/g, '-');
const actorSlugB = actorName.toLowerCase().replace(/\s+/g, '');
@@ -285,6 +306,7 @@ async function fetchProfile(actorName) {
module.exports = {
fetchLatest,
fetchMovie,
fetchProfile,
fetchUpcoming,
fetchScene,