Sha256: d9cbee81dcef3dec0ef36bb1fc09f45510c840173a437d7502e129ce5ec77365

Contents?: true

Size: 622 Bytes

Versions: 6

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

module DownloadTV
  ##
  # Interface for the grabbers
  class LinkGrabber
    attr_reader :url

    def initialize(url)
      @url = url
      @agent = Mechanize.new
      @agent.user_agent = DownloadTV::USER_AGENT
    end

    def online?
      @agent.read_timeout = 2
      url = if @url.include? '%s'
              format(@url, 'test')
            else
              @url
            end
      @agent.head(url)
      true
    rescue Mechanize::ResponseCodeError, Net::HTTP::Persistent::Error
      false
    end

    def get_links(_show)
      raise NotImplementedError
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
download_tv-2.5.5 lib/download_tv/linkgrabber.rb
download_tv-2.5.4 lib/download_tv/linkgrabber.rb
download_tv-2.5.3 lib/download_tv/linkgrabber.rb
download_tv-2.5.2 lib/download_tv/linkgrabber.rb
download_tv-2.5.1 lib/download_tv/linkgrabber.rb
download_tv-2.5.0 lib/download_tv/linkgrabber.rb