Sha256: 1b0ea1e07380922a473d4887ab8c614f50753d49267609701485f3854b9bc764

Contents?: true

Size: 653 Bytes

Versions: 2

Compression:

Stored size: 653 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 = 10
      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

2 entries across 2 versions & 1 rubygems

Version Path
download_tv-2.6.6 lib/download_tv/linkgrabber.rb
download_tv-2.6.5 lib/download_tv/linkgrabber.rb