Added new eroshare method source files.
This commit is contained in:
34
src/methods/eroshareItem.js
Normal file
34
src/methods/eroshareItem.js
Normal file
@@ -0,0 +1,34 @@
|
||||
'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;
|
||||
Reference in New Issue
Block a user