Class: YoutubeAudio::Format
- Inherits:
-
Object
- Object
- YoutubeAudio::Format
- Defined in:
- lib/youtube_audio/format.rb
Instance Attribute Summary collapse
-
#script_player_url ⇒ Object
readonly
Returns the value of attribute script_player_url.
Instance Method Summary collapse
- #approx_duration_ms ⇒ Object
- #audio? ⇒ Boolean
- #audio_quality ⇒ Object
- #cipher ⇒ Object
-
#initialize(response_raw, script_player_url: nil) ⇒ Format
constructor
A new instance of Format.
- #mime_type ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(response_raw, script_player_url: nil) ⇒ Format
Returns a new instance of Format.
7 8 9 10 |
# File 'lib/youtube_audio/format.rb', line 7 def initialize(response_raw, script_player_url: nil) @script_player_url = script_player_url @response_raw = response_raw end |
Instance Attribute Details
#script_player_url ⇒ Object (readonly)
Returns the value of attribute script_player_url.
5 6 7 |
# File 'lib/youtube_audio/format.rb', line 5 def script_player_url @script_player_url end |
Instance Method Details
#approx_duration_ms ⇒ Object
35 36 37 |
# File 'lib/youtube_audio/format.rb', line 35 def approx_duration_ms @response_raw&.dig('approxDurationMs') end |
#audio? ⇒ Boolean
12 13 14 |
# File 'lib/youtube_audio/format.rb', line 12 def audio? mime_type&.match?('audio/') end |
#audio_quality ⇒ Object
39 40 41 |
# File 'lib/youtube_audio/format.rb', line 39 def audio_quality @response_raw&.dig('audioQuality') end |
#cipher ⇒ Object
27 28 29 |
# File 'lib/youtube_audio/format.rb', line 27 def cipher @response_raw&.dig('cipher') end |
#mime_type ⇒ Object
31 32 33 |
# File 'lib/youtube_audio/format.rb', line 31 def mime_type @response_raw&.dig('mimeType') end |
#url ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/youtube_audio/format.rb', line 16 def url if cipher return UrlDecipher.new( cipher, script_player_url: script_player_url ).decipher end @response_raw&.dig('url') end |