rget 2.5.4 → 2.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 858d994084e4cf000d71746ebd0f91858b3765d9
4
- data.tar.gz: ff422c2351a9bc66a222d93dfa36e5cf4ccd7231
3
+ metadata.gz: 430ab60d77c7ae45f44ea928335585d08dab612c
4
+ data.tar.gz: 9a1c2aa1cc84bda8020cb741aab878d0e1209908
5
5
  SHA512:
6
- metadata.gz: 5d8a0e56c23b1f1bd720a4d80701c39aee3e4dd7a51c9071c41a246351f9dd27df5878d1cd34a19476361ed4b0c616982f44776fb765134a6f57e27747524b23
7
- data.tar.gz: ef19273117c868dec6f5ef4034354f10159f6c5d4fda2fa15ed57ade1de6d232646516d8f7c5d828bbbe78a49c4b94bd4484fb793adb92763b65889083cb1d7f
6
+ metadata.gz: fcbdfab23f88567de63d43265057479b0d67490cf3d7de7bb08855efbb54c6410cbb55c130fe9010284924dcfc786844b88f383109da1e8f66e3ea9b5a1b3e73
7
+ data.tar.gz: 295a9df1458733a29c528285000c5833b0a3260c22cb7c147ea39a6c10be6e1bcac2afdd8d5e784c6ce3a89369a04760acc2d1ac9722be8e867110e5edb7d881
data/bin/rget CHANGED
@@ -47,6 +47,12 @@ class GetWebRadio < Thor
47
47
  end
48
48
  end
49
49
  end
50
+
51
+ desc 'yaml', 'dump YAML of specified URL'
52
+ def yaml(url)
53
+ dump = WebRadio(url, OpenStruct.new({dump: true})).dump
54
+ puts YAML.dump(dump).lines.drop(1).map{|l| " #{l}"}
55
+ end
50
56
  end
51
57
 
52
58
  GetWebRadio.start(ARGV)
data/lib/hibiki.rb CHANGED
@@ -7,23 +7,43 @@ require 'uri'
7
7
  require 'openssl'
8
8
 
9
9
  class Hibiki < WebRadio
10
+ def initialize(url, options)
11
+ super
12
+ @url = @url.sub(%r|/detail\Z|, '')
13
+ end
14
+
10
15
  def download(name)
11
- hibiki_download(name, @url.scan(%r|/([^/]*)$|).flatten.first)
16
+ hibiki_download(name, Pathname(@url).basename.to_s)
17
+ end
18
+
19
+ def dump
20
+ tag = Pathname(@url).basename.to_s.gsub(%r|[-/]|, '_')
21
+ agent = Mechanize.new
22
+ media_info = hibiki_media_info(agent, tag)
23
+
24
+ return {
25
+ tag => {
26
+ 'desc' => media_info[:name],
27
+ 'url' => @url,
28
+ 'label' => tag
29
+ }
30
+ }
12
31
  end
13
32
 
14
33
  private
15
34
  def header
16
- {
17
- 'X-Requested-With' => 'XMLHttpRequest',
18
- }
35
+ {'X-Requested-With' => 'XMLHttpRequest'}
19
36
  end
20
37
 
21
- def hibiki_download(name, program_id)
22
- agent = Mechanize.new
38
+ def hibiki_media_info(agent, program_id)
23
39
  agent.request_headers = header
40
+ JSON.parse(agent.get("https://vcms-api.hibiki-radio.jp/api/v1/programs/#{program_id}").body,{:symbolize_names => true})
41
+ end
24
42
 
43
+ def hibiki_download(name, program_id)
25
44
  begin
26
- media_info = JSON.parse(agent.get("https://vcms-api.hibiki-radio.jp/api/v1/programs/#{program_id}").body,{:symbolize_names => true})
45
+ agent = Mechanize.new
46
+ media_info = hibiki_media_info(agent, program_id)
27
47
  serial = media_info[:episode][:name].scan(/([\d\.]+)/).flatten.first
28
48
  video_id = media_info[:episode][:video][:id]
29
49
 
@@ -41,6 +61,7 @@ private
41
61
  key = agent.get_file(key_url)
42
62
  iv = m3u8.scan(/IV=0x(.*)$/).flatten.pack("H*")
43
63
  rescue NoMethodError
64
+ $stderr.puts $!
44
65
  raise NotFoundError.new("no radio program in #{program_id}.")
45
66
  end
46
67
 
data/lib/nicovideo.rb CHANGED
@@ -43,6 +43,23 @@ class Nicovideo < WebRadio
43
43
  end
44
44
  end
45
45
 
46
+ def dump
47
+ begin
48
+ tag = Pathname(@url).basename.to_s.gsub(%r|[-/]|, '_')
49
+ rss_url = "#{@url}/video?rss=2.0"
50
+ desc = RSS::Parser.parse(rss_url).channel.dc_creator
51
+ return {
52
+ tag => {
53
+ 'desc' => desc,
54
+ 'url' => rss_url,
55
+ 'label' => tag
56
+ }
57
+ }
58
+ rescue RSS::NotWellFormedError
59
+ raise
60
+ end
61
+ end
62
+
46
63
  private
47
64
  def get_player_url(list_url)
48
65
  begin
data/lib/onsen.rb CHANGED
@@ -8,6 +8,19 @@ class Onsen < WebRadio
8
8
  onsen_download(name, @url.scan(%r|/([^/]*)/$|).flatten.first)
9
9
  end
10
10
 
11
+ def dump
12
+ tag = Pathname(@url).basename.to_s.gsub(%r|[-/]|, '_')
13
+ html = Nokogiri(open(@url, &:read))
14
+ title = html.css('#outLineWrap h1').text
15
+ return {
16
+ tag => {
17
+ 'desc' => title,
18
+ 'url' => @url,
19
+ 'label' => tag
20
+ }
21
+ }
22
+ end
23
+
11
24
  private
12
25
  def onsen_download(name, program_id)
13
26
  html = Nokogiri(open('http://onsen.ag/', 'User-Agent' => 'iPhone', &:read))
data/lib/webradio.rb CHANGED
@@ -36,7 +36,7 @@ class WebRadio
36
36
  raise 'do not instanciate directly, use WebRadio method.' if self.class == WebRadio
37
37
  @url = url
38
38
  @options = options
39
- if @options.path =~ %r|^dropbox://|
39
+ if !@options.dump && @options.path =~ %r|^dropbox://|
40
40
  require 'dropbox'
41
41
  @dropbox = DropboxAuth.client
42
42
  end
@@ -46,6 +46,10 @@ class WebRadio
46
46
  raise 'not implemented.'
47
47
  end
48
48
 
49
+ def dump
50
+ raise 'not implemented.'
51
+ end
52
+
49
53
  private
50
54
  def mp3nize(src, dst, delete_src = true)
51
55
  if @options.mp3
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.5.4"
7
+ spec.version = "2.6.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.}
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.5.4
4
+ version: 2.6.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: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor