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