Skip to content

Misc

Miscellanious classes and functions

Functions and classes that did not fit in another module

This file is part of Rumble Chat Actor.

Rumble Chat Actor is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Rumble Chat Actor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Rumble Chat Actor. If not, see https://www.gnu.org/licenses/.

S.D.G.

ClipUploader

Upload clips to Rumble automatically

Source code in rumchat_actor/misc.py
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
        # WARNING: uploadphp is used within thread without mutex!
        # WARNING: If servicephp is logged in after uploadphp is created, it could modify session_cookie while uploadphp is using it
        # But, RumChatActor always logs in upon init. So, this is safe, as long as the user doesn't RE-login during operation
        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
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
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
    # WARNING: uploadphp is used within thread without mutex!
    # WARNING: If servicephp is logged in after uploadphp is created, it could modify session_cookie while uploadphp is using it
    # But, RumChatActor always logs in upon init. So, this is safe, as long as the user doesn't RE-login during operation
    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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
88
89
90
91
92
93
94
95
96
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
58
59
60
61
62
63
64
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))

This file is part of Rumble Chat Actor.

Rumble Chat Actor is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Rumble Chat Actor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Rumble Chat Actor. If not, see https://www.gnu.org/licenses/.

S.D.G.