Sha256: c197ebec07b9e4c1fdb158ee6dffb3303bcf375a2a7edb33097d5dddbc7d38da

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby

require 'thor'
require 'pathname'
require 'yaml'
require 'ostruct'
require 'webradio'
require 'podcast'

class GetWebRadio < Thor
	class_option :mp3, type: :boolean, default:true, desc:'convert to mp3 with ffmpeg'
	class_option :path, type: :string, desc:'store path (accept "dropbox://~")'

	config_file = nil
	[
		'./rget.yaml',
		'~/.rget',
		"#{Pathname(__dir__)}/../rget.yaml",
	].each do |file|
		path = Pathname(file).expand_path
		if path.exist?
			config_file = path.to_s
			break
		end
	end
	unless config_file
		$stderr.puts 'config file not found'
		exit 1
	end

	config = YAML::load_file(config_file)
	config['programs'].each do |command, params|
		desc command, params['desc']
		define_method(command) do
			url = params['url']
			opts = OpenStruct.new(config['options'].merge(options))
			if params['podcast']
				Podcast.new(url, opts){|media|media.download(params['label'])}
			else
				WebRadio(url, opts){|media|media.download(params['label'])}
			end
		end
	end
end

GetWebRadio.start(ARGV)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rget-2.3.2 bin/rget
rget-2.3.1 bin/rget
rget-2.3.0 bin/rget