Skip to main content

An unofficial Python wrapper for the Rumble Live Stream API v1.0 (beta)

Project description

Cocorum: Rumble Live Stream API Python Wrapper

A Python wrapper for the Rumble Live Stream API v1.0 (beta), with some quality of live additions, such as:

  • Automatic refresh when past the refresh_rate delay when querying any non_static property.
  • All timespamps are parsed to seconds since Epoch, UTC timezone.
  • Chat has new_messages and new_rants properties that return only messages and rants since the last time they were read.

Usage:

I tried to document the wrapper well, so the help function should work. Note, you are only expected to create a RumbleAPI object, and work with everything through that.

Most attributes that are not added features have the same name as the direct JSON counterparts, with the exception of adding prefixes to some things that have the same name in the JSON as Python builtin functions. For example, thing/id in JSON is thing.thing_id in this Python wrapper.

from cocorum import RumbleAPI
from cocorum.localvars import *

api = RumbleAPI(API_URL, refresh_rate = 10)

print(api.username)
print(api.latest_follower)

if api.latest_subscriber:
    print(api.latest_subscriber, "subscribed for $" + str(api.latest_subscriber.amount_dollars))

#RumbleLivestream objects returned by RumbleAPI properties are deep: When queried, they will pull new information via their parent RumbleAPI object.
livestream = api.latest_livestream #None if there is no stream running

if livestream:
    if livestream.visibility != STREAM_VIS_PUBLIC:
        print("Stream is not public.")
    message = livestream.chat.latest_message #None if there are no messages yet
    if message:
        print(message.username, "said", message)

Experimental SSE chat submodule

This part of cocorum is not part of the official Rumble Livestream API, but may provide a more reliable method of ensuring all chat messages are received.

from cocorum import ssechat

chat = ssechat.SSEChat(chat_id = CHAT_ID)
#Do chat.mailbox = [] here to erase messages that were still visible before we connected

msg = True
while msg:
    msg = chat.next_chat_message() #Hangs until a new message arrives
    print(msg.user.username, ":", msg)

print("Chat has closed.")

Conclusion

Hope this helps!

I, Wilbur Jaywright, and my brand, Marswide BGL, have no official association with Rumble Corp. beyond that of a normal user and/or channel on the Rumble Video platform. This wrapper is not officially endorsed by Rumble Corp. or its subsidiaries.

S.D.G.

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

cocorum-0.3.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

cocorum-0.3.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file cocorum-0.3.0.tar.gz.

File metadata

  • Download URL: cocorum-0.3.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for cocorum-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9e1a2f957e1efe698403f38f6b79f71910e7303eb84a7014776d88059495f0e1
MD5 36490633827e93f47c1b024493349cad
BLAKE2b-256 ddc98ce1955d07788e552f36959b3cbe790bba537fc29775e73ab4e29a950c8d

See more details on using hashes here.

File details

Details for the file cocorum-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cocorum-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for cocorum-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48965a699528ace83bcef44a0a700b33eabe847816451275c10fb44e3a060047
MD5 36d4391925efcc8b03ccc8096ee328dd
BLAKE2b-256 58d0162bd09dce1f0cb3aabbf2299259c1565e49fa9ead0d70eed3af6eac32c4

See more details on using hashes here.

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