honestbleeps / Reddit-Enhancement-Suite

Reddit Enhancement Suite
http://redditenhancementsuite.com
GNU General Public License v3.0
4.17k stars 878 forks source link

Support for Derpibooru Media Host #2527

Closed Ajedi32 closed 8 years ago

Ajedi32 commented 8 years ago

I've started frequenting /r/mylittlepony recently, and one of the more popular image hosts there (and on all the other MLP subs) is Derpibooru.

I'd like to add support for that site to RES's image expand feature, but I want to make sure a PR for that would be welcome before I start working on it. Derpibooru has an easy-to-use API, and I've already located the place in RES where new media hosts are placed, so I'm pretty confident this wouldn't be too difficult to implement, just give me the go ahead and I'll get to work.

erikdesjardins commented 8 years ago

I don't see any reason it wouldn't be welcome.

There is one issue you'll run into: they don't seem to send CORS headers, so you'll need to request optional permissions for Chrome. Right now, the code to do this is a bit horrifying (it should - and will, eventually - be 1 line), though you can pretty much copy most of that.

Ajedi32 commented 8 years ago

@erikdesjardins They don't? I thought I checked...

Yeah, Chrome is showing access-control-allow-origin:* set on https://derpiboo.ru/1025639.json so it shouldn't be a problem.

erikdesjardins commented 8 years ago

Huh, it seems like curl was lying to me...or I'm just blind at reading the headers. In that case - yeah it'll be easy.

jewel-andraia commented 8 years ago

https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/master/lib/modules/hosts/example.js

:+1:

Ajedi32 commented 8 years ago

Quick question: I noticed that some of the existing media host modules like Photobucket seem to include code specifically for handling the case where the user links the image in question directly. (E.g. not just the page the image is on.) Given that RES already handles direct image links, is that sort of code strictly necessary?

Probably won't matter in my case since Derpibooru seems to host its images on a separate domain from the main site, but still I'm kind of curious.

Ajedi32 commented 8 years ago

Another question, is the caption property still used by RES? The example file mentions it, but the strings I put in the caption property don't seem to be displayed anywhere.

erikdesjardins commented 8 years ago

Right, RES will handle images with normal image/video extensions on any domain. So it does seem like that Photobucket code is unnecessary - though it could be for handling links that don't have a file extension but are still direct links to images, à la Steam.

erikdesjardins commented 8 years ago

I'm not sure if caption is used; the properties that are used are a bit ad-hoc (and mostly undocumented) and they depend on the type, I think deviantArt and tumblr use all of the type: photo ones.

Ajedi32 commented 8 years ago

So apparently you also need to set imgCaptions on the link element in order to show image captions? https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/master/lib/modules/showImages.js#L866-L871 Is that intended?

Ajedi32 commented 8 years ago

Also, just noting this for myself for future reference: the Deviantart host currently silently swallows errors raised in its handleInfo method.

Ajedi32 commented 8 years ago

Yay, done! :tada:

That wasn't too hard...