rget 2.2.4 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rget +10 -19
  3. data/lib/webradio.rb +9 -1
  4. data/rget.gemspec +1 -1
  5. data/rget.yaml +2 -0
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e99c7e9a1b29aac8c9be1b14d24e8fea384ce857
4
- data.tar.gz: 4bb7b4d20b29d4f2af4e453a7bfebeff4f2f87da
3
+ metadata.gz: 813d569b8900605477e89efad7ec9c9b40f8a6aa
4
+ data.tar.gz: ad5ec609930b4d4e682d004422a45e3d2c381f94
5
5
  SHA512:
6
- metadata.gz: af2a08ecfa619c99b0896b77504cf79b11f587262f778d2af210b08f28932b4af6aa63f20784a07cb093b83f3f4fc04b7a7ddd468bf00af91913c59097719b0b
7
- data.tar.gz: e5c2ac0f0fe3662aec0fbbd61f49d41968fc13f8c659eeee20162ba211904c1ab4b932cd1dc0ccaa5b753e1117c614e49aba333524846f14445983778a8c8607
6
+ metadata.gz: 6e3ed3332af62479a99377879f46875998113b5a638d33bb3e03f9940c07f0bc7c2de34736951f79eb95b6b1c54c702e712bcefa09f2dba83fcff20207555e76
7
+ data.tar.gz: 045a14ba979a6f425082da7c6dbd234fbe0de85ee61800f8941be096398a58b702904b5691885fe7e639ed7de9d706c1fcbe6f50b2299a92b52fa20b119ab2a4
data/bin/rget CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'thor'
4
4
  require 'pathname'
5
5
  require 'yaml'
6
+ require 'ostruct'
6
7
  require 'webradio'
7
8
  require 'podcast'
8
9
 
@@ -10,7 +11,7 @@ class GetWebRadio < Thor
10
11
  class_option :mp3, type: :boolean, default:true, desc:'convert to mp3 with ffmpeg'
11
12
  class_option :path, type: :string, desc:'store path (accept "dropbox://~")'
12
13
 
13
- config = nil
14
+ config_file = nil
14
15
  [
15
16
  './rget.yaml',
16
17
  '~/.rget',
@@ -18,38 +19,28 @@ class GetWebRadio < Thor
18
19
  ].each do |file|
19
20
  path = Pathname(file).expand_path
20
21
  if path.exist?
21
- config = path.to_s
22
+ config_file = path.to_s
22
23
  break
23
24
  end
24
25
  end
25
- unless config
26
+ unless config_file
26
27
  $stderr.puts 'config file not found'
27
28
  exit 1
28
29
  end
29
30
 
30
- YAML::load_file(config)['programs'].each do |command, params|
31
+ config = YAML::load_file(config_file)
32
+ config['programs'].each do |command, params|
31
33
  desc command, params['desc']
32
34
  define_method(command) do
35
+ url = params['url']
36
+ opts = OpenStruct.new(config['options'].merge(options))
33
37
  if params['podcast']
34
- podcast(params['url'], params['label'])
38
+ Podcast.new(url, opts){|media|media.download(params['label'])}
35
39
  else
36
- process(params['url'], params['label'])
40
+ WebRadio(url, opts){|media|media.download(params['label'])}
37
41
  end
38
42
  end
39
43
  end
40
-
41
- private
42
- def process(uri, label)
43
- WebRadio(uri, options) do |radio|
44
- radio.download(label)
45
- end
46
- end
47
-
48
- def podcast(uri, label = nil)
49
- Podcast.new(uri, options) do |pod|
50
- pod.download(label)
51
- end
52
- end
53
44
  end
54
45
 
55
46
  GetWebRadio.start(ARGV)
data/lib/webradio.rb CHANGED
@@ -80,7 +80,15 @@ private
80
80
 
81
81
  # convert to mp3
82
82
  print "converting to mp3..."
83
- result = Open3.capture3("ffmpeg -i #{src} -ab 64k #{dst}")
83
+ ffmpeg = (@options['mp3nize'] || "ffmpeg -i '$1' -ab 64k '$2'").gsub(/\$(.)/){|s|
84
+ case $1
85
+ when '1'; src
86
+ when '2'; dst
87
+ when '$'; '$'
88
+ else; s
89
+ end
90
+ }
91
+ result = Open3.capture3(ffmpeg)
84
92
  if result[2].to_i == 0
85
93
  File.delete(src) if delete_src
86
94
  puts "done."
data/rget.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rget"
7
- spec.version = "2.2.4"
7
+ spec.version = "2.3.0"
8
8
  spec.authors = ["TADA Tadashi"]
9
9
  spec.email = ["t@tdtds.jp"]
10
10
  spec.description = %q{Downloading newest radio programs on the web. Supported radio stations are hibiki, animate, onsen, seaside communications, niconico and youtube.}
data/rget.yaml CHANGED
@@ -1,3 +1,5 @@
1
+ options:
2
+ mp3nize: ffmpeg -i '$1' -ab 64k '$2'
1
3
  programs:
2
4
  imas_cg:
3
5
  desc: デレラジA (THE IDOLM@STERシンデレラガールズラジオ)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rget
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor