Skip to main content

A simple comprehensive Python Wrapper for LivePeerAPI.

Project description

LivePeerSDK

Make LivePeerAPICalls from Python

License : MIT

Copyright (c) 2022 RAGAVENDIRAN BALASUBRAMANIAN.
GMAIL : bgragavendiran@gmail.com
LINKEDIN: https://www.linkedin.com/in/ragavendiranbalasubramanian/

Permission is hereby granted, free of charge, to any person obtaining a copy Of this software and associated documentation files (the "software"), to deal In the software without restriction, including without limitation the rights To use, copy, modify, merge, publish, distribute, sublicense, and/or sell Copies of the software, and to permit persons to whom the software is Furnished to do so, subject to the following condition that the owner and source contributors names and details shall not to be removed from the project

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Powered By

N|Solid

Build Status

LivePeerSDK for Python Developed by Team Heptre, is a realtime PythonSDK that directly interlinks with the LivePeerAPI endpoints which makes the life of the user simple.

Features

  • simply start and use livepeer with livePeer=LivePeerSDK(<LIVEPEER_API_KEY>)
  • The Library is highly modular and plug and play in nature
  • Forget handling requests just make the function call.
  • The request responses are all dicts
  • Detailed Docs Feeling Stuck Anywhere?? help() will get you right back on track.

Installation

LivePeerSDK requires python3 to run.

pip install LivePeerSDK

EXAMPLES

Instructions on how to use LivePeerSDK in your own project can be inferred from below.

from LivePeerSDK_Python.LivePeerSDK import LivePeerSDK
LivePeer=LivePeerSDK(str(<YOUR_LIVEPEER_API_KEY>))

for asset in LivePeer.listAssets():
    print(asset["id"])

OUTPUT:
19233508-5a34-4508-b54f-fe71b062d225
21bd42e3-044e-4093-b920-46fc104b395e
67095c2f-beda-47f1-ad04-2787fad529c9
aecfa170-7d50-4e47-93aa-f0cae8912398
a20373cd-5c27-4948-a5cb-bb55de5def70
d8b52bb6-4bda-4059-bd73-e6dae2d88c80
b9ea232c-6b6c-4a36-9a9c-809f2144592f

Process finished with exit code 0

USAGE

Function USAGE
createUploadUrl(name) Creates a new upload url to directly upload a video asset to livepeer
exportAssetToIPFS(assetID) Export a specific assetID to ipfs it initializes a cloud async call in livepeer which creates a respective taskID
importWebAsset(url, name) Import a video Asset to Livepeer from an external URL.
listAssets() List all assets currently uploaded to livepeer in the form of a dictionary
listTasks() List all tasks currently uploaded to livepeer
retrieveAsset(assetID) Retrieve a specific assetId from live peer
retrieveTask(taskID) Retrieve a specific taskId from livepeer with ipfs link
uploadContent(filePATH, assetURL) Create a new Direct Upload URL to directly upload a video Asset to Livepeer

createUploadUrl(name)

:parameter "name":"Example name"

:returns dict { url:, asset:{'id':, 'playbackId':, 'userId':, 'createdAt':, >'status':, 'name':} task:{'id':, 'createdAt':, 'type':, 'outputAssetId':, >'userId':, 'params':{'uploadedObjectKey': }}, 'status':{'phase': , 'updatedAt': <>timestamp>}} }


exportAssetToIPFS(assetID)

:param "assetID":"$AssetID"

:returns {}


importWebAsset(url, name)

:param "url":"$EXTERNAL_URL", "name":"Example name"


listAssets()

