43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
'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 => {
|
|
const data = JSON.parse(res.match(/var album = .*/)[0].slice(12, -1));
|
|
|
|
return {
|
|
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
|
|
};
|
|
})
|
|
};
|
|
}).catch(error => {
|
|
console.log('\x1b[33m%s\x1b[0m', error);
|
|
});
|
|
};
|
|
|
|
module.exports = eroshare;
|