35 lines
981 B
JavaScript
35 lines
981 B
JavaScript
'use strict';
|
|
|
|
const util = require('util');
|
|
const config = require('config');
|
|
const fetch = require('node-fetch');
|
|
const cheerio = require('cheerio');
|
|
const mime = require('mime-types');
|
|
|
|
function eroshareItem(post) {
|
|
return fetch(`https://web.archive.org/web/20170630040157im_/https://eroshare.com/i/${post.host.id}`).then(res => {
|
|
if(res.ok) {
|
|
return res.text();
|
|
}
|
|
|
|
return Promise.reject(`Unable to recover Eroshare item '${post.host.id}' :(`);
|
|
}).then(res => {
|
|
const $ = cheerio.load(res);
|
|
const videoElement = $('source[data-default="true"]');
|
|
|
|
return {
|
|
album: null,
|
|
items: [{
|
|
id: post.host.id,
|
|
url: videoElement.attr('src'),
|
|
title: post.title,
|
|
type: videoElement.attr('type'),
|
|
datetime: post.datetime,
|
|
original: post
|
|
}]
|
|
};
|
|
});
|
|
};
|
|
|
|
module.exports = eroshareItem;
|