From 6f21d41cd00c98c9467d93008af5df2275f2fa8a Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Mon, 14 May 2018 00:38:49 +0200 Subject: [PATCH] Added support for /i/ eroshare items. --- src/dissectLink.js | 6 +++++- src/methods/eroshare.js | 42 ----------------------------------------- src/methods/methods.js | 6 ++++-- 3 files changed, 9 insertions(+), 45 deletions(-) delete mode 100644 src/methods/eroshare.js diff --git a/src/dissectLink.js b/src/dissectLink.js index 9926599..37c99bb 100644 --- a/src/dissectLink.js +++ b/src/dissectLink.js @@ -39,9 +39,13 @@ const hosts = [{ label: 'gfycat', pattern: new urlPattern('http(s)\\://(:server.)gfycat.com/:id(.:ext)') }, { - method: 'eroshare', + method: 'eroshareAlbum', label: 'eroshare', pattern: new urlPattern('http(s)\\://eroshare.com/:id(#)(:query)') +}, { + method: 'eroshareItem', + label: 'eroshare', + pattern: new urlPattern('http(s)\\://eroshare.com/i/:id(#)(:query)') }]; module.exports = function dissectLink(url) { diff --git a/src/methods/eroshare.js b/src/methods/eroshare.js deleted file mode 100644 index 3649417..0000000 --- a/src/methods/eroshare.js +++ /dev/null @@ -1,42 +0,0 @@ - '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)); - const extract = config.library.album.extractSingleItem && data.items.length === 1; - - return { - album: extract ? null : { - id: data.slug, - title: data.title, - datetime: new Date(data.created_at) - }, - items: data.items.map(item => { - return { - extracted: extract, - 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 - }; - }) - }; - }); -}; - -module.exports = eroshare; diff --git a/src/methods/methods.js b/src/methods/methods.js index 3ec5033..bf111de 100644 --- a/src/methods/methods.js +++ b/src/methods/methods.js @@ -9,7 +9,8 @@ const imgurAlbum = require('./imgurAlbum.js'); const vidbleImage = require('./vidbleImage.js'); const vidbleAlbum = require('./vidbleAlbum.js'); const gfycat = require('./gfycat.js'); -const eroshare = require('./eroshare.js'); +const eroshareAlbum = require('./eroshareAlbum.js'); +const eroshareItem = require('./eroshareItem.js'); module.exports = { self, @@ -21,5 +22,6 @@ module.exports = { vidbleImage, vidbleAlbum, gfycat, - eroshare + eroshareAlbum, + eroshareItem };