rget 4.8.2 → 4.8.3
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 +4 -4
- data/lib/nicovideo.rb +33 -23
- data/rget.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef68f95f3fbafd9b06628962504a762ea8fa4782d98e87a006a0778f19d92e3
|
4
|
+
data.tar.gz: 698f889ccbf793023b8ee5409aee34039f759cb1d650c453fd6a38524a456fa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55a57b0f4190c235469156e8a9af6b87d0be727e2988d5d6ebe32110d89d1bfb4f269e79712dc7ed0170f3d05704aa9d870a2c2b8546a3619bea8d73dd89ff20
|
7
|
+
data.tar.gz: 16af48cd344bb6ff1e6638b4b5838605d8daae2d7bfd6ba4e5ba880ccc3451ee97aeda07026dea1c56939693db8878868e61f68742f9fe26c5e0a24a02ac6ee5
|
data/lib/nicovideo.rb
CHANGED
@@ -6,6 +6,8 @@ require 'open-uri'
|
|
6
6
|
require 'rss'
|
7
7
|
|
8
8
|
class Nicovideo < WebRadio
|
9
|
+
class ForbiddenError < StandardError; end
|
10
|
+
|
9
11
|
def initialize(params, options)
|
10
12
|
account = Pit::get('nicovideo', :require => {
|
11
13
|
:id => 'your nicovideo id',
|
@@ -17,29 +19,36 @@ class Nicovideo < WebRadio
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def download
|
22
|
+
offset = 0
|
20
23
|
begin
|
21
|
-
video = get_video(@url)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
if serial == 0
|
30
|
-
tmp = title.scan(/\d+/).last.to_i
|
31
|
-
serial = tmp if tmp > 0
|
32
|
-
end
|
33
|
-
appendix = title =~ /おまけ|アフタートーク/ ? 'a' : ''
|
34
|
-
@file = "#{@label}##{'%02d' % serial}#{appendix}.#{video.type}"
|
35
|
-
@mp3_file = @file.sub(/\....$/, '.mp3')
|
36
|
-
mp3nize(@file, @mp3_file) do
|
37
|
-
loop do
|
38
|
-
print '.'
|
39
|
-
_, err, status = Open3.capture3("youtube-dl -f mp4 -o #{@file} --netrc #{video.url}")
|
40
|
-
break if status == 0
|
41
|
-
raise DownloadError.new(err) unless err =~ /403: Forbidden/
|
24
|
+
video = get_video(@url, offset)
|
25
|
+
@cover = thumbinfo(video, 'thumbnail_url') unless @cover
|
26
|
+
title = video.title || thumbinfo(video, 'title') || video.id
|
27
|
+
title.tr!('0-9', '0-9')
|
28
|
+
serial = title.scan(/(?:[#第]|[ ]EP|track-)(\d+)|/).flatten.compact[0].to_i
|
29
|
+
if serial == 0
|
30
|
+
tmp = title.scan(/\d+/).last.to_i
|
31
|
+
serial = tmp if tmp > 0
|
42
32
|
end
|
33
|
+
appendix = title =~ /おまけ|アフタートーク/ ? 'a' : ''
|
34
|
+
@file = "#{@label}##{'%02d' % serial}#{appendix}.#{video.type}"
|
35
|
+
@mp3_file = @file.sub(/\....$/, '.mp3')
|
36
|
+
mp3nize(@file, @mp3_file) do
|
37
|
+
loop do
|
38
|
+
print '.'
|
39
|
+
_, err, status = Open3.capture3("youtube-dl -f mp4 -o #{@file} --netrc #{video.url}")
|
40
|
+
break if status == 0
|
41
|
+
next if err =~ /403: Forbidden/
|
42
|
+
raise ForbiddenError.new("Could not access to #{video.url}") if err =~ /TypeError/
|
43
|
+
raise DownloadError.new(err)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
rescue ForbiddenError
|
47
|
+
puts "#{$!.message}, try next."
|
48
|
+
offset += 1
|
49
|
+
retry
|
50
|
+
rescue NotFoundError
|
51
|
+
raise DownloadError.new('video not found')
|
43
52
|
end
|
44
53
|
end
|
45
54
|
|
@@ -61,9 +70,8 @@ class Nicovideo < WebRadio
|
|
61
70
|
end
|
62
71
|
|
63
72
|
private
|
64
|
-
def get_video(list_url)
|
73
|
+
def get_video(list_url, offset = 0)
|
65
74
|
video_url = nil
|
66
|
-
offset = 0
|
67
75
|
begin
|
68
76
|
begin
|
69
77
|
rss = RSS::Parser.parse(open(list_url).read)
|
@@ -76,6 +84,8 @@ private
|
|
76
84
|
video_url = "http://www.nicovideo.jp#{url}"
|
77
85
|
end
|
78
86
|
video = @nico.video(Pathname(URI(video_url).path).basename.to_s)
|
87
|
+
rescue NoMethodError
|
88
|
+
raise NotFoundError.new('video not found')
|
79
89
|
rescue Net::HTTPForbidden, Mechanize::ResponseCodeError
|
80
90
|
offset += 1
|
81
91
|
retry
|
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 = "4.8.
|
7
|
+
spec.version = "4.8.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, onsen, niconico, freshlive, himalaya and asobi store.}
|
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: 4.8.
|
4
|
+
version: 4.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|