:param : NONE :returns <class 'list'> LIST OF DICTIONARIES OF FORMAT [<class 'dict>,...]

FOR UPLOADED VIDEOS { id : <assetID>, hash : [{'hash': , 'algorithm': 'md5'}, {'hash': , 'algorithm': 'sha256'}] name : , size : , status : ready, userId : , createdAt : , updatedAt : , videoSpec : {'format': , 'tracks': [{'fps': , 'type': 'video', 'codec': 'h264', 'width': , 'height': , 'bitrate': , 'duration': , 'pixelFormat': 'yuv420p'}, {'type': 'audio', 'codec': 'aac', 'bitrate': , 'channels': 2, 'duration': , 'sampleRate': }], 'duration': } playbackId : , downloadUrl : }

FOR PENDING VIDEOS { 'id': , 'name': , 'status': 'waiting', 'userId': , 'createdAt': , 'playbackId': , }


listTasks()


:param : NONE

:returns <class 'list'> LIST OF DICTIONARIES OF FORMAT

FOR EXPORT { 'id':, 'type':, 'output': {'export': {'ipfs': {'videoFileCid':,'nftMetadataCid':,'videoFileUrl':,'videoFileGatewayUrl':,'nftMetadataUrl':,'nftMetadataGatewayUrl':,'params': {'export': {'ipfs': {}}},'status': {'phase':,'updatedAt': },'userId':,'createdAt': ,'inputAssetId':} }

FOR IMPORT { 'id': , 'type': 'import', 'output': {'import': {'assetSpec': {'hash': [hash : [{'hash': , 'algorithm': 'md5'}, {'hash': , 'algorithm': 'sha256'}]], 'name': , 'size': , 'type': 'video', 'videoSpec' : {'format': , 'tracks': [{'fps': , 'type': 'video', 'codec': 'h264', 'width': , 'height': , 'bitrate': , 'duration': , 'pixelFormat': 'yuv420p'}, {'type': 'audio', 'codec': 'aac', 'bitrate': , 'channels': 2, 'duration': , 'sampleRate': }], 'duration': } }}}, 'params': {'import': {'uploadedObjectKey': }}, 'status': { 'phase': , 'userId' : , 'createdAt': , 'updatedAt' : , 'outputAssetId': } }


retrieveAsset(assetID)

:param : assetID obtained from createUploadURL(name) :returns <class 'dict'> LIST OF DICTIONARY OF FORMAT

FOR UPLOADED VIDEOS { id : <assetID>, hash : [{'hash': , 'algorithm': 'md5'}, {'hash': , 'algorithm': 'sha256'}] name : , size : , status : ready, userId : , createdAt : , updatedAt : , videoSpec : {'format': , 'tracks': [{'fps': , 'type': 'video', 'codec': 'h264', 'width': , 'height': , 'bitrate': , 'duration': , 'pixelFormat': 'yuv420p'}, {'type': 'audio', 'codec': 'aac', 'bitrate': , 'channels': 2, 'duration': , 'sampleRate': }], 'duration': } playbackId : , downloadUrl : }

FOR PENDING VIDEOS { 'id': , 'name': , 'status': 'waiting', 'userId': , 'createdAt': , 'playbackId': , }


retrieveTask(taskID)

:param : "taskID obtained from listTASKS

:returns <class 'dict'> LIST OF DICTIONARIES OF FORMAT

FOR EXPORT { 'id':, 'type':, 'output': {'export': {'ipfs': {'videoFileCid':,'nftMetadataCid':,'videoFileUrl':,'videoFileGatewayUrl':,'nftMetadataUrl':,'nftMetadataGatewayUrl':,'params': {'export': {'ipfs': {}}},'status': {'phase':,'updatedAt': },'userId':,'createdAt': ,'inputAssetId':} }

FOR IMPORT { 'id': , 'type': 'import', 'output': {'import': {'assetSpec': {'hash': [hash : [{'hash': , 'algorithm': 'md5'}, {'hash': , 'algorithm': 'sha256'}]], 'name': , 'size': , 'type': 'video', 'videoSpec' : {'format': , 'tracks': [{'fps': , 'type': 'video', 'codec': 'h264', 'width': , 'height': , 'bitrate': , 'duration': , 'pixelFormat': 'yuv420p'}, {'type': 'audio', 'codec': 'aac', 'bitrate': , 'channels': 2, 'duration': , 'sampleRate': }], 'duration': } }}}, 'params': {'import': {'uploadedObjectKey': }}, 'status': { 'phase': , 'userId' : , 'createdAt': , 'updatedAt' : , 'outputAssetId': } }


uploadContent(filePATH, assetURL)

:param "filePATH":"PASS THE FILE PATH OF VIDEO IN H264 and AAC codec "assetURL":ASSET URL FOR THE FILE

:returns {}


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

LivePeerSDK-1.0.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

LivePeerSDK-1.0-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

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