Class: YoutubeAudio::ExtractDecodeFunction
- Inherits:
-
Object
- Object
- YoutubeAudio::ExtractDecodeFunction
- Defined in:
- lib/youtube_audio/extract_decode_function.rb
Constant Summary collapse
- CIPHER_TEST =
Regexp.new('([\\w$]+)\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(""\\)\\s*;')
Instance Attribute Summary collapse
-
#player_script ⇒ Object
readonly
Returns the value of attribute player_script.
Instance Method Summary collapse
- #cipher_helper_object_name ⇒ Object
- #cipher_helpers_object ⇒ Object
- #decipher_function ⇒ Object
- #decryption_function ⇒ Object
-
#initialize(player_script) ⇒ ExtractDecodeFunction
constructor
A new instance of ExtractDecodeFunction.
Constructor Details
#initialize(player_script) ⇒ ExtractDecodeFunction
Returns a new instance of ExtractDecodeFunction.
8 9 10 |
# File 'lib/youtube_audio/extract_decode_function.rb', line 8 def initialize(player_script) @player_script = player_script end |
Instance Attribute Details
#player_script ⇒ Object (readonly)
Returns the value of attribute player_script.
5 6 7 |
# File 'lib/youtube_audio/extract_decode_function.rb', line 5 def player_script @player_script end |
Instance Method Details
#cipher_helper_object_name ⇒ Object
12 13 14 15 |
# File 'lib/youtube_audio/extract_decode_function.rb', line 12 def cipher_helper_object_name @cipher_helper_object_name ||= decipher_function.scan(/\;([a-zA-Z0-9]{0,255})\./).flatten.first end |
#cipher_helpers_object ⇒ Object
17 18 19 20 21 |
# File 'lib/youtube_audio/extract_decode_function.rb', line 17 def cipher_helpers_object object_decibper_index = player_script.index("var #{cipher_helper_object_name}={") object_decibper_index_end = player_script[object_decibper_index..-1].index('};') player_script[object_decibper_index..object_decibper_index + object_decibper_index_end] end |
#decipher_function ⇒ Object
23 24 25 26 |
# File 'lib/youtube_audio/extract_decode_function.rb', line 23 def decipher_function @decipher_function ||= player_script.scan(Regexp.new(function_pattern)).flatten.first end |
#decryption_function ⇒ Object
28 29 30 |
# File 'lib/youtube_audio/extract_decode_function.rb', line 28 def decryption_function @decryption_function ||= player_script.scan(CIPHER_TEST).flatten.first end |