rget 4.1.0 → 4.2.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.
- checksums.yaml +4 -4
- data/lib/dropbox.rb +45 -28
- data/lib/webradio.rb +13 -8
- data/rget.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d5b5444c527c81d9ccf64f5fa5679afec2f29d
|
4
|
+
data.tar.gz: 909b06eb3fce971d60bff406dfec32da68c69b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be8da2f75615ef51c693956f4ab2ece11c6e4cf77ae98cecb3320b5d84222d70261dc26f67fea47dccb6fc16176ab19c1c98cf590262e33f83f494a082e531c6
|
7
|
+
data.tar.gz: 7988434983f08de1c1347ee190386e6c91794d04c047160617ce0a48d43c1ed386560cc8566255ed740768b805e1c6ecc74e3438b14f6628f2926fd9f8767b61
|
data/lib/dropbox.rb
CHANGED
@@ -1,36 +1,53 @@
|
|
1
|
-
require "
|
2
|
-
require "dropbox-api/tasks"
|
1
|
+
require "dropbox_api"
|
3
2
|
require 'pit'
|
4
3
|
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
print "Enter dropbox app key: "
|
10
|
-
token[:api_key] = $stdin.gets.chomp
|
11
|
-
print "Enter dropbox app secret: "
|
12
|
-
token[:api_secret] = $stdin.gets.chomp
|
13
|
-
Pit::set('rget-dropbox', data: token)
|
4
|
+
module RGet
|
5
|
+
class Dropbox
|
6
|
+
def self.client
|
7
|
+
self.new
|
14
8
|
end
|
15
|
-
Dropbox::API::Config.app_key = token[:api_key]
|
16
|
-
Dropbox::API::Config.app_secret = token[:api_secret]
|
17
|
-
Dropbox::API::Config.mode = 'dropbox'
|
18
9
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
10
|
+
def initialize
|
11
|
+
token = Pit::get('rget-dropbox')
|
12
|
+
unless token[:api_token]
|
13
|
+
if token[:api_key]
|
14
|
+
api_key = token[:api_key]
|
15
|
+
else
|
16
|
+
print "Enter dropbox app key: "
|
17
|
+
api_key = $stdin.gets.chomp
|
18
|
+
end
|
19
|
+
|
20
|
+
if token[:api_secret]
|
21
|
+
api_secret = token[:api_secret]
|
22
|
+
else
|
23
|
+
print "Enter dropbox app secret: "
|
24
|
+
api_secret = $stdin.gets.chomp
|
25
|
+
end
|
26
|
+
|
27
|
+
authenticator = DropboxApi::Authenticator.new(api_key, api_secret)
|
28
|
+
puts "\nGo to this url and click 'Authorize' to get the token:"
|
29
|
+
puts authenticator.authorize_url
|
30
|
+
|
31
|
+
token.clear # delete all old settings
|
32
|
+
print "Enter the token: "
|
33
|
+
code = $stdin.gets.chomp
|
34
|
+
token[:api_token] = authenticator.get_token(code).token
|
35
|
+
Pit::set('rget-dropbox', data: token)
|
36
|
+
end
|
37
|
+
@client = DropboxApi::Client.new(token[:api_token])
|
32
38
|
end
|
33
39
|
|
34
|
-
|
40
|
+
def exist?(dst, dropbox_path)
|
41
|
+
!(@client.search(dst, dropbox_path).matches.size == 0)
|
42
|
+
end
|
43
|
+
|
44
|
+
def upload(dropbox_path)
|
45
|
+
info = DropboxApi::Metadata::CommitInfo.new('path'=>dropbox_path, 'mode'=>:add)
|
46
|
+
cursor = @client.upload_session_start('')
|
47
|
+
while data = yield
|
48
|
+
@client.upload_session_append_v2(cursor, data)
|
49
|
+
end
|
50
|
+
@client.upload_session_finish(cursor, info)
|
51
|
+
end
|
35
52
|
end
|
36
53
|
end
|
data/lib/webradio.rb
CHANGED
@@ -35,7 +35,7 @@ class WebRadio
|
|
35
35
|
@options = options
|
36
36
|
if !@options.dump && @options.path =~ %r|^dropbox://|
|
37
37
|
require 'dropbox'
|
38
|
-
@dropbox =
|
38
|
+
@dropbox = RGet::Dropbox.client
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -136,11 +136,7 @@ private
|
|
136
136
|
|
137
137
|
def exist?(dst)
|
138
138
|
if @dropbox
|
139
|
-
|
140
|
-
!@dropbox.ls(dropbox_file(dst))[0]['is_deleted']
|
141
|
-
rescue Dropbox::API::Error::NotFound, NoMethodError
|
142
|
-
false
|
143
|
-
end
|
139
|
+
@dropbox.exist?(dst, dropbox_path)
|
144
140
|
elsif @options.path
|
145
141
|
File.exist?(File.join(@options.path, dst))
|
146
142
|
else
|
@@ -153,7 +149,12 @@ private
|
|
153
149
|
print "move to #{@options.path}..."
|
154
150
|
begin
|
155
151
|
if @dropbox
|
156
|
-
|
152
|
+
open(dst) do |r|
|
153
|
+
@dropbox.upload(dropbox_file(dst)) do
|
154
|
+
print '.'
|
155
|
+
r.read(10_000_000)
|
156
|
+
end
|
157
|
+
end
|
157
158
|
File.delete(dst)
|
158
159
|
elsif @options.path
|
159
160
|
FileUtils.mv(dst, @options.path)
|
@@ -166,8 +167,12 @@ private
|
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
170
|
+
def dropbox_path
|
171
|
+
@options.path.sub(%r|^dropbox://|, '/')
|
172
|
+
end
|
173
|
+
|
169
174
|
def dropbox_file(file)
|
170
|
-
path = @options.path.sub(%r|^dropbox://|, '')
|
175
|
+
path = @options.path.sub(%r|^dropbox://|, '/')
|
171
176
|
File.join(path, file)
|
172
177
|
end
|
173
178
|
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
|
+
spec.version = "4.2.0"
|
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 and freshlive.}
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency "nokogiri", ">= 1.7.0"
|
22
22
|
spec.add_runtime_dependency "niconico", ">= 1.8.0"
|
23
23
|
spec.add_runtime_dependency "pit"
|
24
|
-
spec.add_runtime_dependency "
|
24
|
+
spec.add_runtime_dependency "dropbox_api"
|
25
25
|
spec.add_runtime_dependency "mp3info"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
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.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: dropbox_api
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mp3info
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.5.1
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Downloading newest radio programs on the web.
|