perloader
import os
import requests
import urllib.request
import re

import hashlib

def upto_openload(files):

    dir0 = str(os.getcwd()).replace('\\', '/')
    os.chdir(dir0)

    sha1 = hashlib.sha1()

    BLOCKSIZE = 65536
    with open(files, 'rb') as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            sha1.update(buf)
            buf = afile.read(BLOCKSIZE)

    sha1_hash = sha1.hexdigest()

    url = "https://api.openload.co/1/file/ul?login={login}&key={key}&sha1={sha1}".format(
        login='xxxxxxx',
        key='xxxxxx',
        sha1=sha1_hash,
    )

    p = {
        'url': url,
        'headers': {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
        }
    }
    r = requests.get(url=p['url'], headers=p['headers'])
    j = r.json()

    print(j)
    upload_link = j['result']['url']
    print(upload_link)


    files = {'file': open(files, 'rb')}

    r = requests.post(upload_link, files=files)
    j = r.json()
    print(j)
    dl=j['result']['url']
    return dl


files = 'test01.txt'
dl=upto_openload(files)
print(dl)

Upload

Get an Upload URL

Uploads shall be POSTed to the upload URL returned by our API and shall be multipart/form-data encoded. Example with curl:

curl -F file1=@/path/to/file.txt https://13abc37.example.com/ul/jAZUhVzeU78

Request

https://api.openload.co/1/file/ul?login={login}&key={key}&folder={folder}&sha1={sha1}&httponly={httponly}

Parameters

Name Description Example Required
login API-Login 5147a8f8e924bc82 no
key API-Key / API-Password Fa89_X13-37a8CKR no
folder Folder-ID to upload to 1234 no
sha1 Expected sha1
If sha1 of uploaded file doesn’t match this value, upload fails
2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 no
httponly If this is set to true, use only http upload links 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 no

Response

200 (OK)
Content-Type: application/json
{
    "status": 200,
    "msg": "OK",
    "result": {
        "url": "https://13abc37.example.com/ul/fCgaPthr_ys",
        "valid_until": "2015-01-09 00:02:50"
    }
}
xyz