Sha256: f9dadd8f73dbdf0ad26af16d89a88bd20bd31aea9ee589de3b0ac04626d945a0

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'download_tv'

options = {}
options[:offset] = 0
options[:auto] = true
options[:subs] = true
options[:dry] = false
options[:cmd] = "run"

opt_parser = OptionParser.new do |opts|
	opts.banner = "Usage: tv [options]"

	opts.separator ""
	opts.separator "Specific options:"

	opts.on("-o", "--offset OFFSET", Integer, "Move back the last run offset") do |o|
		options[:offset] = o
	end

	opts.on("-f", "--file PATH", "Download shows from a file") do |f|
		options[:cmd] = "file"
		options[:arg] = f
	end

	opts.on("-d", "--download SHOW", "Downloads given show") do |s|
		options[:cmd] = "dl"
		options[:arg] = s
	end

	opts.on("-c", "--configure", "Configures defaults") do
		options[:cmd] = "config"
	end

	opts.on("--dry-run", "Don't write to the date file") do |n|
		options[:dry] = n
	end

	opts.on("-a", "--[no-]auto", "Automatically find links") do |n|
		options[:auto] = n
	end

	opts.on("-s", "--[no-]subtitles", "Download subtitles") do |n|
		options[:subs] = n
	end

	opts.on_tail("-h", "--help", "Show this message") do
		puts opts
		exit
	end
end

opt_parser.parse!(ARGV)

begin
	dl = DownloadTV::Downloader.new(options[:offset], options[:auto], options[:subs])
	case options[:cmd]
		when "run"
			dl.run(options[:dry])
		when "dl"
			dl.download_single_show(options[:arg])
		when "file"
			dl.download_from_file(options[:arg])
		when "config"
			DownloadTV::Configuration.new true
	end
rescue Interrupt
	puts "Interrupt signal detected. Exiting..."
	exit 1
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
download_tv-2.0.4 bin/tv
download_tv-2.0.3 bin/tv