Fix #2460: Uploading pixiv user's background image throws error.
Fix exception when uploading these types of URLs: * http://img12.pixiv.net/profile/rapattu/119950.jpg * http://i2.pixiv.net/img130/profile/minono_aki/8733472.jpg * http://i2.pixiv.net/img20/img/a-park/novel/3607898.jpg * http://i1.pixiv.net/novel-cover-original/img/2016/11/03/20/10/58/7436075_f75af69f3eacd1656d3733c72aa959cf.jpg * http://i1.pixiv.net/background/img/2016/05/17/12/05/48/2074388_d4ac52034f7ca0af3e083d59fde7e97f.jpg Skip rewriting sources that don't have illust IDs to avoid this exception. Also fix `tags` so that it doesn't blow up when fetching source data for these types of sources.
This commit is contained in:
@@ -8,9 +8,12 @@ module Downloads
|
||||
end
|
||||
|
||||
def rewrite(url, headers, data = {})
|
||||
if url =~ /https?:\/\/(?:\w+\.)?pixiv\.net/
|
||||
if url =~ /\Ahttps?:\/\/(?:\w+\.)?pixiv\.net/
|
||||
url, headers = rewrite_headers(url, headers)
|
||||
url, headers = rewrite_cdn(url, headers)
|
||||
end
|
||||
|
||||
if url =~ /\Ahttps?:\/\/(?:\w+\.)?pixiv\.net/ && source.illust_id_from_url
|
||||
url, headers = rewrite_html_pages(url, headers)
|
||||
url, headers = rewrite_thumbnails(url, headers)
|
||||
url, headers = rewrite_old_small_manga_pages(url, headers)
|
||||
|
||||
@@ -7,7 +7,7 @@ module Sources
|
||||
:profile_url, :image_url, :tags, :artist_record, :unique_id,
|
||||
:page_count, :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls,
|
||||
:has_artist_commentary?, :artist_commentary_title,
|
||||
:artist_commentary_desc, :rewrite_thumbnails, :to => :strategy
|
||||
:artist_commentary_desc, :rewrite_thumbnails, :illust_id_from_url, :to => :strategy
|
||||
|
||||
def self.strategies
|
||||
[Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr]
|
||||
|
||||
@@ -74,6 +74,10 @@ module Sources
|
||||
[image_url]
|
||||
end
|
||||
|
||||
def tags
|
||||
@tags || []
|
||||
end
|
||||
|
||||
# Should be set to a url for sites that prevent hotlinking, or left nil for sites that don't.
|
||||
def fake_referer
|
||||
nil
|
||||
|
||||
@@ -65,7 +65,8 @@ module Sources
|
||||
end
|
||||
|
||||
def get
|
||||
@illust_id = illust_id_from_url!
|
||||
return unless illust_id_from_url
|
||||
@illust_id = illust_id_from_url
|
||||
@metadata = get_metadata_from_papi(@illust_id)
|
||||
|
||||
page = agent.get(URI.parse(normalized_url))
|
||||
|
||||
Reference in New Issue
Block a user