gelbooru: fix normalization of old image URLs.
This commit is contained in:
@@ -24,7 +24,6 @@ class Source::URL::Gelbooru < Source::URL
|
||||
@post_id = params[:id].to_i
|
||||
|
||||
# https://gelbooru.com//images/ee/5c/ee5c9a69db9602c95debdb9b98fb3e3e.jpeg
|
||||
# http://simg.gelbooru.com//images/2003/edd1d2b3881cf70c3acf540780507531.png
|
||||
# https://simg3.gelbooru.com//samples/0b/3a/sample_0b3ae5e225072b8e391c827cb470d29c.jpg
|
||||
# https://video-cdn3.gelbooru.com/images/62/95/6295154d082f04009160261b90e7176e.mp4
|
||||
# https://img2.gelbooru.com//images/a9/64/a96478bbf9bc3f0584f2b5ddf56025fa.webm
|
||||
@@ -33,6 +32,12 @@ class Source::URL::Gelbooru < Source::URL
|
||||
@md5 = $1
|
||||
@full_image_url = "https://#{host}/images/#{h1}/#{h2}/#{md5}.#{file_ext}"
|
||||
|
||||
# http://simg.gelbooru.com//images/2003/edd1d2b3881cf70c3acf540780507531.png
|
||||
# http://simg2.gelbooru.com//samples/619/sample_fe84fb3f86020e120f4b4712fcbd3abf.jpeg?755046
|
||||
in "gelbooru.com", ("images" | "samples"), /\A\d+\z/ => dir, /\A(?:\w+_)?(\h{32})\.(jpeg|jpg|png|gif|mp4|webm)/i
|
||||
@md5 = $1
|
||||
@full_image_url = url
|
||||
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -67,5 +67,15 @@ module Sources
|
||||
download_size: 480_621,
|
||||
)
|
||||
end
|
||||
|
||||
should "normalize gelbooru links" do
|
||||
source1 = "https://gelbooru.com//images/ee/5c/ee5c9a69db9602c95debdb9b98fb3e3e.jpeg"
|
||||
source2 = "http://simg.gelbooru.com//images/2003/edd1d2b3881cf70c3acf540780507531.png"
|
||||
source3 = "https://simg3.gelbooru.com//samples/0b/3a/sample_0b3ae5e225072b8e391c827cb470d29c.jpg"
|
||||
|
||||
assert_equal("https://gelbooru.com/index.php?page=post&s=list&md5=ee5c9a69db9602c95debdb9b98fb3e3e", Source::URL.page_url(source1))
|
||||
assert_equal("https://gelbooru.com/index.php?page=post&s=list&md5=edd1d2b3881cf70c3acf540780507531", Source::URL.page_url(source2))
|
||||
assert_equal("https://gelbooru.com/index.php?page=post&s=list&md5=0b3ae5e225072b8e391c827cb470d29c", Source::URL.page_url(source3))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,16 +72,6 @@ module Sources
|
||||
assert_equal("http://gallery.minitokyo.net/view/199164", Source::URL.page_url(source2))
|
||||
end
|
||||
|
||||
should "normalize gelbooru links" do
|
||||
source1 = "https://gelbooru.com//images/ee/5c/ee5c9a69db9602c95debdb9b98fb3e3e.jpeg"
|
||||
source2 = "http://simg.gelbooru.com//images/2003/edd1d2b3881cf70c3acf540780507531.png"
|
||||
source3 = "https://simg3.gelbooru.com//samples/0b/3a/sample_0b3ae5e225072b8e391c827cb470d29c.jpg"
|
||||
|
||||
assert_equal("https://gelbooru.com/index.php?page=post&s=list&tags=md5:ee5c9a69db9602c95debdb9b98fb3e3e", Source::URL.page_url(source1))
|
||||
assert_equal("https://gelbooru.com/index.php?page=post&s=list&tags=md5:edd1d2b3881cf70c3acf540780507531", Source::URL.page_url(source2))
|
||||
assert_equal("https://gelbooru.com/index.php?page=post&s=list&tags=md5:0b3ae5e225072b8e391c827cb470d29c", Source::URL.page_url(source3))
|
||||
end
|
||||
|
||||
should "normalize e-shuushuu links" do
|
||||
source = "http://e-shuushuu.net/images/2014-07-22-662472.png"
|
||||
assert_equal("https://e-shuushuu.net/image/662472", Source::URL.page_url(source))
|
||||
|
||||
Reference in New Issue
Block a user