Skip to content

Commit

Permalink
feat: add audience type selection (Everyone/Adults)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loukious committed Nov 13, 2024
1 parent 3994645 commit f1e071e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def search(self, game):
info["categories"].append({"full_name": "Other", "game_mask_id": ""})
return info["categories"]

def start(self, title, category):
def start(self, title, category, audience_type='0'):
url = "https://streamlabs.com/api/v5/slobs/tiktok/stream/start"
files=(
('title', (None, title)),
('device_platform', (None, 'win32')),
('category', (None, category)),
('audience_type', (None, audience_type)),
)
response = self.s.post(url, files=files).json()
try:
Expand Down
23 changes: 21 additions & 2 deletions StreamLabsTikTokStreamKeyGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ def load_config():
game_category_entry.delete(0, tk.END)
game_category_entry.insert(0, data.get("game", ""))
game_category_entry.config(state=tk.DISABLED)


audience_type_checkbox.config(state=tk.NORMAL)
audience_type_var.set(data.get("audience_type", "0"))
audience_type_checkbox.config(state=tk.DISABLED)

if token_entry.get():
global stream
stream = Stream(token_entry.get())
go_live_button.config(state=tk.NORMAL)
stream_title_entry.config(state=tk.NORMAL)
game_category_entry.config(state=tk.NORMAL)
audience_type_checkbox.config(state=tk.NORMAL)
load_account_info()

if stream:
Expand Down Expand Up @@ -92,6 +96,7 @@ def save_config():
data = {
"title": stream_title_entry.get(),
"game": game_category_entry.get(),
"audience_type": audience_type_var.get(),
"token": token_entry.get()
}
with open("config.json", "w") as file:
Expand Down Expand Up @@ -186,7 +191,7 @@ def on_token_entry_change(*args):
def go_live():
game_mask_id = getattr(game_category_entry, 'game_mask_id', "")

stream_url, stream_key = stream.start(stream_title_entry.get(), game_mask_id)
stream_url, stream_key = stream.start(stream_title_entry.get(), game_mask_id, audience_type_var.get())

if stream_url or stream_key:
stream_url_entry.config(state=tk.NORMAL)
Expand Down Expand Up @@ -365,6 +370,20 @@ def on_motion(event):
listbox.bind("<<ListboxSelect>>", on_select)
listbox.bind("<Motion>", on_motion)

# Create a StringVar to hold the value for audience type
audience_type_var = tk.StringVar(value='0') # Default to '0' (everyone)

# Create a checkbox for mature content
audience_type_checkbox = tk.Checkbutton(
stream_frame,
text="Enable mature content",
variable=audience_type_var,
onvalue='1', # Set to '1' when checked
offvalue='0', # Set to '0' when unchecked
state=tk.DISABLED
)
audience_type_checkbox.pack(pady=5)

# Create a LabelFrame for stream control buttons and info
control_frame = tk.LabelFrame(root, text="Stream Control", padx=10, pady=10)
control_frame.grid(row=0, column=1, rowspan=2, padx=10, pady=10, sticky='nsew')
Expand Down

0 comments on commit f1e071e

Please sign in to comment.