Skip to content

Instantly share code, notes, and snippets.

@ParthBarot-BoTreeConsulting
Last active August 10, 2017 09:54
Show Gist options
  • Save ParthBarot-BoTreeConsulting/4ed1a71864ff17160bd0db032251036e to your computer and use it in GitHub Desktop.
Save ParthBarot-BoTreeConsulting/4ed1a71864ff17160bd0db032251036e to your computer and use it in GitHub Desktop.
Youtube API integration using YT gem
#
# Old code, which has a loop and sends API call for each video ID
#
video_ids.map do |video_id|
Yt::Video.new(id: video_id).select(:snippet, :content_details, :statistics, :status)
end
#
#New code, which fetches all the videos (max upto 12 IDs only) at once
#
Yt::Collections::Videos.new.where(id: video_ids, #video_ids has at max 12 ids only!
part: 'id,snippet,content_details,statistics,status'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment