class Worldfootball::Metal
todo/check: put in Downloader namespace/class - why? why not?
or use Metal - no "porcelain" downloaders / machinery
Constants
- BASE_URL
Public Class Methods
download_report( slug, cache: true )
click to toggle source
# File lib/webget-football/worldfootball/download.rb, line 81 def self.download_report( slug, cache: true ) url = report_url( slug ) ## check check first if cache && Webcache.cached?( url ) puts " reuse local (cached) copy >#{Webcache.url_to_id( url )}<" else download_page( url ) end end
download_reports_for_schedule( slug, cache: true )
click to toggle source
# File lib/webget-football/worldfootball/download.rb, line 93 def self.download_reports_for_schedule( slug, cache: true ) ## todo/check: rename to reports_for_schedule or such - why? why not? page = Page::Schedule.from_cache( slug ) matches = page.matches puts "matches - #{matches.size} rows:" pp matches[0] puts "#{page.generated_in_days_ago} - #{page.generated}" ## todo/fix: restore sleep to old value at the end!!!! ## Webget.config.sleep = 8 ## fetch 7-8 pages/min matches.each_with_index do |match,i| est = (Webget.config.sleep * (matches.size-(i+1)))/60.0 # estimated time left puts "fetching #{i+1}/#{matches.size} (#{est} min(s)) - #{match[:round]} | #{match[:team1]} v #{match[:team2]}..." report_ref = match[:report_ref ] if report_ref download_report( report_ref, cache: cache ) else puts "!! WARN: report ref missing for match:" pp match end end end
download_schedule( slug )
click to toggle source
www.weltfussball.de/alle_spiele/fra-ligue-2-2019-2020/ www.weltfussball.de/alle_spiele/ita-serie-b-2019-2020/ www.weltfussball.de/alle_spiele/rus-premier-liga-2019-2020/ www.weltfussball.de/alle_spiele/rus-1-division-2019-2020/ www.weltfussball.de/alle_spiele/tur-sueperlig-2019-2020/ www.weltfussball.de/alle_spiele/tur-1-lig-2019-2020/
# File lib/webget-football/worldfootball/download.rb, line 76 def self.download_schedule( slug ) url = schedule_url( slug ) download_page( url ) end
report_url( slug )
click to toggle source
# File lib/webget-football/worldfootball/download.rb, line 50 def self.report_url( slug ) "#{BASE_URL}/spielbericht/#{slug}/"; end
schedule_url( slug )
click to toggle source
# File lib/webget-football/worldfootball/download.rb, line 49 def self.schedule_url( slug ) "#{BASE_URL}/alle_spiele/#{slug}/"; end