Class: OpenLoad

Inherits:
Object
  • Object
show all
Defined in:
lib/openload.rb

Constant Summary collapse

@@api_url =
"https://api.openload.co/1"

Instance Method Summary collapse

Constructor Details

#initialize(login = nil, key = nil) ⇒ OpenLoad

Create a new instace using the api-login and the api-key (both are optional)



8
9
10
11
# File 'lib/openload.rb', line 8

def initialize( = nil, key = nil)
  @api_login = 
  @api_key   = key
end

Instance Method Details

#account_infoObject



13
14
15
16
17
18
19
# File 'lib/openload.rb', line 13

def 
  if is_logged?
    get_a_request_and_return_in_a_struct("/account/info?login=#{@api_login}&key=#{@api_key}")
  else
    raise "You need to insert a login and a key to use this method!"
  end
end

#check_remote_upload_status(id = nil, limit = nil) ⇒ Object

This method cheks the status of the remote uploads.



55
56
57
# File 'lib/openload.rb', line 55

def check_remote_upload_status(id = nil, limit = nil)
  get_a_request_and_return_in_a_struct("/remotedl/status#{(true)}#{key_parameter}#{http_parameter('limit', limit)}#{http_parameter('id', id)}")
end

#convert_to_stream(file) ⇒ Object

This method convert files to stream format (mp4/h.264)



68
69
70
# File 'lib/openload.rb', line 68

def convert_to_stream(file)
  get_a_request_and_return_in_a_struct("/file/convert?login=#{@api_login}&key=#{@api_key}&file=#{file}")
end

Get the download link from a ticket



27
28
29
# File 'lib/openload.rb', line 27

def download_link(file, ticket, captcha_response = nil)
  get_a_request_and_return_in_a_struct("/file/dl?file=#{file}&ticket=#{ticket}#{http_parameter('captcha_response', captcha_response)}")
end

#download_ticket(file) ⇒ Object

Get the ticket to download a file



22
23
24
# File 'lib/openload.rb', line 22

def download_ticket(file)
  get_a_request_and_return_in_a_struct("/file/dlticket?file=#{file}#{}#{key_parameter}")
end

#file_info(file) ⇒ Object

This method return the info of a file Warning: this method rertuns a hash



33
34
35
36
# File 'lib/openload.rb', line 33

def file_info(file)
  response = get_a_request("/file/info?file=#{file}#{}#{key_parameter}")
  JSON.parse(response)
end

#folder_list(folder = nil) ⇒ Object

This method return a list of all folders. You need a login and api kei This method return returns a hash



62
63
64
65
# File 'lib/openload.rb', line 62

def folder_list(folder = nil)
  response = get_a_request("/file/listfolder?login=#{@api_login}&key=#{@api_key}#{http_parameter('folder', folder)}")
  JSON.parse(response)
end

#get_splash_image(file) ⇒ Object



76
77
78
# File 'lib/openload.rb', line 76

def get_splash_image(file)
  get_a_request_and_return_in_a_struct("/file/getsplash?login=#{@api_login}&key=#{@api_key}&file=#{file}")
end

#remote_upload(url, folder = nil, headers = nil) ⇒ Object

This method make a upload of a link from the web Remember: You need a login and key api to use this method.



46
47
48
49
50
51
52
# File 'lib/openload.rb', line 46

def remote_upload(url, folder = nil , headers = nil)
  if is_logged?
    get_a_request_and_return_in_a_struct("/remotedl/add#{(true)}#{key_parameter}#{http_parameter('url', url)}#{http_parameter('folder',folder)}#{http_parameter('headers', headers)}")
  else
    raise "You need a login and a api key to make remote uploads!"
  end
end

#show_converted_files(folder = nil) ⇒ Object



72
73
74
# File 'lib/openload.rb', line 72

def show_converted_files(folder = nil)
  get_a_request_and_return_in_a_struct("/file/runningconverts?login=#{@api_login}&key=#{@api_key}}#{http_parameter('folder',folder)}")
end

This method return a link that you can make uploads. Warning: this links expire in a few hours, always check the .



40
41
42
# File 'lib/openload.rb', line 40

def upload_link(folder = nil, sha1 = nil, httponly = nil)
  get_a_request_and_return_in_a_struct("/file/ul#{(true)}#{key_parameter}#{http_parameter('folder', folder)}#{http_parameter('sha1', sha1)}#{http_parameter('httponly', httponly)}")
end