rget 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1d75196a6acef38d594dd860a9cf4fece40efd0
4
- data.tar.gz: 6552d578e32c479e8769eed425e1473b5b9b937e
3
+ metadata.gz: db7ca2a7888ae0141a1478525ec3c3338dcf1645
4
+ data.tar.gz: 385a19c4d0af62a476932ed5207db91c514ae5ec
5
5
  SHA512:
6
- metadata.gz: 1db1697a12e359844606500b5e27c1fe188eeedf3695836745abb0297c3ba2887a3645b4e79b90dd75e965b489da866d369ad05da73c7d3b329e6592af9987fd
7
- data.tar.gz: e7161b4d203517679d908d5dbdd9342463eccedb203669cad95331658f8e798293c361e2ce07cd76caed336149aeeb2ab6339869a80c0193d8a7c2453c96b506
6
+ metadata.gz: ca0503e920246e6cc73ba39e801c110aa3dc10c6b8a33c42d965d4988007470fb81212524f56e91bbe2306cfc4c120afa2baa8645613710a169108a905822fa1
7
+ data.tar.gz: 513ec0cdd6f96859030d77cf1f5348e89d95cdb86a64f584136b9cd2dc7bec9dbe6444c3847b214c1781421d6779342c3f77f81df1fdedf39d30443b3945f132
data/bin/rget CHANGED
@@ -34,10 +34,14 @@ class GetWebRadio < Thor
34
34
  define_method(command) do
35
35
  url = params['url']
36
36
  opts = OpenStruct.new(config['options'].merge(options))
37
- if params['podcast']
38
- Podcast.new(url, opts){|media|media.download(params['label'])}
39
- else
40
- WebRadio(url, opts){|media|media.download(params['label'])}
37
+ begin
38
+ if params['podcast']
39
+ Podcast.new(url, opts){|media|media.download(params['label'])}
40
+ else
41
+ WebRadio(url, opts){|media|media.download(params['label'])}
42
+ end
43
+ rescue WebRadio::NotFoundError => e
44
+ $stderr.puts e.message
41
45
  end
42
46
  end
43
47
  end
@@ -11,10 +11,14 @@ class Onsen < WebRadio
11
11
  private
12
12
  def onsen_download(name, program_id)
13
13
  html = Nokogiri(open('http://onsen.ag/', 'User-Agent' => 'iPhone', &:read))
14
- serial = html.css("##{program_id}").text.scan(/#(\d+)/).flatten.first
15
- mp3_url = html.css('form[target=_self]').select {|form|
16
- form.attr('action') =~ %r[/#{program_id}\w+\.mp3]
17
- }.first.attr('action')
14
+ begin
15
+ serial = html.css("##{program_id}").text.scan(/#(\d+)/).flatten.first
16
+ mp3_url = html.css('form[target=_self]').select {|form|
17
+ form.attr('action') =~ %r[/#{program_id}\w+\.mp3]
18
+ }.first.attr('action')
19
+ rescue NoMethodError
20
+ raise NotFoundError.new("no radio program in #{program_id}.")
21
+ end
18
22
  mp3_file = "#{name}##{serial}.mp3"
19
23
  mp3ize(mp3_file, mp3_file, false) do
20
24
  open(mp3_file, 'wb:ASCII-8BIT') do |mp3|
@@ -4,6 +4,7 @@ require 'open-uri'
4
4
  require 'open3'
5
5
 
6
6
  class WebRadio
7
+ class NotFoundError < StandardError; end
7
8
  class DownloadError < StandardError; end
8
9
 
9
10
  def self.instance(url, options)
@@ -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.3.2"
7
+ spec.version = "2.3.3"
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.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rget
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi