newgrounds: fix style nitpicks.
This commit is contained in:
@@ -7,19 +7,18 @@
|
||||
# * https://www.newgrounds.com/art/view/puddbytes/costanza-at-bat
|
||||
# * https://www.newgrounds.com/art/view/natthelich/fire-emblem-marth-plus-progress-pic (multiple)
|
||||
#
|
||||
#
|
||||
# Profile URLs
|
||||
# * https://natthelich.newgrounds.com/
|
||||
|
||||
module Sources
|
||||
module Strategies
|
||||
class Newgrounds < Base
|
||||
IMAGE_URL = %r{https?://art\.ngfiles\.com/images/\d+/\d+_(?<user_name>[0-9a-z-]+)_(?<illust_title>[0-9a-z-]+)\.\w+}i
|
||||
COMMENT_URL = %r{https?://art\.ngfiles\.com/comments/\d+/\w+\.\w+}i
|
||||
IMAGE_URL = %r{\Ahttps?://art\.ngfiles\.com/images/\d+/\d+_(?<user_name>[0-9a-z-]+)_(?<illust_title>[0-9a-z-]+)\.\w+}i
|
||||
COMMENT_URL = %r{\Ahttps?://art\.ngfiles\.com/comments/\d+/\w+\.\w+}i
|
||||
|
||||
PAGE_URL = %r{https?://(?:www\.)?newgrounds\.com/art/view/(?<user_name>[0-9a-z-]+)/(?<illust_title>[0-9a-z-]+)(?:\?.*)?}i
|
||||
PAGE_URL = %r{\Ahttps?://(?:www\.)?newgrounds\.com/art/view/(?<user_name>[0-9a-z-]+)/(?<illust_title>[0-9a-z-]+)(?:\?.*)?}i
|
||||
|
||||
PROFILE_URL = %r{https?://(?<artist_name>(?!www)[0-9a-z-]+)\.newgrounds\.com(?:/.*)?}i
|
||||
PROFILE_URL = %r{\Ahttps?://(?<artist_name>(?!www)[0-9a-z-]+)\.newgrounds\.com(?:/.*)?}i
|
||||
|
||||
def domains
|
||||
["newgrounds.com", "ngfiles.com"]
|
||||
@@ -50,11 +49,11 @@ module Sources
|
||||
|
||||
def page
|
||||
return nil if page_url.blank?
|
||||
doc = Danbooru::Http.cache(1.minute).get(page_url)
|
||||
|
||||
return if doc.code == 404
|
||||
response = Danbooru::Http.cache(1.minute).get(page_url)
|
||||
return nil if response.status == 404
|
||||
|
||||
Nokogiri::HTML(doc.body)
|
||||
response.parse
|
||||
end
|
||||
memoize :page
|
||||
|
||||
|
||||
@@ -344,6 +344,10 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
should_upload_successfully("https://www.weibo.com/5501756072/J2UNKfbqV")
|
||||
should_upload_successfully("https://wx1.sinaimg.cn/mw690/0060kO5aly1gezsyt5xvhj30ok0sgtc9.jpg")
|
||||
|
||||
should_upload_successfully("https://art.ngfiles.com/images/1254000/1254722_natthelich_pandora.jpg")
|
||||
should_upload_successfully("https://art.ngfiles.com/comments/57000/iu_57615_7115981.jpg")
|
||||
should_upload_successfully("https://www.newgrounds.com/art/view/puddbytes/costanza-at-bat")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,9 +60,9 @@ module Sources
|
||||
end
|
||||
|
||||
should "find the right artist" do
|
||||
artist_1 = FactoryBot.create(:artist, name: "natthelich1", url_string: "https://natthelich.newgrounds.com/art")
|
||||
artist_2 = FactoryBot.create(:artist, name: "natthelich2", url_string: "https://www.newgrounds.com/art/view/natthelich/fire-emblem-marth-plus-progress-pic")
|
||||
artist_3 = FactoryBot.create(:artist, name: "bad_artist", url_string: "https://www.newgrounds.com/art")
|
||||
artist_1 = create(:artist, name: "natthelich1", url_string: "https://natthelich.newgrounds.com/art")
|
||||
artist_2 = create(:artist, name: "natthelich2", url_string: "https://www.newgrounds.com/art/view/natthelich/fire-emblem-marth-plus-progress-pic")
|
||||
artist_3 = create(:artist, name: "bad_artist", url_string: "https://www.newgrounds.com/art")
|
||||
|
||||
assert_equal([artist_1, artist_2], @image_1.artists)
|
||||
assert_equal([artist_1, artist_2], @image_2.artists)
|
||||
@@ -75,13 +75,13 @@ module Sources
|
||||
context "A deleted or not existing picture" do
|
||||
setup do
|
||||
@fake_1 = Sources::Strategies.find("https://www.newgrounds.com/art/view/ThisUser/DoesNotExist")
|
||||
@artist_1 = FactoryBot.create(:artist, name: "thisuser", url_string: "https://thisuser.newgrounds.com")
|
||||
@artist_1 = create(:artist, name: "thisuser", url_string: "https://thisuser.newgrounds.com")
|
||||
|
||||
@fake_2 = Sources::Strategies.find("https://www.newgrounds.com/art/view/natthelich/nopicture")
|
||||
@artist_2 = FactoryBot.create(:artist, name: "natthelich", url_string: "https://natthelich.newgrounds.com")
|
||||
@artist_2 = create(:artist, name: "natthelich", url_string: "https://natthelich.newgrounds.com")
|
||||
|
||||
@fake_3 = Sources::Strategies.find("https://www.newgrounds.com/art/view/theolebrave/sensitive-pochaco")
|
||||
@artist_3 = FactoryBot.create(:artist, name: "taffytoad", url_string: "https://taffytoad.newgrounds.com")
|
||||
@artist_3 = create(:artist, name: "taffytoad", url_string: "https://taffytoad.newgrounds.com")
|
||||
end
|
||||
|
||||
should "still find the artist name" do
|
||||
|
||||
Reference in New Issue
Block a user