openload 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openload.rb +106 -106
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b6b6d614f923542e76a4d1a72dcca9fe78c9bed
|
4
|
+
data.tar.gz: 16975b8f1410ab11795e166baf6f1b9e57694613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bf257322d1f297f59b3d2129cfd3bf1c34fa01bda707b7bec73fd75c1a843bc82d091bb47e48eb843b2146ef6baec4a3bf66b2d1c2f9927d702ad2ec2dc5541
|
7
|
+
data.tar.gz: d71d6c220921e6f729741696f5d6e511bc38eecee55be00ed53540b9f3216d1bb2853e1a71944418ed649b046325410dd9560f3ef07312da5fd750c710ca060f
|
data/lib/openload.rb
CHANGED
@@ -1,106 +1,106 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
class OpenLoad
|
5
|
-
|
6
|
-
|
7
|
-
# Create a new instace using the api-login and the api-key (both are optional)
|
8
|
-
def initialize(login = nil, key = nil)
|
9
|
-
@api_login = login
|
10
|
-
@api_key = key
|
11
|
-
end
|
12
|
-
|
13
|
-
def account_info
|
14
|
-
if is_logged?
|
15
|
-
get_a_request_and_return_in_a_struct("/account/info?login=#{@api_login}&key=#{@api_key}")
|
16
|
-
else
|
17
|
-
raise "You need to insert a login and a key to use this method!"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
#Get the ticket to download a file
|
22
|
-
def download_ticket(file)
|
23
|
-
get_a_request_and_return_in_a_struct("/file/dlticket?file=#{file}#{login_parameter}#{key_parameter}")
|
24
|
-
end
|
25
|
-
|
26
|
-
# Get the download link from a ticket
|
27
|
-
def download_link(file, ticket, captcha_response = nil)
|
28
|
-
get_a_request_and_return_in_a_struct("/file/dl?file=#{file}&ticket=#{ticket}#{http_parameter('captcha_response', captcha_response)}")
|
29
|
-
end
|
30
|
-
|
31
|
-
# This method return the info of a file
|
32
|
-
# Warning: this method rertuns a hash
|
33
|
-
def file_info(file)
|
34
|
-
response = get_a_request("/file/info?file=#{file}#{login_parameter}#{key_parameter}")
|
35
|
-
JSON.parse(response)
|
36
|
-
end
|
37
|
-
|
38
|
-
# This method return a link that you can make uploads.
|
39
|
-
# Warning: this links expire in a few hours, always check the .
|
40
|
-
def upload_link(folder = nil, sha1 = nil, httponly = nil)
|
41
|
-
get_a_request_and_return_in_a_struct("/file/ul#{login_parameter(true)}#{key_parameter}#{http_parameter('folder', folder)}#{http_parameter('sha1', sha1)}#{http_parameter('httponly', httponly)}")
|
42
|
-
end
|
43
|
-
|
44
|
-
# This method make a upload of a link from the web
|
45
|
-
# Remember: You need a login and key api to use this method.
|
46
|
-
def remote_upload(url, folder = nil , headers = nil)
|
47
|
-
if is_logged?
|
48
|
-
get_a_request_and_return_in_a_struct("/remotedl/add#{login_parameter(true)}#{key_parameter}#{http_parameter('url', url)}#{http_parameter('folder',folder)}#{http_parameter('headers', headers)}")
|
49
|
-
else
|
50
|
-
raise "You need a login and a api key to make remote uploads!"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# This method cheks the status of the remote uploads.
|
55
|
-
def check_remote_upload_status(id = nil, limit = nil)
|
56
|
-
get_a_request_and_return_in_a_struct("/remotedl/status#{login_parameter(true)}#{key_parameter}#{http_parameter('limit', limit)}#{http_parameter('id', id)}")
|
57
|
-
end
|
58
|
-
|
59
|
-
# This method return a list of all folders.
|
60
|
-
# You need a login and api kei
|
61
|
-
# This method return returns a hash
|
62
|
-
def folder_list(folder = nil)
|
63
|
-
response = get_a_request("/file/listfolder?login=#{@api_login}&key=#{@api_key}#{http_parameter('folder', folder)}")
|
64
|
-
JSON.parse(response)
|
65
|
-
end
|
66
|
-
|
67
|
-
# This method convert files to stream format (mp4/h.264)
|
68
|
-
def convert_to_stream(file)
|
69
|
-
get_a_request_and_return_in_a_struct("/file/convert?login=#{@api_login}&key=#{@api_key}&file=#{file}")
|
70
|
-
end
|
71
|
-
|
72
|
-
def show_converted_files(folder = nil)
|
73
|
-
get_a_request_and_return_in_a_struct("/file/runningconverts?login=#{@api_login}&key=#{@api_key}}#{http_parameter('folder',folder)}")
|
74
|
-
end
|
75
|
-
|
76
|
-
def get_splash_image(file)
|
77
|
-
get_a_request_and_return_in_a_struct("/file/getsplash?login=#{@api_login}&key=#{@api_key}&file=#{file}")
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
def get_a_request(path)
|
82
|
-
HTTParty.get("#{api_url}#{path}").body
|
83
|
-
end
|
84
|
-
|
85
|
-
def http_parameter(name, value, first_parameter = false)
|
86
|
-
"#{'?' if first_parameter}#{'&' unless first_parameter}#{name}=#{value}" if value
|
87
|
-
end
|
88
|
-
|
89
|
-
def login_parameter(first_parameter = false)
|
90
|
-
http_parameter('login', @api_login, first_parameter)
|
91
|
-
end
|
92
|
-
|
93
|
-
def key_parameter()
|
94
|
-
http_parameter('key', @api_key)
|
95
|
-
end
|
96
|
-
|
97
|
-
def is_logged?
|
98
|
-
@api_key && @api_login
|
99
|
-
end
|
100
|
-
|
101
|
-
def get_a_request_and_return_in_a_struct(req)
|
102
|
-
response = get_a_request(req)
|
103
|
-
data_hash = JSON.parse(response)
|
104
|
-
OpenStruct.new(data_hash)
|
105
|
-
end
|
106
|
-
end
|
1
|
+
require 'httparty'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
class OpenLoad
|
5
|
+
@@api_url = "https://api.openload.co/1"
|
6
|
+
|
7
|
+
# Create a new instace using the api-login and the api-key (both are optional)
|
8
|
+
def initialize(login = nil, key = nil)
|
9
|
+
@api_login = login
|
10
|
+
@api_key = key
|
11
|
+
end
|
12
|
+
|
13
|
+
def account_info
|
14
|
+
if is_logged?
|
15
|
+
get_a_request_and_return_in_a_struct("/account/info?login=#{@api_login}&key=#{@api_key}")
|
16
|
+
else
|
17
|
+
raise "You need to insert a login and a key to use this method!"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#Get the ticket to download a file
|
22
|
+
def download_ticket(file)
|
23
|
+
get_a_request_and_return_in_a_struct("/file/dlticket?file=#{file}#{login_parameter}#{key_parameter}")
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get the download link from a ticket
|
27
|
+
def download_link(file, ticket, captcha_response = nil)
|
28
|
+
get_a_request_and_return_in_a_struct("/file/dl?file=#{file}&ticket=#{ticket}#{http_parameter('captcha_response', captcha_response)}")
|
29
|
+
end
|
30
|
+
|
31
|
+
# This method return the info of a file
|
32
|
+
# Warning: this method rertuns a hash
|
33
|
+
def file_info(file)
|
34
|
+
response = get_a_request("/file/info?file=#{file}#{login_parameter}#{key_parameter}")
|
35
|
+
JSON.parse(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
# This method return a link that you can make uploads.
|
39
|
+
# Warning: this links expire in a few hours, always check the .
|
40
|
+
def upload_link(folder = nil, sha1 = nil, httponly = nil)
|
41
|
+
get_a_request_and_return_in_a_struct("/file/ul#{login_parameter(true)}#{key_parameter}#{http_parameter('folder', folder)}#{http_parameter('sha1', sha1)}#{http_parameter('httponly', httponly)}")
|
42
|
+
end
|
43
|
+
|
44
|
+
# This method make a upload of a link from the web
|
45
|
+
# Remember: You need a login and key api to use this method.
|
46
|
+
def remote_upload(url, folder = nil , headers = nil)
|
47
|
+
if is_logged?
|
48
|
+
get_a_request_and_return_in_a_struct("/remotedl/add#{login_parameter(true)}#{key_parameter}#{http_parameter('url', url)}#{http_parameter('folder',folder)}#{http_parameter('headers', headers)}")
|
49
|
+
else
|
50
|
+
raise "You need a login and a api key to make remote uploads!"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# This method cheks the status of the remote uploads.
|
55
|
+
def check_remote_upload_status(id = nil, limit = nil)
|
56
|
+
get_a_request_and_return_in_a_struct("/remotedl/status#{login_parameter(true)}#{key_parameter}#{http_parameter('limit', limit)}#{http_parameter('id', id)}")
|
57
|
+
end
|
58
|
+
|
59
|
+
# This method return a list of all folders.
|
60
|
+
# You need a login and api kei
|
61
|
+
# This method return returns a hash
|
62
|
+
def folder_list(folder = nil)
|
63
|
+
response = get_a_request("/file/listfolder?login=#{@api_login}&key=#{@api_key}#{http_parameter('folder', folder)}")
|
64
|
+
JSON.parse(response)
|
65
|
+
end
|
66
|
+
|
67
|
+
# This method convert files to stream format (mp4/h.264)
|
68
|
+
def convert_to_stream(file)
|
69
|
+
get_a_request_and_return_in_a_struct("/file/convert?login=#{@api_login}&key=#{@api_key}&file=#{file}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def show_converted_files(folder = nil)
|
73
|
+
get_a_request_and_return_in_a_struct("/file/runningconverts?login=#{@api_login}&key=#{@api_key}}#{http_parameter('folder',folder)}")
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_splash_image(file)
|
77
|
+
get_a_request_and_return_in_a_struct("/file/getsplash?login=#{@api_login}&key=#{@api_key}&file=#{file}")
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
def get_a_request(path)
|
82
|
+
HTTParty.get("#{@@api_url}#{path}").body
|
83
|
+
end
|
84
|
+
|
85
|
+
def http_parameter(name, value, first_parameter = false)
|
86
|
+
"#{'?' if first_parameter}#{'&' unless first_parameter}#{name}=#{value}" if value
|
87
|
+
end
|
88
|
+
|
89
|
+
def login_parameter(first_parameter = false)
|
90
|
+
http_parameter('login', @api_login, first_parameter)
|
91
|
+
end
|
92
|
+
|
93
|
+
def key_parameter()
|
94
|
+
http_parameter('key', @api_key)
|
95
|
+
end
|
96
|
+
|
97
|
+
def is_logged?
|
98
|
+
@api_key && @api_login
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_a_request_and_return_in_a_struct(req)
|
102
|
+
response = get_a_request(req)
|
103
|
+
data_hash = JSON.parse(response)
|
104
|
+
OpenStruct.new(data_hash)
|
105
|
+
end
|
106
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Tripoloni
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
53
|
rubyforge_project:
|
54
|
-
rubygems_version: 2.
|
54
|
+
rubygems_version: 2.5.1
|
55
55
|
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: Openload
|