Git Product home page Git Product logo

pybeamit's Introduction

PyBeamIt

This is a python wrapper around the unofficial just beam it API. It supports both sending and receiving files.

Installation

Via pip:

$ pip install pybeamit

Or from source:

$ git clone https://github.com/cartertemm/pybeamit.git
$ pip install .

Usage

Integrating P2P file sharing capability in your application is extremely simple.

On the sender's machine:

from pybeamit import JustBeamIt

j = JustBeamIt("file.wav")
#or for multiple files:
j = JustBeamIt(("file.wav", "file2.mp3"))
t=j.tokenise()
print("retrieval url for recipient: "+t)
print("waiting for recipient...")
j.wait()
print("starting the transfer")
j.transfer()
print("done")

On the receiving end:

from pybeamit import JustBeamIt

url = ""  # e.g. https://www.justbeamit.com/s8x9j
j = JustBeamIt()
j.download(url, path="dest")

There are also a couple demos.

All operations require a JustBeamIt object:

class JustBeamIt(files=[], base_url=None, backend_url=None)

Once you have an instance, the following methods are defined:

tokenise()
	Initiates the transfer with a backend server, returning a URL for download.
	note: This must be called on the sender's machine.
wait()
	Blocks until a recipient is available to receive the file.
transfer(progress_callback=None)
	Perform the transfer, blocking until complete.
	progress_callback will be called internally with one parameter, percentage
	note: As of version 0.3, wait must be called first to ensure the other peer is ready to receive the file.
download(self, url_or_token, path=None, progress_callback=None, chunk_size=1024)
	Blocking function that initiates a download.
	The downloaded file will be saved in path (if provided) otherwise the current directory.
	progress_callback will be called internally with one parameter, the percentage of the transfer (0-100).

contributing

Contributions are appreciated, thanks for your interest! Submit issues through the tracker. New features are accepted through PRs.

see also

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.