Make the artist finder work with new Pixiv URLs.
This commit is contained in:
@@ -118,11 +118,7 @@ class ArtistsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def finder
|
def finder
|
||||||
url = params[:url]
|
url = Sources::Strategies::Pixiv.new(url).normalize_for_artist_finder!(params[:url])
|
||||||
headers = {
|
|
||||||
"User-Agent" => "#{Danbooru.config.safe_app_name}/#{Danbooru.config.version}"
|
|
||||||
}
|
|
||||||
url, headers = Downloads::Strategies::Pixiv.new.rewrite(url, headers)
|
|
||||||
|
|
||||||
@artists = Artist.url_matches(url).order("id desc").limit(20)
|
@artists = Artist.url_matches(url).order("id desc").limit(20)
|
||||||
respond_with(@artists) do |format|
|
respond_with(@artists) do |format|
|
||||||
|
|||||||
@@ -25,6 +25,21 @@ module Sources
|
|||||||
@pixiv_moniker
|
@pixiv_moniker
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize_for_artist_finder!(url)
|
||||||
|
illust_id = illust_id_from_url(url)
|
||||||
|
|
||||||
|
# http://i2.pixiv.net/img04/img/syounen_no_uta/46170939_m.jpg
|
||||||
|
if url =~ %r!/img/([^/]+)/\d+(?:_\w+)?\.(?:jpg|jpeg|png|gif)!i
|
||||||
|
username = $1
|
||||||
|
else
|
||||||
|
get_metadata_from_spapi!(illust_id) do |metadata|
|
||||||
|
username = metadata[24]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
"http://img.pixiv.net/img/#{username}"
|
||||||
|
end
|
||||||
|
|
||||||
def get
|
def get
|
||||||
agent.get(URI.parse(normalized_url)) do |page|
|
agent.get(URI.parse(normalized_url)) do |page|
|
||||||
@artist_name, @profile_url = get_profile_from_page(page)
|
@artist_name, @profile_url = get_profile_from_page(page)
|
||||||
|
|||||||
Reference in New Issue
Block a user