Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # このコードは @taroyanaka様 が書いてくれた以下の記事をコピーし、必要な部分だけ残したものです。
- # https://qiita.com/taroyanaka/items/c40f8d5df3ea67ba0b5a
- require 'open3'
- class Mediadl
- def initialize(file_name="./download_urls.txt")
- @file = file_name
- end
- def line_counter
- File.open(@file) do |f|
- while f.gets
- @total_lines = f.lineno
- end
- end
- return @total_lines
- end
- def dl
- counter = 0
- total_lines = self.line_counter
- File.open(@file,'r').each do |url|
- counter += 1
- puts "start file:#{counter}/#{total_lines}"
- Open3.capture3('youtube-dl -f mp4 ' + "#{url}")
- puts "finish file:#{counter}/#{total_lines}"
- end
- Process.waitall
- end
- end
- download = Mediadl.new
- download.dl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement