Sha256: 58116fc30717dd39c6f4ec335e141ff863acd3d957352bc886e536ef1f550e10

Contents?: true

Size: 641 Bytes

Versions: 4

Compression:

Stored size: 641 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, Errno::ECONNRESET
      false
    end

    def get_links(_show)
      raise NotImplementedError
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
download_tv-2.6.3 lib/download_tv/linkgrabber.rb
download_tv-2.6.2 lib/download_tv/linkgrabber.rb
download_tv-2.6.1 lib/download_tv/linkgrabber.rb
download_tv-2.6.0 lib/download_tv/linkgrabber.rb