uploads/batch now supports pixiv

This commit is contained in:
r888888888
2015-03-15 13:56:16 -07:00
parent 709943b627
commit 2d266fc0b6
7 changed files with 1881 additions and 5 deletions

View File

@@ -67,6 +67,10 @@ module Sources
template.params[:ref] || template.params[:url]
end
def image_urls
[image_url]
end
protected
def agent
raise NotImplementedError

View File

@@ -63,6 +63,7 @@ module Sources
@zip_url, @ugoira_frame_data, @ugoira_content_type = get_zip_url_from_page(page)
@tags = get_tags_from_page(page)
@page_count = get_page_count_from_page(page)
@gallery_link = get_gallery_link(page)
is_manga = @page_count > 1
@@ -86,9 +87,30 @@ module Sources
def file_url
image_url || zip_url
end
def image_urls
results = []
if @gallery_link
agent.get("http://www.pixiv.net/" + @gallery_link) do |page|
results = page.search("a.full-size-container").map {|x| "http://www.pixiv.net" + x.attr("href")}
end
end
results
end
protected
def get_gallery_link(page)
link = page.search("a.multiple").first
if link
link.attr("href")
else
nil
end
end
# 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
def rewrite_new_medium_images(thumbnail_url)

View File

@@ -18,5 +18,9 @@ module Sources::Strategies
@profile_url = "https://twitter.com/" + attrs[:user][:screen_name]
@image_url = attrs[:entities][:media][0][:media_url] + ":orig"
end
def image_urls
TwitterService.new.image_urls(url)
end
end
end