#1866: support e-hentai source redirection

* hopefully prevents error pages when the url during upload expires
* makes use of file sha-1 hash and filename in the url to query the e-hentai search page
* the file hash by itself is enough to generate a result but the filename is also added for completeness (the page displays the filename being searched)
* ip addresses, port numbers, and unix timestamps validation can also be added later
* a better solution maybe is to get the gallery ids and gallery tokens directly
This commit is contained in:
ghostrigger
2014-06-22 23:18:51 +08:00
parent 4e902d541a
commit e448e489e2

View File

@@ -331,6 +331,11 @@ class Post < ActiveRecord::Base
subdomain = $1
filename = $2
"http://#{subdomain}.wikia.com/wiki/File:#{filename}"
when %r{\Ahttp://(?:(?:\d{1,3}\.){1,3}\d{1,3}):(?:\d{1,5})/h/([a-f0-9]{40})-(?:\d+-){3}(?:png|gif|(?:jpe?g?))/keystamp=\d+-[a-f0-9]{10}/([^/]+)}i
sha1hash = $1
filename = $2
"http://g.e-hentai.org/?f_shash=#{sha1hash}&fs_from=#{filename}"
else
source