Class: Scry::ExportDownloader

Inherits:
Object
  • Object
show all
Includes:
Helpers, Sidekiq::Worker
Defined in:
lib/scry/sidekiq/workers/export_downloader.rb

Overview

Works on downloading an export.

Will attempt 5 times before giving up.

Instance Method Summary collapse

Methods included from Helpers

#click_link, #write_log

Instance Method Details

#perform(cookie_crumbs, course_url, download_url) ⇒ Object

Instigates downloading an export.

Creates a course from the cookies, then starts downloading the export.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/scry/sidekiq/workers/export_downloader.rb', line 25

def perform(cookie_crumbs, course_url, download_url)
  course = Course.from_cookies(cookie_crumbs, course_url)
  uri = URI.parse(course_url)
  uri.path = download_url
  course.download_export(uri.to_s)
  write_log(Scry.export_download_good, course_url)
rescue SocketError, Mechanize::Error, Net::HTTPClientError => e
  write_log(
    Scry.export_download_bad,
    "#{course_url} #{e.class} #{e.message}",
  )
  raise
end