nicoseiga: support a few more url types.
This commit is contained in:
@@ -27,7 +27,7 @@ module Source
|
||||
attr_reader :illust_id, :manga_id, :image_id, :user_id, :username, :profile_url
|
||||
|
||||
def self.match?(url)
|
||||
url.domain.in?(%w[nicovideo.jp nicoseiga.jp nicomanga.jp nimg.jp])
|
||||
url.domain.in?(%w[nicovideo.jp nicoseiga.jp nicomanga.jp nimg.jp nico.ms])
|
||||
end
|
||||
|
||||
def site_name
|
||||
@@ -90,6 +90,18 @@ module Source
|
||||
in "deliver.cdn.nicomanga.jp", *rest
|
||||
# unhandled
|
||||
|
||||
# https://drm.cdn.nicomanga.jp/image/d4a2faa68ec34f95497db6601a4323fde2ccd451_9537/8017978p?1570012695
|
||||
in "drm.cdn.nicomanga.jp", "image", _, /^(\d+)p$/ => image_id
|
||||
@image_id = $1
|
||||
|
||||
# https://nico.ms/im10922621
|
||||
in "nico.ms", /^im(\d+)$/
|
||||
@illust_id = $1
|
||||
|
||||
# https://nico.ms/mg310193
|
||||
in "nico.ms", /^mg(\d+)$/
|
||||
@manga_id = $1
|
||||
|
||||
# https://seiga.nicovideo.jp/user/illust/456831
|
||||
# https://sp.seiga.nicovideo.jp/user/illust/20542122
|
||||
# https://ext.seiga.nicovideo.jp/user/illust/20542122
|
||||
|
||||
@@ -103,6 +103,31 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
context "A manga image" do
|
||||
should "work" do
|
||||
@source = Sources::Strategies.find("https://drm.cdn.nicomanga.jp/image/d4a2faa68ec34f95497db6601a4323fde2ccd451_9537/8017978p?1570012695")
|
||||
|
||||
assert_match(%r{\Ahttps://lohas\.nicoseiga\.jp/priv/\h{40}/\d+/8017978\z}, @source.image_urls.sole)
|
||||
end
|
||||
end
|
||||
|
||||
context "A nico.ms illust URL" do
|
||||
should "work" do
|
||||
@source = Sources::Strategies.find("https://nico.ms/im10922621")
|
||||
|
||||
assert_match(%r{\Ahttps://lohas\.nicoseiga\.jp/priv/\h{40}/\d+/10922621\z}, @source.image_urls.sole)
|
||||
end
|
||||
end
|
||||
|
||||
context "A nico.ms manga URL" do
|
||||
should "work" do
|
||||
@source = Sources::Strategies.find("https://nico.ms/mg310193")
|
||||
|
||||
assert_equal(19, @source.image_urls.size)
|
||||
assert_equal("https://seiga.nicovideo.jp/watch/mg310193", @source.page_url)
|
||||
end
|
||||
end
|
||||
|
||||
context "A nicoseiga video" do
|
||||
should "not raise anything" do
|
||||
site = Sources::Strategies.find("https://www.nicovideo.jp/watch/sm36465441")
|
||||
|
||||
Reference in New Issue
Block a user