Skip to main content

filebit python library and cli

Project description

Installation

pip install filebit

Check Filebit URL & Get Parts

from filebit import api
filebit_url = "https://filebit.net/f/qknI9LX#Ac1A3HJ13aBRn66XHnkktQNlOK1dxItiRqnkAovV82uU";
is_valid = api.is_valid_url(filebit_url)
print(is_valid) # True
parts = api.get_parts(filebit_url)
print(parts) # ('qknI9LX', 'Ac1A3HJ13aBRn66XHnkktQNlOK1dxItiRqnkAovV82uU')

Get Upload Server

from filebit import api
# get a list of usable servers
servers = api.get_upload_servers()
print(servers)

# pick one randomly
random_server = api.get_upload_server()
print(random_server)

Get File Informations

from filebit import api
info = api.get_file_info("https://filebit.net/f/teBKKQ6#Abts8F6i70LmwgoeUrDe_8RWMmuXBtQj5C_BguRzJL-p")
filename = info['filename']
filesize = info['filesize']
print(f'{filename} Filesize: {filesize}')
#Example.zip Filesize: 104857600

Multi File Information(s)

from filebit import api, crypto
urls = [
    "https://filebit.net/f/tlBKQQ6#Abts8F6i70LmwgoeUrDe_1RWMmuXBtQj5C_BguRzJL",
    "https://filebit.net/f/AfAiPEM#AbotIF8zJdU44b6cF_9f9kXIir_U5AmODfRiWE9xDo2U"
] # replace example links with actual links...

infos = api.get_multi_info(urls);

for url in urls:
    parts = api.get_parts(url)
    id = parts[0]
    key = parts[1]
    info = infos[id]
    filename = "n/A"
    size = 0
    if info["state"] == "ONLINE":
        decryptor = crypto.FilebitCipher(key).decryptor()
        filename = crypto.unpad(decryptor.update(crypto.b64dec(info['name'])) + decryptor.finalize()).decode("utf-8")
        size = info['size']
    state = info['state']
    print(f'[{state}] {filename} Filesize: {size}')

Upload

from filebit import upload
u = upload.Upload(path)
u.max_workers = 4 # parallel upload workers
u.start(retries=10) # returns admin code
print(u.get_link())

Download

import os
from filebit import download
from pathlib import Path
d = download.Download("https://filebit.net/f/tlBKQQ6#Abts8F6i70LmwgoeUrDe_1RWMmuXBtQj5C_BguRzJL")
d.prepare()
path = Path(os.getcwd())
if path.is_dir():
    path = path.joinpath(d.filename)
d.start(path)
success = d.validate()
if success:
    print("File download successful")
    print("Stored at:")
    print(d.path)
else:
    print("Download failed.")

CLI Usage

CLI for filebit. Can upload and download files.
Usage:
    filebit upload <FILE> [-p parallel]
    filebit download <url> [-o OUTPUT] [-l licence_key] [-p parallel] [--overwrite]

Options:
    FILE: path to a file
    -o OUTPUT: path or directory to a place where to store the file
    -l licence_key: valid licence key for premium downloads
    --overwrite: overwrite if file exists
    -p parallel: upload or download multiple chunks at the same time

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filebit-1.2.2.tar.gz (9.3 kB view details)

Uploaded Source

File details

Details for the file filebit-1.2.2.tar.gz.

File metadata

  • Download URL: filebit-1.2.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for filebit-1.2.2.tar.gz
Algorithm Hash digest
SHA256 d79ad857219280c0a92ad9aab9abdc61380f0cd4f9d1d4252557da2a9dfebf7d
MD5 110a8ee0423dbba9c8570552f10c4947
BLAKE2b-256 8299148ee69ddeaa01784e6be916324f82bb1c962b521a4f616fff6949cd5b1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page