ripdiru 0.0.3 → 0.1.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 (3) hide show
  1. data/lib/ripdiru.rb +11 -14
  2. data/lib/ripdiru/version.rb +1 -1
  3. metadata +2 -2
data/lib/ripdiru.rb CHANGED
@@ -13,7 +13,6 @@ require 'fileutils'
13
13
  module Ripdiru
14
14
  class DownloadTask
15
15
 
16
- PLAYER_URL = "http://www3.nhk.or.jp/netradio/files/swf/rtmpe.swf"
17
16
  TMPDIR = ENV['TMPDIR'] || '/tmp'
18
17
 
19
18
  attr_accessor :station, :cache, :buffer, :outdir, :bitrate
@@ -34,17 +33,14 @@ module Ripdiru
34
33
  def channel
35
34
  case station
36
35
  when "NHK1"
37
- @rtmp="rtmpe://netradio-r1-flash.nhk.jp"
38
- @playpath="NetRadio_R1_flash@63346"
39
36
  @xmlpath="http://cgi4.nhk.or.jp/hensei/api/sche-nr.cgi?tz=all&ch=netr1"
37
+ @aspx="http://mfile.akamai.com/129931/live/reflector:46032.asx"
40
38
  when "NHK2"
41
- @rtmp="rtmpe://netradio-r2-flash.nhk.jp"
42
- @playpath="NetRadio_R2_flash@63342"
43
39
  @xmlpath="http://cgi4.nhk.or.jp/hensei/api/sche-nr.cgi?tz=all&ch=netr2"
40
+ @aspx="http://mfile.akamai.com/129932/live/reflector:46056.asx"
44
41
  when "FM"
45
- @rtmp="rtmpe://netradio-fm-flash.nhk.jp"
46
- @playpath="NetRadio_FM_flash@63343"
47
42
  @xmlpath="http://cgi4.nhk.or.jp/hensei/api/sche-nr.cgi?tz=all&ch=netfm"
43
+ @aspx="http://mfile.akamai.com/129933/live/reflector:46051.asx"
48
44
  else
49
45
  puts "invalid channel"
50
46
  end
@@ -81,6 +77,12 @@ module Ripdiru
81
77
  end
82
78
  end
83
79
 
80
+ def mms_url
81
+ doc = Nokogiri::HTML(open(@aspx))
82
+ mms_url = doc.xpath(".//ref").attribute("href").text
83
+ mms_url.sub!("mms://", "mmsh://")
84
+ end
85
+
84
86
  def run
85
87
  program = now_playing(station)
86
88
 
@@ -91,13 +93,8 @@ module Ripdiru
91
93
  puts "Ripping audio file to #{tempfile}"
92
94
 
93
95
  command = %W(
94
- rtmpdump --live --quiet
95
- -r #{@rtmp}
96
- --playpath #{@playpath}
97
- --app "live"
98
- -W #{PLAYER_URL}
99
- --live --stop #{duration} -o - |
100
- ffmpeg -y -i - -vn
96
+ timeout --foreground -s 2 #{duration}
97
+ ffmpeg -y -i #{mms_url} -vn
101
98
  -loglevel error
102
99
  -metadata author="NHK"
103
100
  -metadata artist="#{program.station}"
@@ -1,3 +1,3 @@
1
1
  module Ripdiru
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripdiru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-21 00:00:00.000000000 Z
12
+ date: 2013-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri