fixed pixiv sources
This commit is contained in:
@@ -26,7 +26,11 @@ module Sources
|
||||
end
|
||||
|
||||
def artist_record
|
||||
Artist.other_names_match(artist_name)
|
||||
if artist_name.present?
|
||||
Artist.other_names_match(artist_name)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -25,12 +25,12 @@ module Sources
|
||||
protected
|
||||
|
||||
def get_profile_from_page(page)
|
||||
links = page.search("div.front-subContent a").find_all do |node|
|
||||
links = page.search("div.profile_area a.avatar_m").find_all do |node|
|
||||
node["href"] =~ /member\.php/
|
||||
end
|
||||
|
||||
if links.any?
|
||||
profile_url = "http://www.pixiv.net/" + links[0]["href"]
|
||||
profile_url = "http://www.pixiv.net" + links[0]["href"]
|
||||
children = links[0].children
|
||||
artist = children[0]["alt"]
|
||||
return [artist, profile_url]
|
||||
@@ -49,13 +49,13 @@ module Sources
|
||||
end
|
||||
|
||||
def get_tags_from_page(page)
|
||||
links = page.search("div.pedia li a").find_all do |node|
|
||||
links = page.search("span#tags a").find_all do |node|
|
||||
node["href"] =~ /tags\.php/
|
||||
end
|
||||
|
||||
if links.any?
|
||||
links.map do |node|
|
||||
[node.inner_text, "http://www.pixiv.net/" + node.attr("href")]
|
||||
[node.inner_text, "http://www.pixiv.net" + node.attr("href")]
|
||||
end
|
||||
else
|
||||
[]
|
||||
@@ -66,6 +66,8 @@ module Sources
|
||||
@normalized_url ||= begin
|
||||
if url =~ /\/(\d+)(_m|_p\d+)?\.(jpg|jpeg|png|gif)/i
|
||||
"http://www.pixiv.net/member_illust.php?mode=medium&illust_id=#{$1}"
|
||||
elsif url =~ /mode=big/
|
||||
url.sub(/mode=big/, "mode=medium")
|
||||
elsif url =~ /member_illust\.php/ && url =~ /illust_id=/
|
||||
url
|
||||
else
|
||||
@@ -80,8 +82,7 @@ module Sources
|
||||
|
||||
mech.get("http://www.pixiv.net") do |page|
|
||||
page.form_with(:action => "/login.php") do |form|
|
||||
form['mode'] = "login"
|
||||
form['login_pixiv_id'] = Danbooru.config.pixiv_login
|
||||
form['pixiv_id'] = Danbooru.config.pixiv_login
|
||||
form['pass'] = Danbooru.config.pixiv_password
|
||||
end.click_button
|
||||
end
|
||||
|
||||
@@ -60,7 +60,7 @@ class Artist < ActiveRecord::Base
|
||||
module NameMethods
|
||||
module ClassMethods
|
||||
def normalize_name(name)
|
||||
name.downcase.strip.gsub(/ /, '_')
|
||||
name.to_s.downcase.strip.gsub(/ /, '_')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class PixivProxyTest < ActiveSupport::TestCase
|
||||
context "The proxy" do
|
||||
should "get a single post" do
|
||||
site = Sources::Site.new("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=9646484")
|
||||
site.get
|
||||
|
||||
assert_equal("http://www.pixiv.net/member.php?id=4015", site.profile_url)
|
||||
assert(site.tags.size > 0)
|
||||
first_tag = site.tags.first
|
||||
assert_equal(2, first_tag.size)
|
||||
assert(first_tag[0] =~ /./)
|
||||
assert(first_tag[1] =~ /tags\.php\?tag=/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,7 +6,7 @@ module Sources
|
||||
class PixivTest < ActiveSupport::TestCase
|
||||
context "The source site for pixiv" do
|
||||
setup do
|
||||
@site = Sources::Site.new("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=9646484")
|
||||
@site = Sources::Site.new("http://www.pixiv.net/member_illust.php?mode=big&illust_id=9646484")
|
||||
@site.get
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user