Created
January 19, 2015 22:38
-
-
Save amalagaura/8821f2b26cc3b00a1b13 to your computer and use it in GitHub Desktop.
comments_with_meta for YoutubeIt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YouTubeIt::Upload::VideoUpload | |
def comments_with_meta(video_id_or_url, opts = {}) | |
url = if video_id_or_url.start_with?('http') | |
video_id_or_url | |
else | |
comment_url = "/feeds/api/videos/%s/comments?" % video_id_or_url | |
comment_url << opts.collect { |k, p| [k, p].join '=' }.join('&') | |
end | |
response = yt_session.get(url) | |
comments = YouTubeIt::Parser::CommentsFeedParser.new(response).parse | |
xml = Nokogiri::XML(response.body) | |
next_link = xml.at(:css, 'link[rel=next]') | |
url = next_link.nil? ? nil : next_link['href'] | |
{ comments: comments, next_link: url } | |
end | |
end | |
class YouTubeIt::Client | |
def comments_with_meta(video_id_or_url, opts = {}) | |
client.comments_with_meta(video_id_or_url, opts) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment