openload 0.0.1
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 +7 -0
- data/lib/openload.rb +106 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3efd80c504edc79968f90dc41ad254ed5a57111f
|
4
|
+
data.tar.gz: d39da21bef9870ac22f4442d543d0377fac9e0ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c1e67376ab22938972194704f45f552e7f6bb590484a1681560eaa35f7088cc361cf047086654cdfc24b8131a511ea57981570872811359d6011d635af06a665
|
7
|
+
data.tar.gz: 034f926eabfb598db0b008038f15701935130ec1b3cb61db464cb2f5b07af0744626377c6f6570e882abf62280b4b7ab56311bce475446898e588194927dda99
|
data/lib/openload.rb
ADDED
@@ -0,0 +1,106 @@
|
|
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 acount_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
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openload
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruno Tripoloni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Gem to use openload.io with ruby
|
14
|
+
email: bruno.tripoloni@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/openload.rb
|
20
|
+
homepage: http://github.com/btripoloni/openload
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.5
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Openload
|
44
|
+
test_files: []
|