Sha256: dd7c97a76064b0b318c635b19070e68d8a6e3b52302edfc7a324a8f806730ea8

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 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 do |a|
        a.user_agent = DownloadTV::USER_AGENT
        a.read_timeout = 2
      end
    end

    def online?
      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

1 entries across 1 versions & 1 rubygems

Version Path
download_tv-2.6.4 lib/download_tv/linkgrabber.rb