Class: Oddb2xml::ZurroseDownloader
- Inherits:
-
Downloader
- Object
- Downloader
- Oddb2xml::ZurroseDownloader
- Includes:
- DownloadMethod
- Defined in:
- lib/oddb2xml/downloader.rb
Instance Attribute Summary
Attributes inherited from Downloader
Instance Method Summary collapse
Methods inherited from Downloader
Constructor Details
This class inherits a constructor from Oddb2xml::Downloader
Instance Method Details
#download ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/oddb2xml/downloader.rb', line 149 def download @url ||= 'http://pillbox.oddb.org/TRANSFER.ZIP' unless @url =~ /^http/ io = File.open(@url, 'r:iso-8859-1:utf-8') content = io.read Oddb2xml.log("ZurroseDownloader #{__LINE__} download #{@url} @url returns #{content.bytes}") content else file = File.join(Downloads, 'transfer.zip') unless Oddb2xml.skip_download(file) Oddb2xml.log "ZurroseDownloader #{__LINE__}: #{file}" begin response = @agent.get(@url) response.save_as(file) response = nil # win rescue Timeout::Error, Errno::ETIMEDOUT retrievable? ? retry : raise ensure Oddb2xml.download_finished(file) end end read_xml_from_zip(/transfer.dat/, file) dest = File.join(Downloads, 'transfer.dat') File.open(dest, 'r:iso-8859-1:utf-8').read end end |