Add domain icons for InkBunny, Newgrounds, and Patreon; update E621 post helper and improve file URL handling
This commit is contained in:
BIN
app/assets/images/domain-icons/inkbunny.png
Normal file
BIN
app/assets/images/domain-icons/inkbunny.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
app/assets/images/domain-icons/newgrounds.png
Normal file
BIN
app/assets/images/domain-icons/newgrounds.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 797 B |
BIN
app/assets/images/domain-icons/patreon.png
Normal file
BIN
app/assets/images/domain-icons/patreon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 772 B |
@@ -10,6 +10,10 @@ module Domain::E621::PostsHelper
|
||||
%w[*.itaku.ee itaku.ee] => "itaku.png",
|
||||
%w[*.deviantart.com deviantart.com *.wixmp.com] => "deviantart.png",
|
||||
%w[*.twitter.com twitter.com *.x.com x.com] => "x-twitter.png",
|
||||
%w[*.inkbunny.net inkbunny.net *.ib.metapix.net ib.metapix.net] =>
|
||||
"inkbunny.png",
|
||||
%w[*.newgrounds.com newgrounds.com] => "newgrounds.png",
|
||||
%w[*.patreon.com patreon.com] => "patreon.png",
|
||||
}
|
||||
|
||||
domain_patterns.each do |patterns, icon|
|
||||
|
||||
@@ -8,14 +8,6 @@ module Domain::E621::TagUtil
|
||||
e621_id = post_json["id"]
|
||||
e621_post = Domain::E621::Post.find_or_initialize_by(e621_id: e621_id)
|
||||
|
||||
e621_tag_names =
|
||||
Domain::E621::Tagging
|
||||
.categories
|
||||
.keys
|
||||
.flat_map { |tag_category| post_json["tags"][tag_category] }
|
||||
.sort
|
||||
.uniq
|
||||
|
||||
e621_updated_at = post_json["updated_at"]
|
||||
if e621_post.state_detail["e621_updated_at"] == e621_updated_at
|
||||
return e621_post
|
||||
@@ -41,7 +33,12 @@ module Domain::E621::TagUtil
|
||||
end
|
||||
|
||||
e621_post.md5 = e621_md5
|
||||
e621_post.file_url_str = post_json["file"]["url"]
|
||||
e621_post.file_url_str =
|
||||
begin
|
||||
file = post_json["file"]
|
||||
file["url"] ||
|
||||
"https://static1.e621.net/data/#{e621_md5[0...2]}/#{e621_md5[2...4]}/#{e621_md5}.#{file["ext"]}"
|
||||
end
|
||||
e621_post.posted_at = post_json["created_at"]
|
||||
e621_post.description = post_json["description"]
|
||||
e621_post.rating = post_json["rating"]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
class: "h-16 w-16 object-cover rounded",
|
||||
alt: post.title %>
|
||||
<% else %>
|
||||
indexable post id: <%= post.id %>
|
||||
(none)
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="grid-cell min-w-0">
|
||||
|
||||
@@ -2,11 +2,10 @@ require "rails_helper"
|
||||
|
||||
describe Domain::E621::Job::ScanPostJob do
|
||||
let(:http_client_mock) { instance_double("::Scraper::HttpClient") }
|
||||
let(:post) { SpecUtil.create_e621_post(e621_id: 2_227_914) }
|
||||
|
||||
before { Scraper::ClientFactory.http_client_mock = http_client_mock }
|
||||
|
||||
it "scans the post" do
|
||||
post = SpecUtil.create_e621_post(e621_id: 2_227_914)
|
||||
caused_by_entry = SpecUtil.create_http_log_entry
|
||||
mock_log_entries =
|
||||
SpecUtil.init_http_client_mock(
|
||||
@@ -45,4 +44,39 @@ describe Domain::E621::Job::ScanPostJob do
|
||||
SpecUtil.enqueued_jobs(Domain::E621::Job::StaticFileJob).first[:args],
|
||||
).to eq([{ post: post, caused_by_entry: mock_log_entries[0] }])
|
||||
end
|
||||
|
||||
it "handles a post with no file url" do
|
||||
post = SpecUtil.create_e621_post(e621_id: 5_270_136)
|
||||
mock_log_entries =
|
||||
SpecUtil.init_http_client_mock(
|
||||
http_client_mock,
|
||||
[
|
||||
{
|
||||
uri: "https://e621.net/posts/5270136.json",
|
||||
status_code: 200,
|
||||
content_type: "application/json; charset=utf-8",
|
||||
contents:
|
||||
SpecUtil.read_fixture_file("domain/e621/job/posts_5270136.json"),
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
expect(post.file_url_str).to be_nil
|
||||
described_class.perform_now({ post: post })
|
||||
|
||||
post.reload
|
||||
expect(post.file_url_str).to eq(
|
||||
"https://static1.e621.net/data/d7/72/d7720676ae1dc4c0ff53c1c34ae5c5b0.png",
|
||||
)
|
||||
expect(post.md5).to eq("d7720676ae1dc4c0ff53c1c34ae5c5b0")
|
||||
expect(post.tags_array).to match(
|
||||
hash_including("general" => array_including("anthro", "duo")),
|
||||
)
|
||||
expect(
|
||||
SpecUtil.enqueued_jobs(Domain::E621::Job::StaticFileJob).length,
|
||||
).to eq(1)
|
||||
expect(
|
||||
SpecUtil.enqueued_jobs(Domain::E621::Job::StaticFileJob).first[:args],
|
||||
).to eq([{ post: post, caused_by_entry: mock_log_entries[0] }])
|
||||
end
|
||||
end
|
||||
|
||||
86
test/fixtures/files/domain/e621/job/posts_5270136.json
vendored
Normal file
86
test/fixtures/files/domain/e621/job/posts_5270136.json
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"post": {
|
||||
"id": 5270136,
|
||||
"created_at": "2024-12-27T16:42:18.693-05:00",
|
||||
"updated_at": "2024-12-27T16:54:52.228-05:00",
|
||||
"file": {
|
||||
"width": 1500,
|
||||
"height": 1500,
|
||||
"ext": "png",
|
||||
"size": 1618955,
|
||||
"md5": "d7720676ae1dc4c0ff53c1c34ae5c5b0",
|
||||
"url": null
|
||||
},
|
||||
"preview": { "width": 150, "height": 150, "url": null },
|
||||
"sample": {
|
||||
"has": true,
|
||||
"height": 850,
|
||||
"width": 850,
|
||||
"url": null,
|
||||
"alternates": {}
|
||||
},
|
||||
"score": { "up": 2, "down": 0, "total": 2 },
|
||||
"tags": {
|
||||
"general": [
|
||||
"anthro",
|
||||
"duo",
|
||||
"herm",
|
||||
"intersex",
|
||||
"intersex/male",
|
||||
"knot",
|
||||
"male",
|
||||
"young",
|
||||
"young_anthro"
|
||||
],
|
||||
"artist": ["zombieviking"],
|
||||
"contributor": [],
|
||||
"copyright": [],
|
||||
"character": [],
|
||||
"species": [
|
||||
"bird_dog",
|
||||
"canid",
|
||||
"canine",
|
||||
"canis",
|
||||
"domestic_cat",
|
||||
"domestic_dog",
|
||||
"felid",
|
||||
"feline",
|
||||
"felis",
|
||||
"golden_retriever",
|
||||
"hunting_dog",
|
||||
"mammal",
|
||||
"retriever"
|
||||
],
|
||||
"invalid": ["experiment_(disambiguation)"],
|
||||
"meta": ["hi_res"],
|
||||
"lore": []
|
||||
},
|
||||
"locked_tags": [],
|
||||
"change_seq": 63442546,
|
||||
"flags": {
|
||||
"pending": true,
|
||||
"flagged": false,
|
||||
"note_locked": false,
|
||||
"status_locked": false,
|
||||
"rating_locked": false,
|
||||
"deleted": false
|
||||
},
|
||||
"rating": "e",
|
||||
"fav_count": 3,
|
||||
"sources": ["https://www.furaffinity.net/view/59306869/"],
|
||||
"pools": [],
|
||||
"relationships": {
|
||||
"parent_id": null,
|
||||
"has_children": false,
|
||||
"has_active_children": false,
|
||||
"children": []
|
||||
},
|
||||
"approver_id": null,
|
||||
"uploader_id": 809468,
|
||||
"description": "hey I don't post here often !\nHere's my furaffinity !\nhttps://www.furaffinity.net/user/zombieviking",
|
||||
"comment_count": 0,
|
||||
"is_favorited": false,
|
||||
"has_notes": false,
|
||||
"duration": null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user