Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/alexis/youtube_it into al…
Browse files Browse the repository at this point in the history
…exis-master
  • Loading branch information
kylejginavan committed Apr 8, 2011
2 parents 3b200aa + 5541784 commit 7554afe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/youtube_it/request/video_upload.rb
Expand Up @@ -472,22 +472,26 @@ def parse_upload_error_from(string)
msg_error = error.elements["internalReason"].text
elsif error.elements["location"]
msg_error = error.elements["location"].text[/media:group\/media:(.*)\/text\(\)/,1]
else
msg_error = "Unspecified error"
end
code = error.elements["code"].text if error.elements["code"]
all_faults + sprintf("%s: %s\n", msg_error, code)
end
rescue
string
string[/<TITLE>(.+)<\/TITLE>/, 1] || string
end
end

def raise_on_faulty_response(response)
response_code = response.code.to_i
msg = parse_upload_error_from(response.body.gsub(/\n/, ''))

if response_code == 403 || response_code == 401
#if response_code / 10 == 40
raise AuthenticationError, response.body[/<TITLE>(.+)<\/TITLE>/, 1]
raise AuthenticationError, msg
elsif response_code / 10 != 20 # Response in 20x means success
raise UploadError, parse_upload_error_from(response.body.gsub(/\n/,''))
raise UploadError, msg
end
end

Expand Down

0 comments on commit 7554afe

Please sign in to comment.