Skip to content

Misc

Miscellanious classes and functions

Functions and classes that did not fit in another module S.D.G.

ClipUploader

Upload clips to Rumble automatically

Source code in rumchat_actor/misc.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class ClipUploader():
    """Upload clips to Rumble automatically"""
    def __init__(self, actor, clip_command, **kwargs):
        """Upload clips to Rumble automatically

    Args:
        actor (RumbleChatActor): The RumbleChatActor() instance
        clip_command (ChatCommand): The clip command instance
        channel_id (str | int): The name or int ID of the channel to upload to, defaults to no channel (user page)"""

        #Save actor
        self.actor = actor

        #Save clip command instance and assign ourself to it
        self.clip_command = clip_command
        self.clip_command.clip_uploader = self

        #Get upload system
        self.uploadphp = uploadphp.UploadPHP(self.actor.servicephp)

        #Channel ID to use, or None if it was not passed
        self.channel_id = kwargs.get("channel_id", 0)

        #List of clip filenames to upload
        self.clips_to_upload = queue.Queue()

        #Thread to keep uploading clips as they arrive
        self.clip_uploader_thread = threading.Thread(target = self.clip_upload_loop, daemon = True)
        self.clip_uploader_thread.start()

    def upload_clip(self, name, complete_path):
        """Add the clip filename to the queue

    Args:
        name (str): The base name of the clip.
        complete_path (str): The full file path of the clip."""
        self.clips_to_upload.put((name, complete_path))

    def __upload_clip(self, name, complete_path):
        """Upload a clip to Rumble

    Args:
        name (str): The base name of the clip.
        complete_path (str): The full file path of the clip."""

        upload = self.uploadphp.upload_video(
            file_path = complete_path,
            title = f"stream {self.actor.stream_id_b10} clip {name}",
            description = "Automatic clip upload. Enjoy!",
            category1 = static.Clip.Upload.category_1,
            category2 = static.Clip.Upload.category_2,
            channel_id = self.channel_id,
            visibility = "unlisted",
            )

        #Announce link
        self.actor.send_message("Clip uploaded to " + upload.url)

        print(f"Clip {name} published.")

    def clip_upload_loop(self):
        """Keep uploading clips while actor is alive"""
        while self.actor.keep_running:
            try:
                self.__upload_clip(*self.clips_to_upload.get_nowait())
            except queue.Empty:
                pass

            time.sleep(1)

__init__(actor, clip_command, **kwargs)

Upload clips to Rumble automatically

Parameters:

Name Type Description Default
actor RumbleChatActor

The RumbleChatActor() instance

required
clip_command ChatCommand

The clip command instance

required
channel_id str | int

The name or int ID of the channel to upload to, defaults to no channel (user page)

required
Source code in rumchat_actor/misc.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def __init__(self, actor, clip_command, **kwargs):
    """Upload clips to Rumble automatically

Args:
    actor (RumbleChatActor): The RumbleChatActor() instance
    clip_command (ChatCommand): The clip command instance
    channel_id (str | int): The name or int ID of the channel to upload to, defaults to no channel (user page)"""

    #Save actor
    self.actor = actor

    #Save clip command instance and assign ourself to it
    self.clip_command = clip_command
    self.clip_command.clip_uploader = self

    #Get upload system
    self.uploadphp = uploadphp.UploadPHP(self.actor.servicephp)

    #Channel ID to use, or None if it was not passed
    self.channel_id = kwargs.get("channel_id", 0)

    #List of clip filenames to upload
    self.clips_to_upload = queue.Queue()

    #Thread to keep uploading clips as they arrive
    self.clip_uploader_thread = threading.Thread(target = self.clip_upload_loop, daemon = True)
    self.clip_uploader_thread.start()

__upload_clip(name, complete_path)

Upload a clip to Rumble

Parameters:

Name Type Description Default
name str

The base name of the clip.

required
complete_path str

The full file path of the clip.

required
Source code in rumchat_actor/misc.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def __upload_clip(self, name, complete_path):
    """Upload a clip to Rumble

Args:
    name (str): The base name of the clip.
    complete_path (str): The full file path of the clip."""

    upload = self.uploadphp.upload_video(
        file_path = complete_path,
        title = f"stream {self.actor.stream_id_b10} clip {name}",
        description = "Automatic clip upload. Enjoy!",
        category1 = static.Clip.Upload.category_1,
        category2 = static.Clip.Upload.category_2,
        channel_id = self.channel_id,
        visibility = "unlisted",
        )

    #Announce link
    self.actor.send_message("Clip uploaded to " + upload.url)

    print(f"Clip {name} published.")

clip_upload_loop()

Keep uploading clips while actor is alive

Source code in rumchat_actor/misc.py
73
74
75
76
77
78
79
80
81
def clip_upload_loop(self):
    """Keep uploading clips while actor is alive"""
    while self.actor.keep_running:
        try:
            self.__upload_clip(*self.clips_to_upload.get_nowait())
        except queue.Empty:
            pass

        time.sleep(1)

upload_clip(name, complete_path)

Add the clip filename to the queue

Parameters:

Name Type Description Default
name str

The base name of the clip.

required
complete_path str

The full file path of the clip.

required
Source code in rumchat_actor/misc.py
43
44
45
46
47
48
49
def upload_clip(self, name, complete_path):
    """Add the clip filename to the queue

Args:
    name (str): The base name of the clip.
    complete_path (str): The full file path of the clip."""
    self.clips_to_upload.put((name, complete_path))