2018-04-18 23:47:09 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const config = require('config');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
function eroshare(post) {
|
|
|
|
return fetch(`https://web.archive.org/web/20170630040157im_/https://eroshare.com/${post.host.id}`).then(res => {
|
|
|
|
if(res.ok) {
|
|
|
|
return res.text()
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.reject(`Unable to recover Eroshare video '${post.host.id}' :(`);
|
|
|
|
}).then(res => {
|
2018-04-20 00:23:02 +00:00
|
|
|
const data = JSON.parse(res.match(/var album = .*/)[0].slice(12, -1));
|
2018-04-18 23:47:09 +00:00
|
|
|
|
|
|
|
return {
|
2018-04-20 00:23:02 +00:00
|
|
|
album: {
|
|
|
|
id: data.slug,
|
|
|
|
title: data.title,
|
|
|
|
datetime: new Date(data.created_at)
|
|
|
|
},
|
|
|
|
items: data.items.map(item => {
|
|
|
|
return {
|
|
|
|
id: item.slug,
|
|
|
|
url: item.type === 'Image' ? item.url_full_protocol : item.url_mp4,
|
|
|
|
title: data.title,
|
|
|
|
description: item.description,
|
|
|
|
type: item.type === 'Image' ? 'image/jpeg' : 'video/mp4',
|
|
|
|
datetime: new Date(data.created_at),
|
|
|
|
width: data.width,
|
|
|
|
height: data.height,
|
|
|
|
original: item
|
|
|
|
};
|
|
|
|
})
|
2018-04-18 23:47:09 +00:00
|
|
|
};
|
|
|
|
}).catch(error => {
|
|
|
|
console.log('\x1b[33m%s\x1b[0m', error);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = eroshare;
|