Merge pull request #4782 from nonamethanks/feat-nicoseiga-spoiler

Nicoseiga: auto-add spoiler tags to commentary
This commit is contained in:
evazion
2021-05-05 05:07:13 -05:00
committed by GitHub
2 changed files with 30 additions and 1 deletions

View File

@@ -134,7 +134,11 @@ module Sources
end
def dtext_artist_commentary_desc
DText.from_html(artist_commentary_desc).gsub(/[^\w]im(\d+)/, ' seiga #\1 ')
DText.from_html(artist_commentary_desc) do |element|
if element.name == "font" && element["color"] == "white"
element.content = "[spoiler]#{element.content}[/spoiler]"
end
end.gsub(/[^\w]im(\d+)/, ' seiga #\1 ').chomp
end
def normalize_for_source

View File

@@ -129,6 +129,31 @@ module Sources
end
end
context "A commentary with spoiler" do
should "correctly add spoiler tags" do
site = Sources::Strategies.find("https://seiga.nicovideo.jp/seiga/im8992650")
commentary = <<~COMM.chomp
SLVN大好き
[spoiler]
Kiss
HZNの企画した東方合同動画企画
HZNの心にも
27
[/spoiler]
COMM
assert_equal(commentary, site.dtext_artist_commentary_desc)
end
end
context "normalizing for source" do
should "normalize correctly" do
source1 = "http://lohas.nicoseiga.jp/priv/3521156?e=1382558156&h=f2e089256abd1d453a455ec8f317a6c703e2cedf"