A simple Python API wrapper for Cloudflare Stream's API.

Overview

python-cloudflare-stream

A basic Python API wrapper for working with Cloudflare Stream.

Arbington.com started off using Cloudflare Stream. We used their API very heavily and pulled out our code into a simple client for others to use. It's not perfect, nor is it close to being complete. But it's a good start for anyone who wishes to contribute!

Installation

pip install python-cloudflare-stream

Setup

You will need a Cloudflare account with Stream minutes added. We recommend starting small with a $5 subscription just to get your feet wet.

Once you have your Cloudflare Stream subscription you'll need:

  • Your Account ID, which you can find in your Cloudflare Dashboard.
  • Your email address you used for Cloudflare
  • Your API key
  • Then run:
from python_cloudflare_stream.client import StreamClient

keys = StreamClient.create_signing_keys()
print(keys)

That will give the PEM key you will need and the "signing token". Save these as they are only displayed once.

Understanding Cloudflare Stream

Stream is a bit different from other platforms. It's very basic, fast, reliable and moderately priced.

Everytime you upload a video, the video receives a "UID". You'll want to store this UID as it's the only way to refer to a video through their API.

Here is some example code to get you started:

from python_cloudflare_stream.client import StreamClient

keys = StreamClient.create_signing_keys('your-cloudflare-account-id', '[email protected]', 'your-api-key')  # Gives you your PEM and signing_token (called an "id") if you don't have that already. These are only displayed once per API call and aren't shown when listing your keys

# Store these somewhere safe.
signing_token = keys['result']['id']
pem = keys['result']['pem']

# Init the client
client = StreamClient(
    auth_email='[email protected]',
    auth_api_key='qwertyqwertyqwertyqwertyqwertyqwerty',
    account_id='asdf1asdf2asdf3asdf4asdf5',
    pem='LS0TEASRASDASDa-VERY-long-string-here=',
    signing_token='qwertyqwertyqwertyqwertyqwerty',
)

# Sample download URL
download_url = 'https://yourwebsite.com/video.mp4'
# Tell Cloudflare to download the sample download URL from above
video_uid, all_data_dict = client.pull_from_url(download_url, 'Test video', require_signed_url=True, watermark_uid=None)

# Get details about a specific video from its video_uid
data = client.get_video(video_uid)

# Get the total minutes in your account, and the total remaining minutes
client.get_total_storage_minutes()
client.get_remaining_cloudflare_minutes()

# Create a download URL from Cloudflare. Wait until its ready, or return a URL that can be used sometime in the future.
download_url = client.get_download_url(video_uid, wait_until_ready=True)

# Delete a video
deleted = client.delete_video(video_uid)

# List up to 1000 videos at once
videos = client.get_all_videos()

Contributing

Happy to accept contributions of any size!

Owner
Arbington
Learn anything from anyone at any time.
Arbington
Messing around with GitHub API to look at omicron build times

gh-workflow-runs This is a very simple tool to dump out basic information about workflow runs for a GitHub repo. The structure is based on gh-subscrip

David Pacheco 1 Nov 30, 2021
A telegram string extractor bot

Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github.com/FayasNoushad/String-Extract-Bot/blob/main/LIC

Fayas Noushad 12 Jul 19, 2022
Cookiecutter templates for Serverless applications using AWS SAM and the Rust programming language.

Cookiecutter SAM template for Lambda functions in Rust This is a Cookiecutter template to create a serverless application based on the Serverless Appl

AWS Samples 24 Nov 11, 2022
Discord Token Nuker With Python

Discord token nuker a.k.a A$$Fvcker Setup For installing the requirements do this: pip install -r requirements.txt To start the Token nuker run this

PR3C14D0 8 Sep 22, 2022
Python wrapper for eBay API

python-ebay - Python Wrapper for eBay API This project intends to create a simple python wrapper around eBay APIs. Development and Download Sites The

Roopesh 99 Nov 16, 2022
Currency Merger is a simple tool for joining values in different currencies

Currency Merger Description Currency Merger is a simple tool for joining values in different currencies. For example, if I have money in USD, EUR, BRL

Arthur Diniz 1 Feb 08, 2022
A simple Python TDLib wrapper

Telegram Forwarder App Description pywtdlib (Python Wrapper TDLib) is a simple synchronous Python wrapper that makes you easy to create new Python Tel

Álvaro Fernández 2 Jan 04, 2023
LavaAPI - A simple library for accepting payments and using the LAVA Wallet

This library was created to simplify the LAVA api provided on the official websi

Vlad Baccara 8 Dec 18, 2022
Wordnik Python public library

Python 2.7 client for Wordnik.com API Overview This is a Python 2.7 client for the Wordnik.com v4 API. For more information, see http://developer.word

Wordnik 224 Dec 29, 2022
✖️ Unofficial API of 1337x.to

✖️ Unofficial Python API Wrapper of 1337x This is the unofficial API of 1337x. It supports all proxies of 1337x and almost all functions of 1337x. You

Hemanta Pokharel 71 Dec 26, 2022
SpautiNoFay - A simple and beautiful music player created with Python

SpautiNoFay A simple and beautiful music player created with Python Why SpautiNo

8 Jan 19, 2022
Forked from 0x36 on github who then rewrote the ida_kernelcache python framework

Forked from 0x36 on github who then rewrote the ida_kernelcache python framework. Sadly 0x36 doesn't seem to have push updates to the project and it took me a very long time to figure out why this wa

Turnerhackz1 6 Dec 13, 2022
Ethereum transactions and wallet information for people you follow on Twitter.

ethFollowing Ethereum transactions and wallet information for people you follow on Twitter. Set up Setup python environment (requires python 3.8): vir

Brian Donohue 2 Dec 28, 2021
A self-bot for discord, written in Python, which will send you notifications to your desktop if it detects an intruder on your discord server

A self-bot for discord, written in Python, which will send you notifications to your desktop if it detects an intruder on your discord server

LevPrav 1 Jan 11, 2022
Plazmix API wrapper for Python

An optimised, easy to use Plazmix API wrapper written in Python

Someone 2 Nov 16, 2021
A anti-repostbot script for reddit, runs u/ThisIsARepostBotBot

ThisIsARepostBotBot So you found a repost bot, now what? This is a bot to reply to all posts of a repost bot with a message urging users to report and

3 May 23, 2022
A simple library for interacting with Amazon SQS.

qoo is a very simple Amazon SQS client, written in Python. It aims to be much more straight-forward to use than boto3, and specializes only in Amazon

Jacobi Petrucciani 2 Oct 30, 2020
Yes, it's true :heartbeat: This repository has 337 stars.

Yes, it's true! Inspired by a similar repository from @RealPeha, but implemented using a webhook on AWS Lambda and API Gateway, so it's serverless! If

512 Jan 01, 2023
A group management bot written in python3 using the python-telegram-bot library.

Chika Fujiwara A modular telegram Python bot running on python3 with an sqlalchemy database. Originally a Marie fork, Chika was created for personal u

Wahyusaputra 3 Feb 12, 2022
A Discord Bot that tracks and displays cryptocurrencies using the CoinMarketCap API

PyBo - A Crypto Inspired Discord Bot Pybo (paɪ boʊ) is a Discord bot that utilizes the discord.py API wrapper to run the bot. Pybo also integrates the

0 Nov 17, 2022