#1866: Support HTTPS urls
This commit is contained in:
@@ -12,7 +12,7 @@ module Downloads
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
def rewrite_html_pages(url, headers)
|
def rewrite_html_pages(url, headers)
|
||||||
if url =~ %r{^http://.+?\.deviantart\.com/art/}
|
if url =~ %r{^https?://.+?\.deviantart\.com/art/}
|
||||||
source = ::Sources::Strategies::DeviantArt.new(url)
|
source = ::Sources::Strategies::DeviantArt.new(url)
|
||||||
source.get
|
source.get
|
||||||
return [source.image_url, headers]
|
return [source.image_url, headers]
|
||||||
@@ -22,10 +22,10 @@ module Downloads
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rewrite_thumbnails(url, headers)
|
def rewrite_thumbnails(url, headers)
|
||||||
if url =~ %r{^(http://.+?\.deviantart\.net/.+?/)200H/}
|
if url =~ %r{^(https?://.+?\.deviantart\.net/.+?/)200H/}
|
||||||
match = $1
|
match = $1
|
||||||
url.sub!(match + "200H/", match)
|
url.sub!(match + "200H/", match)
|
||||||
elsif url =~ %r{^(http://.+?\.deviantart\.net/.+?/)PRE/}
|
elsif url =~ %r{^(https?://.+?\.deviantart\.net/.+?/)PRE/}
|
||||||
match = $1
|
match = $1
|
||||||
url.sub!(match + "PRE/", match)
|
url.sub!(match + "PRE/", match)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Downloads
|
|||||||
module Strategies
|
module Strategies
|
||||||
class Twitpic < Base
|
class Twitpic < Base
|
||||||
def rewrite(url, headers)
|
def rewrite(url, headers)
|
||||||
if url =~ %r{http://twitpic\.com} || url =~ %r{^http://d3j5vwomefv46c\.cloudfront\.net}
|
if url =~ %r{https?://twitpic\.com} || url =~ %r{^https?://d3j5vwomefv46c\.cloudfront\.net}
|
||||||
url, headers = rewrite_html_pages(url, headers)
|
url, headers = rewrite_html_pages(url, headers)
|
||||||
url, headers = rewrite_thumbnails(url, headers)
|
url, headers = rewrite_thumbnails(url, headers)
|
||||||
end
|
end
|
||||||
@@ -14,7 +14,7 @@ module Downloads
|
|||||||
def rewrite_html_pages(url, headers)
|
def rewrite_html_pages(url, headers)
|
||||||
# example: http://twitpic.com/cpprns
|
# example: http://twitpic.com/cpprns
|
||||||
|
|
||||||
if url =~ %r{http://twitpic\.com/([a-z0-9]+)$}
|
if url =~ %r{https?://twitpic\.com/([a-z0-9]+)$}
|
||||||
id = $1
|
id = $1
|
||||||
url = "http://twitpic.com/show/full/#{id}"
|
url = "http://twitpic.com/show/full/#{id}"
|
||||||
return [url, headers]
|
return [url, headers]
|
||||||
@@ -24,7 +24,7 @@ module Downloads
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rewrite_thumbnails(url, headers)
|
def rewrite_thumbnails(url, headers)
|
||||||
if url =~ %r{^http://d3j5vwomefv46c\.cloudfront\.net/photos/thumb/(\d+\..+)$}
|
if url =~ %r{^https?://d3j5vwomefv46c\.cloudfront\.net/photos/thumb/(\d+\..+)$}
|
||||||
match = $1
|
match = $1
|
||||||
url.sub!("/thumb/" + match, "/large/" + match)
|
url.sub!("/thumb/" + match, "/large/" + match)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ module Sources
|
|||||||
|
|
||||||
def normalized_url
|
def normalized_url
|
||||||
@normalized_url ||= begin
|
@normalized_url ||= begin
|
||||||
if url =~ %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]*_by_[a-z0-9_]+-d([a-z0-9]+)\.}i
|
if url =~ %r{\Ahttps?://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]*_by_[a-z0-9_]+-d([a-z0-9]+)\.}i
|
||||||
"http://fav.me/d#{$1}"
|
"http://fav.me/d#{$1}"
|
||||||
elsif url =~ %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-f0-9]+-d([a-z0-9]+)\.}i
|
elsif url =~ %r{\Ahttps?://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-f0-9]+-d([a-z0-9]+)\.}i
|
||||||
"http://fav.me/d#{$1}"
|
"http://fav.me/d#{$1}"
|
||||||
elsif url =~ %r{deviantart\.com/art/}
|
elsif url =~ %r{deviantart\.com/art/}
|
||||||
url
|
url
|
||||||
|
|||||||
@@ -279,15 +279,15 @@ class Post < ActiveRecord::Base
|
|||||||
when %r{\Ahttp://lohas\.nicoseiga\.jp/priv/(\d+)\?e=\d+&h=[a-f0-9]+}i, %r{\Ahttp://lohas\.nicoseiga\.jp/priv/[a-f0-9]+/\d+/(\d+)}i
|
when %r{\Ahttp://lohas\.nicoseiga\.jp/priv/(\d+)\?e=\d+&h=[a-f0-9]+}i, %r{\Ahttp://lohas\.nicoseiga\.jp/priv/[a-f0-9]+/\d+/(\d+)}i
|
||||||
"http://seiga.nicovideo.jp/seiga/im#{$1}"
|
"http://seiga.nicovideo.jp/seiga/im#{$1}"
|
||||||
|
|
||||||
when %r{\Ahttp://d3j5vwomefv46c\.cloudfront\.net/photos/large/(\d+)\.}i
|
when %r{\Ahttps?://d3j5vwomefv46c\.cloudfront\.net/photos/large/(\d+)\.}i
|
||||||
base_10_id = $1.to_i
|
base_10_id = $1.to_i
|
||||||
base_36_id = base_10_id.to_s(36)
|
base_36_id = base_10_id.to_s(36)
|
||||||
"http://twitpic.com/#{base_36_id}"
|
"http://twitpic.com/#{base_36_id}"
|
||||||
|
|
||||||
when %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]*_by_([a-z0-9_]+)-d([a-z0-9]+)\.}i
|
when %r{\Ahttps?://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]*_by_([a-z0-9_]+)-d([a-z0-9]+)\.}i
|
||||||
"http://#{$1}.deviantart.com/gallery/#/d#{$2}"
|
"http://#{$1}.deviantart.com/gallery/#/d#{$2}"
|
||||||
|
|
||||||
when %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-f0-9]+-d([a-z0-9]+)\.}i
|
when %r{\Ahttps?://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-f0-9]+-d([a-z0-9]+)\.}i
|
||||||
"http://deviantart.com/gallery/#/d#{$1}"
|
"http://deviantart.com/gallery/#/d#{$1}"
|
||||||
|
|
||||||
when %r{\Ahttp://www\.karabako\.net/images(?:ub)?/karabako_(\d+)(?:_\d+)?\.}i
|
when %r{\Ahttp://www\.karabako\.net/images(?:ub)?/karabako_(\d+)(?:_\d+)?\.}i
|
||||||
@@ -296,7 +296,7 @@ class Post < ActiveRecord::Base
|
|||||||
when %r{\Ahttp://p\.twpl\.jp/show/orig/([a-z0-9]+)}i
|
when %r{\Ahttp://p\.twpl\.jp/show/orig/([a-z0-9]+)}i
|
||||||
"http://p.twipple.jp/#{$1}"
|
"http://p.twipple.jp/#{$1}"
|
||||||
|
|
||||||
when %r{\Ahttp://pictures\.hentai-foundry\.com//[^/]/([^/]+)/(\d+)\.}i
|
when %r{\Ahttps?://pictures\.hentai-foundry\.com//[^/]/([^/]+)/(\d+)\.}i
|
||||||
"http://www.hentai-foundry.com/pictures/user/#{$1}/#{$2}"
|
"http://www.hentai-foundry.com/pictures/user/#{$1}/#{$2}"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user