Class: YoutubeAudio::PlayerResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/youtube_audio/player_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response_raw) ⇒ PlayerResponse

Returns a new instance of PlayerResponse.



6
7
8
# File 'lib/youtube_audio/player_response.rb', line 6

def initialize(response_raw)
  @response_raw = response_raw
end

Instance Method Details

#formatsObject



10
11
12
13
14
# File 'lib/youtube_audio/player_response.rb', line 10

def formats
  (@response_raw&.dig('streamingData', 'adaptiveFormats') || []).map do |f|
    to_youtube_format(f)
  end
end

#to_youtube_format(format_raw) ⇒ Object



16
17
18
# File 'lib/youtube_audio/player_response.rb', line 16

def to_youtube_format(format_raw)
  Format.new(format_raw)
end