lib/downloader.rb in narou-3.4.8 vs lib/downloader.rb in narou-3.5.0
- old
+ new
@@ -723,11 +723,11 @@
max_retry = 5
toc_source = ""
cookie = @setting["cookie"] || ""
open_uri_options = make_open_uri_options("Cookie" => cookie, allow_redirections: :safe)
begin
- open(toc_url, open_uri_options) do |toc_fp|
+ URI.open(toc_url, open_uri_options) do |toc_fp|
if toc_fp.base_uri.to_s != toc_url
# リダイレクトされた場合。
# ノクターン・ムーンライトのNコードを ncode.syosetu.com に渡すと、年齢認証のクッションページに飛ばされる
# 転送先を取得し再度ページを取得し直す
uri = URI.parse(toc_fp.base_uri.to_s)
@@ -1090,11 +1090,11 @@
end
raw = download_raw_data(subtitle_url)
save_raw_data(raw, subtitle_info, ".html")
%w(introduction postscript body).each { |type| @setting[type] = nil }
@setting.multi_match(raw, "body_pattern", "introduction_pattern", "postscript_pattern")
- element = { "data_type" => "html" }
+ element = { "data_type" => @setting["data_type"] || "html" }
%w(introduction postscript body).each { |type|
element[type] = @setting[type].to_s
}
subtitle_info["download_time"] = Time.now
@section_download_cache[index] = element
@@ -1130,10 +1130,10 @@
raw = nil
retry_count = LIMIT_TO_RETRY_NETWORK
cookie = @setting["cookie"] || ""
begin
open_uri_options = make_open_uri_options("Cookie" => cookie, allow_redirections: :safe)
- open(url, "r:#{@setting["encoding"]}", open_uri_options) do |fp|
+ URI.open(url, "r:#{@setting["encoding"]}", open_uri_options) do |fp|
raw = Helper.pretreatment_source(fp.read, @setting["encoding"])
end
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout => e
case e.message
when /^503/