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 life 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 help("cocorum") should work. Note, you are only expected to create a RumbleAPI() and / or ssechat.SSEChat() object, and work with everything through them.

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 *
import time

#API_URL is either your Rumble Live Stream API URL with key,
#or if you are also running GlobalGamer2015's RumBot, use http://localhost:9843/api/ls
#to use RumBot's API passthrough and reduce unnecessary API traffic.
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.")

    #Get messages for one minute
    start_time = time.time()
    while time.time() - start_time < 60 and livestream.is_live:
        for message in livestream.chat.new_messages:
            print(message.username, "said", message)
        time.sleep(0.1)

Experimental SSE chat submodule

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

from cocorum import ssechat

chat = ssechat.SSEChat(stream_id = stream_id) #Stream ID can be base 10 or 36
chat.clear_mailbox() #Erase messages that were still visible before we connected

#Get messages for one minute
start_time = time.time()
while time.time() - start_time < 60 and (msg := chat.get_message()):
    print(msg.user.username, "said", msg)

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-1.5.0.tar.gz (365.4 kB view details)

Uploaded Source

Built Distribution

cocorum-1.5.0-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cocorum-1.5.0.tar.gz
Algorithm Hash digest
SHA256 a4f08d221026f3a6d396b123f3ef7ec2bf2121c01a4831c7b10ef4c32079d717
MD5 93120847c776a37b54967c5f9d75b200
BLAKE2b-256 bbd12097e383dfedb33abaf983771103cd408efaa6fbc24963b1aabc7ad84f64

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cocorum-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af8d09f021d117d7cbb114fda0304d5834bcc20645c21add3068eba5f201cdda
MD5 4ccb1eea5f715e29ac886ff1384128aa
BLAKE2b-256 d3dc488ebe4c350690fbd96cdcfc51a5553253742f0b7c13e271ae13193f2b8f

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