Skip to content

Instantly share code, notes, and snippets.

@amalagaura
Created January 19, 2015 22:38
Show Gist options
  • Save amalagaura/8821f2b26cc3b00a1b13 to your computer and use it in GitHub Desktop.
Save amalagaura/8821f2b26cc3b00a1b13 to your computer and use it in GitHub Desktop.
comments_with_meta for YoutubeIt
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