31 lines
825 B
JavaScript
31 lines
825 B
JavaScript
'use strict';
|
|
|
|
const fetch = require('node-fetch');
|
|
const cheerio = require('cheerio');
|
|
|
|
async function eroshareItem(host, post) {
|
|
const res = await fetch(`https://web.archive.org/web/20170630040157im_/https://eroshare.com/i/${host.id}`);
|
|
if (!res.ok) {
|
|
throw new Error(`Unable to recover Eroshare item '${host.id}' :(`);
|
|
}
|
|
|
|
const html = await res.text();
|
|
|
|
const $ = cheerio.load(html);
|
|
const videoElement = $('source[data-default="true"]');
|
|
|
|
return {
|
|
album: null,
|
|
items: [{
|
|
id: host.id,
|
|
url: videoElement.attr('src'),
|
|
title: post ? post.title : null,
|
|
type: videoElement.attr('type'),
|
|
datetime: post ? post.datetime : null,
|
|
original: post || null,
|
|
}],
|
|
};
|
|
}
|
|
|
|
module.exports = eroshareItem;
|