newgrounds: support parsing video urls.
Fixes URLS like `https://www.newgrounds.com/portal/view/830293` being treated as bad_source.
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
# * https://uploads.ungrounded.net/225000/225625_colormedressup.swf?1111143751 (file)
|
# * https://uploads.ungrounded.net/225000/225625_colormedressup.swf?1111143751 (file)
|
||||||
#
|
#
|
||||||
class Source::URL::Newgrounds < Source::URL
|
class Source::URL::Newgrounds < Source::URL
|
||||||
attr_reader :username, :work_id, :work_title
|
attr_reader :username, :work_id, :work_title, :video_id
|
||||||
|
|
||||||
def self.match?(url)
|
def self.match?(url)
|
||||||
url.domain.in?(["newgrounds.com", "ngfiles.com", "ungrounded.net"])
|
url.domain.in?(["newgrounds.com", "ngfiles.com", "ungrounded.net"])
|
||||||
@@ -31,6 +31,11 @@ class Source::URL::Newgrounds < Source::URL
|
|||||||
@username = username
|
@username = username
|
||||||
@work_title = work_title
|
@work_title = work_title
|
||||||
|
|
||||||
|
# https://www.newgrounds.com/portal/view/536659
|
||||||
|
# https://www.newgrounds.com/portal/video/536659 (curl 'https://www.newgrounds.com/portal/video/536659' -H 'X-Requested-With: XMLHttpRequest')
|
||||||
|
in "www.newgrounds.com", "portal", ("view" | "video"), video_id
|
||||||
|
@video_id = video_id
|
||||||
|
|
||||||
# https://art.ngfiles.com/images/1254000/1254722_natthelich_pandora.jpg
|
# https://art.ngfiles.com/images/1254000/1254722_natthelich_pandora.jpg
|
||||||
# https://art.ngfiles.com/images/1033000/1033622_natthelich_fire-emblem-marth-plus-progress-pic.png?f1569487181
|
# https://art.ngfiles.com/images/1033000/1033622_natthelich_fire-emblem-marth-plus-progress-pic.png?f1569487181
|
||||||
in "art.ngfiles.com", "images", _, /^(\d+)_([^_]+)_(.*)\.\w+$/
|
in "art.ngfiles.com", "images", _, /^(\d+)_([^_]+)_(.*)\.\w+$/
|
||||||
@@ -63,6 +68,8 @@ class Source::URL::Newgrounds < Source::URL
|
|||||||
def page_url
|
def page_url
|
||||||
if username.present? && work_title.present?
|
if username.present? && work_title.present?
|
||||||
"https://www.newgrounds.com/art/view/#{username}/#{work_title}"
|
"https://www.newgrounds.com/art/view/#{username}/#{work_title}"
|
||||||
|
elsif video_id.present?
|
||||||
|
"https://www.newgrounds.com/portal/view/#{video_id}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ module Sources
|
|||||||
assert(Source::URL.image_url?("https://art.ngfiles.com/thumbnails/1254000/1254985.png?f1588263349"))
|
assert(Source::URL.image_url?("https://art.ngfiles.com/thumbnails/1254000/1254985.png?f1588263349"))
|
||||||
|
|
||||||
assert(Source::URL.page_url?("https://www.newgrounds.com/art/view/puddbytes/costanza-at-bat"))
|
assert(Source::URL.page_url?("https://www.newgrounds.com/art/view/puddbytes/costanza-at-bat"))
|
||||||
|
assert(Source::URL.page_url?("https://www.newgrounds.com/portal/view/830293"))
|
||||||
|
|
||||||
assert(Source::URL.profile_url?("https://natthelich.newgrounds.com"))
|
assert(Source::URL.profile_url?("https://natthelich.newgrounds.com"))
|
||||||
refute(Source::URL.profile_url?("https://www.newgrounds.com"))
|
refute(Source::URL.profile_url?("https://www.newgrounds.com"))
|
||||||
|
|||||||
Reference in New Issue
Block a user