ripdiru 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,12 +35,11 @@ Recommended to install the following:
35
35
 
36
36
  - Ruby 1.9
37
37
  - Nokogiri
38
- - rtmpdump
39
38
  - ffmpeg
40
39
 
41
40
  ## Special thanks to
42
41
 
43
- - [matchy2 (MACHIDA Hideki)](https://github.com/matchy2), for the shell script to rip Radiru\*Radiru https://gist.github.com/5310409.git
42
+ - [matchy2 (MACHIDA Hideki)](https://github.com/matchy2), for the shell script to rip Radiru\*Radiru https://gist.github.com/matchy2/5310409
44
43
 
45
44
  - [miyagawa (Tatsuhiko Miyagawa)](https://github.com/miyagawa/), for [ripdiko](https://github.com/miyagawa/ripdiko), from which I shamelessly copy-pasted most of the code.
46
45
 
@@ -1,3 +1,3 @@
1
1
  module Ripdiru
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/ripdiru.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "ripdiru/version"
4
4
  require 'net/https'
5
- require 'nokogiri'
5
+ require 'rexml/document'
6
6
  require 'uri'
7
7
  require 'pathname'
8
8
  require 'base64'
@@ -14,6 +14,7 @@ module Ripdiru
14
14
  class DownloadTask
15
15
 
16
16
  TMPDIR = ENV['TMPDIR'] || '/tmp'
17
+ SCHEDULE_URL = "http://www2.nhk.or.jp/hensei/api/noa.cgi?c=3&wide=1&mode=json"
17
18
 
18
19
  attr_accessor :station, :cache, :buffer, :outdir, :bitrate
19
20
 
@@ -33,21 +34,21 @@ module Ripdiru
33
34
  def channel
34
35
  case station
35
36
  when "NHK1"
36
- @xmlpath="http://cgi4.nhk.or.jp/hensei/api/sche-nr.cgi?tz=all&ch=netr1"
37
37
  @aspx="http://mfile.akamai.com/129931/live/reflector:46032.asx"
38
+ @mms_ch="netr1"
38
39
  when "NHK2"
39
- @xmlpath="http://cgi4.nhk.or.jp/hensei/api/sche-nr.cgi?tz=all&ch=netr2"
40
40
  @aspx="http://mfile.akamai.com/129932/live/reflector:46056.asx"
41
+ @mms_ch="netr2"
41
42
  when "FM"
42
- @xmlpath="http://cgi4.nhk.or.jp/hensei/api/sche-nr.cgi?tz=all&ch=netfm"
43
43
  @aspx="http://mfile.akamai.com/129933/live/reflector:46051.asx"
44
+ @mms_ch="netfm"
44
45
  else
45
46
  puts "invalid channel"
46
47
  end
47
48
  end
48
49
 
49
- def val(node, xpath)
50
- node.xpath(".//#{xpath}").text
50
+ def val(element, path)
51
+ element.get_text(path)
51
52
  end
52
53
 
53
54
  def parse_time(str)
@@ -57,13 +58,14 @@ module Ripdiru
57
58
  def now_playing(station)
58
59
  today = Date.today
59
60
  now = Time.now
60
- doc = Nokogiri::XML(open(@xmlpath))
61
+
62
+ f = open(SCHEDULE_URL)
63
+ xml = REXML::Document.new(f)
61
64
 
62
- node = doc.xpath("//program").first
63
- node.xpath(".//item").each do |item|
64
- from, to = parse_time(val(item, "starttime")), parse_time(val(item, "endtime"))
65
- start_time = now.to_i + buffer
66
- if from.to_i <= start_time && start_time < to.to_i
65
+ REXML::XPath.each(xml, "//item") do |item|
66
+ if val(item, "ch") == @mms_ch && val(item, "index") == '0'
67
+ from, to = parse_time(val(item, "starttime")), parse_time(val(item, "endtime"))
68
+ start_time = now.to_i + buffer
67
69
  return Program.new(
68
70
  id: now.strftime("%Y%m%d%H%M%S") + "-#{station}",
69
71
  station: station,
@@ -76,10 +78,12 @@ module Ripdiru
76
78
  end
77
79
  end
78
80
  end
79
-
81
+
80
82
  def mms_url
81
- doc = Nokogiri::HTML(open(@aspx))
82
- mms_url = doc.xpath(".//ref").attribute("href").text
83
+ f = open(@aspx)
84
+ doc = REXML::Document.new(f)
85
+
86
+ mms_url = REXML::XPath.first(doc, "//ENTRY/REF").attribute("HREF").to_s
83
87
  mms_url.sub!("mms://", "mmsh://")
84
88
  end
85
89
 
data/ripdiru.gemspec CHANGED
@@ -18,8 +18,4 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'nokogiri'
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
21
  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.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,56 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-22 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: nokogiri
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: bundler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.3'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.3'
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
12
+ date: 2013-10-25 00:00:00.000000000 Z
13
+ dependencies: []
62
14
  description: Radiru*Radiru ripper
63
15
  email:
64
16
  - harupong@gmail.com