Skip to content

Commit

Permalink
Fixed response code 201 being interpreted as error. Started using Xml…
Browse files Browse the repository at this point in the history
…Markup instead of XML.
  • Loading branch information
Andrius Chamentauskas authored and tmm1 committed Dec 1, 2009
1 parent eec9bee commit f1aab7a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/youtube_g/request/video_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def parse_upload_error_from(string)
def raise_on_faulty_response(response)
if response.code.to_i == 403
raise AuthenticationError, response.body[/<TITLE>(.+)<\/TITLE>/, 1]
elsif response.code.to_i != 200
elsif response.code.to_i / 10 != 20 # Response in 20x means success
raise UploadError, parse_upload_error_from(response.body)
end
end
Expand Down Expand Up @@ -185,14 +185,14 @@ def auth_token

# TODO: isn't there a cleaner way to output top-notch XML without requiring stuff all over the place?
def video_xml
b = Builder::XML.new
b = Builder::XmlMarkup.new
b.instruct!
b.entry(:xmlns => "http://www.w3.org/2005/Atom", 'xmlns:media' => "http://search.yahoo.com/mrss/", 'xmlns:yt' => "http://gdata.youtube.com/schemas/2007") do | m |
m.tag!("media:group") do | mg |
mg.tag!("media:title", :type => "plain") { @opts[:title] }
mg.tag!("media:description", :type => "plain") { @opts[:description] }
mg.tag!("media:keywords") { @opts[:keywords].join(",") }
mg.tag!('media:category', :scheme => "http://gdata.youtube.com/schemas/2007/categories.cat") { @opts[:category] }
mg.tag!("media:title", @opts[:title], :type => "plain")
mg.tag!("media:description", @opts[:description], :type => "plain")
mg.tag!("media:keywords", @opts[:keywords].join(","))
mg.tag!('media:category', @opts[:category], :scheme => "http://gdata.youtube.com/schemas/2007/categories.cat")
mg.tag!('yt:private') if @opts[:private]
end
end.to_s
Expand All @@ -215,4 +215,4 @@ def generate_upload_io(video_xml, data)

end
end
end
end

0 comments on commit f1aab7a

Please sign in to comment.