-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl.rb
35 lines (30 loc) · 1.12 KB
/
dl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'optparse'
require_relative 'rtl'
if RTL.ffmpeg?
puts "Using ffmpeg version: #{RTL.ffmpeg_version}"
else
puts 'Error: ffpmeg is not installed on this system. Please install the necessary packages before you continue.'
exit
end
ARGV << '-h' if ARGV.empty?
@options = {
quality: '1280x720',
verbose: false,
target: __dir__
}
OptionParser.new do |opts|
opts.banner = 'Usage: ruby dl.rb <URL> [options]'
opts.on('-1', '--low', 'Low quality (640x360)') do |v| @options[:quality] = '640x360' end
opts.on('-2', '--average', 'Average quality (854x480)') do |v| @options[:quality] = '854x480' end
opts.on('-3', '--high', 'High quality (1280x720)') do |v| @options[:quality] = '1280x720' end
opts.on('-4', '--highest', 'Highest quality (1920x1080)') do |v| @options[:quality] = '1920x1080' end
opts.on('-v', '--verbose', 'Verbose mode') do |v| @options[:verbose] = true end
opts.on('-o', '--output=FOLDER', 'Specify output folder (optional)') do |v| @options[:target] = v end
opts.on_tail('-h', '--help', 'Show help message') do
puts opts
exit
end
end.parse!
ARGV.each do |url|
RTL.parse(url, @options)
end