#1866: Support HTTPS urls

This commit is contained in:
Toks
2014-05-15 23:35:57 -04:00
parent b3bab586d3
commit 5f70768962
4 changed files with 12 additions and 12 deletions

View File

@@ -12,7 +12,7 @@ module Downloads
protected
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.get
return [source.image_url, headers]
@@ -22,10 +22,10 @@ module Downloads
end
def rewrite_thumbnails(url, headers)
if url =~ %r{^(http://.+?\.deviantart\.net/.+?/)200H/}
if url =~ %r{^(https?://.+?\.deviantart\.net/.+?/)200H/}
match = $1
url.sub!(match + "200H/", match)
elsif url =~ %r{^(http://.+?\.deviantart\.net/.+?/)PRE/}
elsif url =~ %r{^(https?://.+?\.deviantart\.net/.+?/)PRE/}
match = $1
url.sub!(match + "PRE/", match)
end

View File

@@ -2,7 +2,7 @@ module Downloads
module Strategies
class Twitpic < Base
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_thumbnails(url, headers)
end
@@ -14,7 +14,7 @@ module Downloads
def rewrite_html_pages(url, headers)
# 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
url = "http://twitpic.com/show/full/#{id}"
return [url, headers]
@@ -24,7 +24,7 @@ module Downloads
end
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
url.sub!("/thumb/" + match, "/large/" + match)
end

View File

@@ -58,9 +58,9 @@ module Sources
def normalized_url
@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}"
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}"
elsif url =~ %r{deviantart\.com/art/}
url

View File

@@ -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
"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_36_id = base_10_id.to_s(36)
"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}"
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}"
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
"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}"
else