diff --git a/src/app.js b/src/app.js index 49f8b69..8a0dd97 100644 --- a/src/app.js +++ b/src/app.js @@ -76,6 +76,7 @@ function fetchSavePosts(userPosts, ep) { async function initApp() { try { + klsjdflkjs const userPosts = await getCompleteUserPosts(); const ep = new exiftool.ExiftoolProcess(exiftoolBin); @@ -87,7 +88,11 @@ async function initApp() { console.log(`[${format(new Date(), 'YYYY-MM-DD HH:mm:ss')}] Watch-mode enabled, checking again for new posts according to crontab '${config.fetch.watch.schedule}'.`); } } catch (error) { - console.log('\x1b[31m%s\x1b[0m', error.message); + if (args.debug) { + console.log('\x1b[31m%s\x1b[0m', error.stack); + } else { + console.log('\x1b[31m%s\x1b[0m', error.message); + } } return true; diff --git a/src/dissectLink.js b/src/dissectLink.js index cb12f58..b104e8d 100644 --- a/src/dissectLink.js +++ b/src/dissectLink.js @@ -1,74 +1,78 @@ 'use strict'; -const urlPattern = require('url-pattern'); +const UrlPattern = require('url-pattern'); const hosts = [{ method: 'self', label: 'self', - pattern: new urlPattern('http(s)\\://(www.)reddit.com/r/:subreddit/comments/:id/:uri/') + pattern: new UrlPattern('http(s)\\://(www.)reddit.com/r/:subreddit/comments/:id/:uri/'), }, { method: 'redditImage', label: 'reddit', - pattern: new urlPattern('http(s)\\://i.redd.it/:id.:ext') + pattern: new UrlPattern('http(s)\\://i.redd.it/:id.:ext'), }, { method: 'redditImage', label: 'reddit', - pattern: new urlPattern('http(s)\\://i.reddituploads.com/:id(?*)') + pattern: new UrlPattern('http(s)\\://i.reddituploads.com/:id(?*)'), }, { method: 'redditVideo', label: 'reddit', - pattern: new urlPattern('http(s)\\://v.redd.it/:id') + pattern: new UrlPattern('http(s)\\://v.redd.it/:id'), }, { method: 'imgurImage', label: 'imgur', - pattern: new urlPattern('http(s)\\://(:subdomain.)imgur.com/:id(.:ext)(?*)') + pattern: new UrlPattern('http(s)\\://(:subdomain.)imgur.com/:id_d(.:ext)(?*)'), +}, { + method: 'imgurImage', + label: 'imgur', + pattern: new UrlPattern('http(s)\\://(:subdomain.)imgur.com/:id(.:ext)(?*)'), }, { method: 'imgurAlbum', label: 'imgur', - pattern: new urlPattern('http(s)\\://(:subdomain.)imgur.com/:type/:id(#:focus)') + pattern: new UrlPattern('http(s)\\://(:subdomain.)imgur.com/:type/:id(#:focus)'), }, { method: 'vidbleImage', label: 'vidble', - pattern: new urlPattern('http(s)\\://(www.)vidble.com/(show/):id(.:ext)') + pattern: new UrlPattern('http(s)\\://(www.)vidble.com/(show/):id(.:ext)'), }, { method: 'vidbleVideo', label: 'vidble', - pattern: new urlPattern('http(s)\\://(www.)vidble.com/watch?v=:id') + pattern: new UrlPattern('http(s)\\://(www.)vidble.com/watch?v=:id'), }, { method: 'vidbleAlbum', label: 'vidble', - pattern: new urlPattern('http(s)\\://(www.)vidble.com/album/:id') + pattern: new UrlPattern('http(s)\\://(www.)vidble.com/album/:id'), }, { method: 'gfycat', label: 'gfycat', - pattern: new urlPattern('http(s)\\://(:server.)gfycat.com/:id(-size_restricted.gif)') + pattern: new UrlPattern('http(s)\\://(:server.)gfycat.com/:id(-size_restricted.gif)'), }, { method: 'gfycat', label: 'gfycat', - pattern: new urlPattern('http(s)\\://(:server.)gfycat.com/(gifs/detail/):id(.:ext)') + pattern: new UrlPattern('http(s)\\://(:server.)gfycat.com/(gifs/detail/):id(.:ext)'), }, { method: 'eroshareAlbum', label: 'eroshare', - pattern: new urlPattern('http(s)\\://eroshare.com/:id(#)(:query)') + pattern: new UrlPattern('http(s)\\://eroshare.com/:id(#)(:query)'), }, { method: 'eroshareItem', label: 'eroshare', - pattern: new urlPattern('http(s)\\://eroshare.com/i/:id(#)(:query)') + pattern: new UrlPattern('http(s)\\://eroshare.com/i/:id(#)(:query)'), }]; module.exports = function dissectLink(url) { return hosts.reduce((acc, host) => { - if(acc) { + if (acc) { return acc; } const match = host.pattern.match(url.replace(/(https?:\/\/)|(\/)+/g, '$1$2')); // remove double slashes - if(match) { + if (match) { return Object.assign(match, { - url: url, + url, method: host.method, - label: host.label + label: host.label, }); } diff --git a/src/methods/imgurAlbum.js b/src/methods/imgurAlbum.js index d0877b5..bd432d0 100644 --- a/src/methods/imgurAlbum.js +++ b/src/methods/imgurAlbum.js @@ -9,7 +9,7 @@ async function imgurAlbum(post) { const html = await res.text(); if (res.status !== 200) { - throw new Error(`Could not fetch info for imgur image '${post.host.id}': '${res.data.error}'`); + throw new Error(`Could not fetch info for imgur image '${post.host.id}': '${res.statusText}'`); } const dataString = html.replace(/\s+/g, ' ').match(/}}, item:(.*)}; var PREBID_TIMEOUT/)[1]; diff --git a/src/methods/imgurImage.js b/src/methods/imgurImage.js index 1442ccd..29227bc 100644 --- a/src/methods/imgurImage.js +++ b/src/methods/imgurImage.js @@ -7,7 +7,7 @@ async function imgurImage(post) { const html = await res.text(); if (res.status !== 200) { - throw new Error(`Could not fetch info for imgur image '${post.host.id}': '${res.data.error}'`); + throw new Error(`Could not fetch info for imgur image '${post.host.id}': '${res.statusText}'`); } const dataString = html.replace(/\s+/g, ' ').match(/}}, item:(.*)}; var PREBID_TIMEOUT/)[1];