Skip to content

Instantly share code, notes, and snippets.

@kimoto
Created March 1, 2012 02:05
Show Gist options
  • Select an option

  • Save kimoto/1946658 to your computer and use it in GitHub Desktop.

Select an option

Save kimoto/1946658 to your computer and use it in GitHub Desktop.
Fetch YouTube favorite video list
#!/bin/env ruby
# encoding: utf-8
# Author: kimoto
require 'youtube_it'
def all_fetch_favorite_videos(username, password, dev_key)
client = YouTubeIt::Client.new(
:username => username,
:password => password,
:dev_key => dev_key
)
all_videos = []
page = 0
per_page = 20
while true
videos = client.videos_by(:favorites, :user => username, :page => page, :per_page => per_page).videos.map(&:player_url)
all_videos += videos
if videos.size != 20
break
end
page += 1
end
all_videos
end
if $0 == __FILE__
config = {
:username => '',
:password => '',
:dev_key => ''
}
puts all_fetch_favorite_videos(config[:username], config[:password], config[:dev_key]).join($/)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment