Fix #2779: Erroneous pixiv_id parsed for novel/background/profile images

This commit is contained in:
evazion
2016-12-03 20:00:34 -06:00
parent 96a38f8d1b
commit 5302b804f1
2 changed files with 7 additions and 9 deletions

View File

@@ -56,7 +56,7 @@ module Sources
if has_moniker? if has_moniker?
moniker = get_moniker_from_url moniker = get_moniker_from_url
else else
@illust_id = self.class.illust_id_from_url!(url) @illust_id = illust_id_from_url!
@metadata = get_metadata_from_papi(@illust_id) @metadata = get_metadata_from_papi(@illust_id)
moniker = @metadata.moniker moniker = @metadata.moniker
end end
@@ -65,7 +65,7 @@ module Sources
end end
def get def get
@illust_id = self.class.illust_id_from_url!(url) @illust_id = illust_id_from_url!
@metadata = get_metadata_from_papi(@illust_id) @metadata = get_metadata_from_papi(@illust_id)
page = agent.get(URI.parse(normalized_url)) page = agent.get(URI.parse(normalized_url))
@@ -111,9 +111,9 @@ module Sources
@metadata.pages @metadata.pages
end end
def self.illust_id_from_url(url) def illust_id_from_url
if url_match?(url) if sample_image? || full_image? || work_page?
illust_id_from_url!(url) illust_id_from_url!
else else
nil nil
end end
@@ -121,7 +121,7 @@ module Sources
nil nil
end end
def self.illust_id_from_url!(url) def illust_id_from_url!
# http://img18.pixiv.net/img/evazion/14901720.png # http://img18.pixiv.net/img/evazion/14901720.png
# #
# http://i2.pixiv.net/img18/img/evazion/14901720.png # http://i2.pixiv.net/img18/img/evazion/14901720.png
@@ -156,8 +156,6 @@ module Sources
end end
end end
protected
# http://i1.pixiv.net/c/600x600/img-master/img/2014/10/02/13/51/23/46304396_p1_master1200.jpg # http://i1.pixiv.net/c/600x600/img-master/img/2014/10/02/13/51/23/46304396_p1_master1200.jpg
# => http://i1.pixiv.net/img-original/img/2014/10/02/13/51/23/46304396_p1.png # => http://i1.pixiv.net/img-original/img/2014/10/02/13/51/23/46304396_p1.png
def rewrite_new_medium_images(thumbnail_url) def rewrite_new_medium_images(thumbnail_url)

View File

@@ -1685,7 +1685,7 @@ class Post < ActiveRecord::Base
module PixivMethods module PixivMethods
def parse_pixiv_id def parse_pixiv_id
self.pixiv_id = Sources::Strategies::Pixiv.illust_id_from_url(source) self.pixiv_id = Sources::Strategies::Pixiv.new(source).illust_id_from_url
end end
end end