Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #62 from rexly/master

properly encode ampersand in video search
  • Loading branch information...
commit eb098e26e87aaebd9487e2b4c1078926f791366c 2 parents 1f20b37 + 8e49418
@kylejginavan kylejginavan authored
View
3  lib/youtube_it.rb
@@ -19,8 +19,7 @@ def initialize(msg, code = 0)
end
def self.esc(s) #:nodoc:
- # URI encodes correctly Unicode characters
- URI.encode(s.to_s.tr(' ','+'))
+ CGI.escape(s.to_s)
end
# Set the logger for the library
View
12 lib/youtube_it/client.rb
@@ -228,20 +228,25 @@ def my_videos(opts = {})
client.get_my_videos(opts)
end
- # Get's all of the user's contacts/friends.
+ # Gets all of the user's contacts/friends.
def my_contacts(opts = {})
client.get_my_contacts(opts)
end
- # Send vedio message
+ # Send video message
def send_message(opts = {})
client.send_message(opts)
end
- # Get's all of the user's messages/inbox.
+ # Gets all of the user's messages/inbox.
def my_messages(opts = {})
client.get_my_messages(opts)
end
+
+ # Gets the user's watch history
+ def watch_history
+ client.get_watch_history
+ end
private
@@ -413,6 +418,7 @@ def initialize(options)
@client_refresh_token = options[:client_refresh_token]
@client_token_expires_at = options[:client_token_expires_at]
@dev_key = options[:dev_key]
+ @legacy_debug_flag = options[:debug]
end
def oauth_client
View
4 lib/youtube_it/request/base_search.rb
@@ -52,6 +52,10 @@ def fields_to_params(fields)
if fields[:view_count]
fields_param << "entry[yt:statistics/@viewCount > #{fields[:view_count]}]"
end
+
+ if fields[:entry]
+ fields_param << "entry[#{fields[:entry]}]"
+ end
return "&fields=#{URI.escape(fields_param.join(","))}"
View
7 lib/youtube_it/request/video_upload.rb
@@ -348,6 +348,13 @@ def delete_response(original_video_id, response_video_id)
return {:code => response.status, :body => response.body}
end
+
+ def get_watch_history
+ watch_history_url = "/feeds/api/users/default/watch_history?v=2"
+ response = yt_session.get(watch_history_url)
+
+ return YouTubeIt::Parser::VideosFeedParser.new(response.body).parse
+ end
private
View
13 test/test_client.rb
@@ -279,7 +279,7 @@ def test_should_update_playlist
def test_should_list_playlist_for_user
result = @client.playlists('chebyte')
- assert result.last.title, "rock"
+ assert_equal "rock", result.last.title
end
def test_should_determine_if_widescreen_video_is_widescreen
@@ -290,7 +290,7 @@ def test_should_determine_if_widescreen_video_is_widescreen
end
def test_get_current_user
- assert_equal @client.current_user, 'tubeit20101'
+ assert_equal 'tubeit20101', @client.current_user
end
def test_should_get_my_videos
@@ -347,7 +347,7 @@ def test_should_list_subscriptions
def test_should_get_profile
profile = @client.profile
- assert_equal profile.username, "tubeit20101"
+ assert_equal "tubeit20101", profile.username
end
def test_should_add_and_delete_video_to_favorite
@@ -360,7 +360,12 @@ def test_should_add_and_delete_video_to_favorite
def test_esc
result = YouTubeIt.esc("спят усталые игрушки")
- assert result, "спят+усталые+игрушки"
+ assert_equal "%D1%81%D0%BF%D1%8F%D1%82+%D1%83%D1%81%D1%82%D0%B0%D0%BB%D1%8B%D0%B5+%D0%B8%D0%B3%D1%80%D1%83%D1%88%D0%BA%D0%B8", result
+ end
+
+ def test_should_encode_ampersand
+ result = YouTubeIt.esc("such & such")
+ assert_equal "such+%26+such", result
end
def test_unicode_query
Please sign in to comment.
Something went wrong with that request. Please try again.