Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

raise for error condition

  • Loading branch information...
commit 473e33cd1b048e64e87cb3825aafdc1ef1cadf35 1 parent 9dd89a3
xue yong zhi authored
Showing with 8 additions and 11 deletions.
  1. +8 −11 lib/youtube_utils.rb
View
19 lib/youtube_utils.rb
@@ -15,20 +15,17 @@ def initialize(debug = false)
def get_videos youtube_watch_url
res = get_webpage(youtube_watch_url);
unless res.code == '200'
- puts res.code
- return []
+ raise res.code
end
- hash = json_to_hash(get_PLAYER_CONFIG(res.body))
- unless hash
- puts "no PLAYER_CONFIG"
- return []
+ play_config = get_PLAYER_CONFIG(res.body)
+ unless play_config
+ raise "no PLAYER_CONFIG"
end
- args = hash['args']
+ args = json_to_hash(play_config)['args']
unless args
- puts "no args"
- return []
+ raise "no args"
end
result = []
@@ -151,8 +148,8 @@ def json_to_hash js
end
def get_PLAYER_CONFIG body
- puts boby if @debug
- body[/\'PLAYER_CONFIG\':(.*)\}\)\;\n/]
+ #puts boby if @debug
+ body[/\'PLAYER_CONFIG\':(.*),\n/]
puts $1 if @debug
return $1
end
Please sign in to comment.
Something went wrong with that request. Please try again.