rget 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nicodl +36 -8
  3. data/rget.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b3976d15a463499402b2030934daa49e54c1427
4
- data.tar.gz: 0031f310197b9f32e2ed7b815fbdd2f1ec73af2e
3
+ metadata.gz: 04ee8f21885d5c538e3a9f94ecc7458420de3f6f
4
+ data.tar.gz: 564e80e9536e2fdffb63b257d8309053b7a2c2bc
5
5
  SHA512:
6
- metadata.gz: 9e09e6a95b1f0deaed88b73d607762c1fc4cf21155a9a690cee29107ce01308ce17c833328ce8af9c9573d44cf196d4d2be2940f9ddfa7fc72dc4e208b3f8ef1
7
- data.tar.gz: 809b25629fb8842839a1b6499b1d6ae97291e4d784572380e4565328e0d76f23289e38e1c131dd5ae50469e6228fef3f58cc470f07973a71a5e120ac3698f5f2
6
+ metadata.gz: 94cca70161ef7d7db7a0fd2e105ab80ed8fc545e6d8bc300c205432484ab2acd663304ed028b83549fcd5f81718bd0653bc9cd170bb899d4b6ac92cc5367f365
7
+ data.tar.gz: a59e95f0a6e5bedc0468e2bf9139e7c5e02edfd9cf70cbd051db48b2997000c26c4c73347515e00fb3d15caa8186fbe468b80e74b84a5937e8c34ba5c11a2d9f
data/bin/nicodl CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'pit'
4
4
  require 'niconico'
5
5
  require 'pathname'
6
+ require 'open3'
6
7
 
7
8
  player_url = ARGV.shift
8
9
  unless player_url
@@ -15,23 +16,50 @@ account = Pit::get('nicovideo', :require => {
15
16
  })
16
17
  nico = Niconico.new(account[:id], account[:pass])
17
18
  nico.login
19
+
18
20
  video_id = Pathname(URI(player_url).path).basename.to_s
19
21
  begin
22
+ # downloading video
20
23
  video = nico.video(video_id)
21
24
  file = "#{video.title}.#{video.type}".gsub(%r([\\/\?:*"><|]), '_')
22
25
  open(file, 'wb:ASCII-8BIT') do |o|
23
26
  video.get_video{|body|o.write(body)}
24
27
  end
25
28
  rescue Mechanize::ResponseCodeError
29
+ # live streaming time-shift
26
30
  live = nico.live(video_id)
27
- cmd = live.rtmpdump_commands(video_id).first
28
- cmd.delete('-V')
29
- cmd[cmd.index('-o') + 1] = "./#{video_id}.flv"
30
- system(*cmd)
31
+ if File.exist?("#{video_id}.flv")
32
+ $stderr.puts "#{video_id}.flv is existent. skipping."
33
+ else
34
+ cmd = live.rtmpdump_commands(video_id).first
35
+ cmd[cmd.index('-o') + 1] = "./#{video_id}.flv"
36
+ begin
37
+ o, e, s = Open3.capture3(cmd.join(' '))
38
+ unless s.exitstatus == 0
39
+ $stderr.puts e
40
+ exit 1
41
+ end
42
+ rescue Errno::ENOENT
43
+ $stderr.puts $!
44
+ exit 1
45
+ end
46
+ end
31
47
 
32
- avconv = ['avconv', '-i', "#{video_id}.flv", '-acodec', 'copy', '-vcodec', 'copy', "#{video_id}.mp4"]
33
- if system(*avconv) == nil
34
- avconv[0] = 'ffmpeg'
35
- system(*avconv)
48
+ avconv = 'avconv'
49
+ args = " -i '#{video_id}.flv' -acodec copy -vcodec copy '#{live.title}.mp4'"
50
+ begin
51
+ o, e, s = Open3.capture3(avconv + args)
52
+ unless s.exitstatus == 0
53
+ $stderr.puts e
54
+ exit 1
55
+ end
56
+ File.delete("#{video_id}.flv")
57
+ rescue Errno::ENOENT
58
+ if avconv == 'ffmpeg'
59
+ $stderr.puts $!
60
+ else
61
+ avconv = 'ffmpeg'
62
+ retry
63
+ end
36
64
  end
37
65
  end
@@ -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.0"
7
+ spec.version = "2.5.1"
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.0
4
+ version: 2.5.1
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-03-21 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor