sources: add 4chan.org upload support.

Add upload support for 4chan.org. You can upload either individual posts or entire threads at a time.
This commit is contained in:
evazion
2022-11-17 03:32:08 -06:00
parent 94824fb171
commit 902cd0bbdf
8 changed files with 263 additions and 4 deletions

View File

@@ -518,6 +518,8 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
should_upload_successfully("https://rule34.xxx/index.php?page=post&s=view&id=6961597")
should_upload_successfully("https://rule34.us/index.php?r=posts/view&id=6204967")
should_upload_successfully("https://boards.4channel.org/vt/thread/1#p1")
should_upload_successfully("http://lohas.nicoseiga.jp/o/910aecf08e542285862954017f8a33a8c32a8aec/1433298801/4937663")
should_upload_successfully("http://seiga.nicovideo.jp/seiga/im4937663")
should_upload_successfully("https://seiga.nicovideo.jp/image/source/9146749")

View File

@@ -0,0 +1,73 @@
require "test_helper"
module Sources
class FourChanTest < ActiveSupport::TestCase
context "A 4chan source extractor" do
context "A 4chan direct image url without a referer" do
strategy_should_work(
"https://i.4cdn.org/vt/1611919211191.jpg",
image_urls: ["https://i.4cdn.org/vt/1611919211191.jpg"],
page_url: nil,
artist_commentary_title: nil,
artist_commentary_desc: nil,
dtext_artist_commentary_desc: "",
download_size: 145_602,
)
end
context "A 4chan direct image url with a referer" do
strategy_should_work(
"https://i.4cdn.org/vt/1611919211191.jpg",
referer: "https://boards.4channel.org/vt/thread/1",
image_urls: ["https://i.4cdn.org/vt/1611919211191.jpg"],
page_url: "https://boards.4channel.org/vt/thread/1#p1",
artist_commentary_title: "Anonymous 01/29/21(Fri)06:20:11 No.1",
dtext_artist_commentary_desc: <<~EOS.chomp,
"vt.jpg":[https://i.4cdn.org/vt/1611919211191.jpg] (142 KB, 767x677)
This board is for the discussion of Virtual YouTubers ("VTubers"), including those streaming in Japanese, English, and other languages. VTubers don't necessarily need to be on Youtube of course, they can be on Twitch, Niconico, Bilibili, or any other platform.
Please note that discussion should pertain to a VTuber's streams and content, and should not pertain to their real lives, relationships, or appearances ("IRL").
EOS
download_size: 145_602,
)
end
context "A 4chan thumbnail image url without a referer" do
strategy_should_work(
"https://i.4cdn.org/vt/1611919211191s.jpg",
image_urls: ["https://i.4cdn.org/vt/1611919211191s.jpg"],
page_url: nil,
artist_commentary_title: nil,
artist_commentary_desc: nil,
dtext_artist_commentary_desc: "",
download_size: 7430,
)
end
context "A 4chan post url" do
strategy_should_work(
"https://boards.4channel.org/vt/thread/1#p1",
image_urls: ["https://i.4cdn.org/vt/1611919211191.jpg"],
page_url: "https://boards.4channel.org/vt/thread/1#p1",
artist_commentary_title: "Anonymous 01/29/21(Fri)06:20:11 No.1",
dtext_artist_commentary_desc: <<~EOS.chomp,
"vt.jpg":[https://i.4cdn.org/vt/1611919211191.jpg] (142 KB, 767x677)
This board is for the discussion of Virtual YouTubers ("VTubers"), including those streaming in Japanese, English, and other languages. VTubers don't necessarily need to be on Youtube of course, they can be on Twitch, Niconico, Bilibili, or any other platform.
Please note that discussion should pertain to a VTuber's streams and content, and should not pertain to their real lives, relationships, or appearances ("IRL").
EOS
download_size: 145_602,
)
end
context "A 4chan thread url" do
strategy_should_work(
"https://boards.4channel.org/vt/thread/1",
image_urls: ["https://i.4cdn.org/vt/1611919211191.jpg"],
page_url: "https://boards.4channel.org/vt/thread/1",
download_size: 145_602,
)
end
end
end
end