Module: Ydj

Defined in:
lib/ydj.rb,
lib/ydj/version.rb

Constant Summary collapse

VERSION =
"0.0.5"

Class Method Summary collapse

Class Method Details

.download(channel) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ydj.rb', line 4

def self.download(channel)
  client = YouTubeIt::Client.new
  puts "Downloading #{channel}..."
  page = 1
  array = []
  while urls = client.videos_by(:user => channel, :per_page => 50, :page => page).videos.collect{|v| v.player_url} and urls.any?
    puts "Page #{page}, found #{urls.count} videos"
    urls.each do |url|
      array << url
    end
    page = page + 1
  end
  File.open('list', 'w') {|f| f.write(array.join("\n"))}
end