Class: PinterestDL::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pinterest_dl/configuration.rb

Constant Summary collapse

DEFAULT_USER_AGENT =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' \
'(KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
VALID_QUALITIES =
%i[originals 736x 474x 236x].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pinterest_dl/configuration.rb', line 19

def initialize
  @user_agent = DEFAULT_USER_AGENT
  @cookies = nil
  @open_timeout = 10
  @read_timeout = 20
  @max_retries = 3
  @retry_wait = 1.0
  @quality = :originals
  @rate_limit_interval = 0.0
  @logger = Logger.new($stdout).tap do |log|
    log.level = Logger::WARN
    log.formatter = proc { |severity, _time, _progname, msg| "[pinterest-dl] #{severity}: #{msg}\n" }
  end
end

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def cookies
  @cookies
end

#loggerObject

Returns the value of attribute logger.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def logger
  @logger
end

#max_retriesObject

Returns the value of attribute max_retries.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def max_retries
  @max_retries
end

#open_timeoutObject

Returns the value of attribute open_timeout.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def open_timeout
  @open_timeout
end

#qualityObject

Returns the value of attribute quality.



17
18
19
# File 'lib/pinterest_dl/configuration.rb', line 17

def quality
  @quality
end

#rate_limit_intervalObject

Returns the value of attribute rate_limit_interval.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def rate_limit_interval
  @rate_limit_interval
end

#read_timeoutObject

Returns the value of attribute read_timeout.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def read_timeout
  @read_timeout
end

#retry_waitObject

Returns the value of attribute retry_wait.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def retry_wait
  @retry_wait
end

#user_agentObject

Returns the value of attribute user_agent.



13
14
15
# File 'lib/pinterest_dl/configuration.rb', line 13

def user_agent
  @user_agent
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/pinterest_dl/configuration.rb', line 42

def authenticated?
  !cookies.nil? && !cookies.to_s.empty?
end