Class: YoutubeAudio::Formats

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Formats

Returns a new instance of Formats.

Parameters:

  • url (String)

    youtube link



9
10
11
# File 'lib/youtube_audio/formats.rb', line 9

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlString (readonly)

Returns:

  • (String)


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

def url
  @url
end

Instance Method Details

#formatsObject



13
14
15
# File 'lib/youtube_audio/formats.rb', line 13

def formats
  player_response.formats.select(&:audio?)
end

#player_responseObject



17
18
19
# File 'lib/youtube_audio/formats.rb', line 17

def player_response
  @player_response ||= ScriptParser.new(script_js).player_response
end