rget 4.7.6 → 4.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ulizadl +63 -5
- data/rget.gemspec +2 -2
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67ae7e0feff45509f86be682672f93b2bc85458e686cf3f77b188549daf7447f
|
4
|
+
data.tar.gz: 5b63864b67d2c93337f4b48d5a253295b1d72ea3863c03216ee315d9e66916e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e3009d6cbe8c14cc0d6cd42fdfa62077b4be96ee17825df1a8e65f0a4d3cc08610151ec6b37a0b25bbd0c4b88b4fc9c79b7ffdfb70c5da0be7c3861b3d16fd1
|
7
|
+
data.tar.gz: 558ecd9a332a374f03f3092dea3499ef69516da359662b1c1f912af7f3fffd1122772f965000c9af962a1dd244c87d90d2606c8a931935932001c2ff5d4fe72c
|
data/bin/ulizadl
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require "uri"
|
3
3
|
require "mechanize"
|
4
4
|
require 'open-uri'
|
5
|
+
require 'thread'
|
5
6
|
|
6
7
|
if ARGV.size != 2
|
7
8
|
$stderr.puts "download TS file decoded by Uliza style video streaming"
|
@@ -11,6 +12,7 @@ end
|
|
11
12
|
|
12
13
|
m3u8 = ARGV.shift
|
13
14
|
ts_file = "#{ARGV.shift}.ts"
|
15
|
+
ts_file = nil if File.basename(ts_file) == "-.ts"
|
14
16
|
|
15
17
|
begin
|
16
18
|
agent = Mechanize.new
|
@@ -35,11 +37,67 @@ else
|
|
35
37
|
def decoder.final(); return ''; end
|
36
38
|
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
q = Queue.new
|
41
|
+
tses.each_with_index{|ts_url, block_no| q.push([ts_url, block_no])}
|
42
|
+
q.close
|
43
|
+
results = [nil] * q.size
|
44
|
+
|
45
|
+
msgs = Queue.new
|
46
|
+
stats = [0] * 3
|
47
|
+
stats.size.times do |thread_no|
|
48
|
+
Thread.start(thread_no) do |thread_no|
|
49
|
+
while (ts_url, block_no = q.pop)
|
50
|
+
begin
|
51
|
+
sleep(rand(0.1) * 3)
|
52
|
+
results[block_no] = agent.get_file(ts_url)
|
53
|
+
stats[thread_no] = block_no
|
54
|
+
rescue Mechanize::ResponseCodeError => e
|
55
|
+
case e.response_code
|
56
|
+
when "403" # Forbidden
|
57
|
+
msgs.push "T#{thread_no}: 403 Forbidden"
|
58
|
+
retry
|
59
|
+
when "429" # TooManyRequests
|
60
|
+
msgs.push "T#{thread_no}: 429 TooManyRequests"
|
61
|
+
retry
|
62
|
+
else
|
63
|
+
msgs.push "T#{thread_no}: #{e}"
|
64
|
+
retry # TODO: catch other status code
|
65
|
+
end
|
66
|
+
rescue
|
67
|
+
msgs.push "T#{thread_no}: #{e.class} #{e}"
|
68
|
+
break
|
69
|
+
end
|
70
|
+
end
|
42
71
|
end
|
43
|
-
|
72
|
+
end
|
73
|
+
|
74
|
+
def print_status(block, tses, stats, msgs)
|
75
|
+
$stderr.puts msgs.pop while !msgs.empty?
|
76
|
+
$stderr.print "#{block+1}/#{tses.size} saved --"
|
77
|
+
stats.each_with_index{|block_no, thread_no| $stderr.print " T#{thread_no+1}:#{block_no+1}"}
|
78
|
+
$stderr.print "\r"
|
79
|
+
end
|
80
|
+
|
81
|
+
def save(fd, results, tses, stats, msgs, decoder)
|
82
|
+
results.each_with_index do |data, i|
|
83
|
+
print_status(i, tses, stats, msgs)
|
84
|
+
loop do
|
85
|
+
if data
|
86
|
+
fd.write(decoder.update(data))
|
87
|
+
results[i] = nil # be saved data want to GC
|
88
|
+
break
|
89
|
+
else
|
90
|
+
sleep(1.0) # wait for complete of chunk download finished
|
91
|
+
data = results[i]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
fd.write(decoder.final)
|
44
96
|
puts
|
45
97
|
end
|
98
|
+
|
99
|
+
if ts_file
|
100
|
+
open(ts_file, 'wb:ASCII-8BIT'){|f|save(f, results, tses, stats, msgs, decoder)}
|
101
|
+
else
|
102
|
+
save($stdout, results, tses, stats, msgs, decoder)
|
103
|
+
end
|
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.7.
|
7
|
+
spec.version = "4.7.7"
|
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.}
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "dropbox_api"
|
25
25
|
spec.add_runtime_dependency "mp3info"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
28
|
spec.add_development_dependency "rake"
|
29
29
|
spec.add_development_dependency "pry"
|
30
30
|
spec.add_development_dependency "travis"
|
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.7.
|
4
|
+
version: 4.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,8 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
|
207
|
-
rubygems_version: 2.7.8
|
206
|
+
rubygems_version: 3.0.1
|
208
207
|
signing_key:
|
209
208
|
specification_version: 4
|
210
209
|
summary: Downloading newest radio programs on the web.
|