Prefix OBS source names with team scene names
All checks were successful
Lint and Build / build (pull_request) Successful in 2m51s
All checks were successful
Lint and Build / build (pull_request) Successful in 2m51s
Update stream creation to include team prefixes in all OBS source naming: - Browser sources: team_streamname format - Stream group scenes: team_streamname_stream format - Consistent naming across createStreamGroup and addStream functions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b6937f3a4f
commit
6fc079382a
2 changed files with 25 additions and 19 deletions
|
@ -63,9 +63,11 @@ async function fetchTeamInfo(teamId: number) {
|
||||||
|
|
||||||
import { validateStreamInput } from '../../../lib/security';
|
import { validateStreamInput } from '../../../lib/security';
|
||||||
|
|
||||||
// Generate OBS source name from stream name
|
// Generate OBS source name from team scene name and stream name
|
||||||
function generateOBSSourceName(streamName: string): string {
|
function generateOBSSourceName(teamSceneName: string, streamName: string): string {
|
||||||
return streamName.toLowerCase().replace(/\s+/g, '_') + '_twitch';
|
const cleanTeamName = teamSceneName.toLowerCase().replace(/\s+/g, '_');
|
||||||
|
const cleanStreamName = streamName.toLowerCase().replace(/\s+/g, '_');
|
||||||
|
return `${cleanTeamName}_${cleanStreamName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
|
@ -85,14 +87,24 @@ export async function POST(request: NextRequest) {
|
||||||
|
|
||||||
({ name, url, team_id } = validation.data!);
|
({ name, url, team_id } = validation.data!);
|
||||||
|
|
||||||
// Auto-generate OBS source name from stream name
|
|
||||||
obs_source_name = generateOBSSourceName(name);
|
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 });
|
return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Fetch team info first to generate proper OBS source name
|
||||||
|
const teamInfo = await fetchTeamInfo(team_id);
|
||||||
|
if (!teamInfo) {
|
||||||
|
throw new Error('Team not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Team Info:', teamInfo);
|
||||||
|
|
||||||
|
// Use group_name if it exists, otherwise use team_name
|
||||||
|
const groupName = teamInfo.group_name || teamInfo.team_name;
|
||||||
|
|
||||||
|
// Generate OBS source name with team scene name prefix
|
||||||
|
obs_source_name = generateOBSSourceName(groupName, name);
|
||||||
|
|
||||||
// Connect to OBS WebSocket
|
// Connect to OBS WebSocket
|
||||||
console.log("Pre-connect")
|
console.log("Pre-connect")
|
||||||
|
@ -117,16 +129,6 @@ export async function POST(request: NextRequest) {
|
||||||
throw new Error('GetInputList failed.');
|
throw new Error('GetInputList failed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const teamInfo = await fetchTeamInfo(team_id);
|
|
||||||
if (!teamInfo) {
|
|
||||||
throw new Error('Team not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Team Info:', teamInfo);
|
|
||||||
|
|
||||||
// Use group_name if it exists, otherwise use team_name
|
|
||||||
const groupName = teamInfo.group_name || teamInfo.team_name;
|
|
||||||
|
|
||||||
const sourceExists = inputs.some((input: OBSInput) => input.inputName === obs_source_name);
|
const sourceExists = inputs.some((input: OBSInput) => input.inputName === obs_source_name);
|
||||||
|
|
||||||
if (!sourceExists) {
|
if (!sourceExists) {
|
||||||
|
@ -174,7 +176,9 @@ export async function POST(request: NextRequest) {
|
||||||
|
|
||||||
for (const screen of screens) {
|
for (const screen of screens) {
|
||||||
try {
|
try {
|
||||||
const streamGroupName = `${name.toLowerCase().replace(/\s+/g, '_')}_stream`;
|
const cleanGroupName = groupName.toLowerCase().replace(/\s+/g, '_');
|
||||||
|
const cleanStreamName = name.toLowerCase().replace(/\s+/g, '_');
|
||||||
|
const streamGroupName = `${cleanGroupName}_${cleanStreamName}_stream`;
|
||||||
await addSourceToSwitcher(screen, [
|
await addSourceToSwitcher(screen, [
|
||||||
{ hidden: false, selected: false, value: streamGroupName },
|
{ hidden: false, selected: false, value: streamGroupName },
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -317,8 +317,10 @@ async function createStreamGroup(groupName, streamName, teamName, url) {
|
||||||
// Ensure team scene exists
|
// Ensure team scene exists
|
||||||
await createGroupIfNotExists(groupName);
|
await createGroupIfNotExists(groupName);
|
||||||
|
|
||||||
const streamGroupName = `${streamName.toLowerCase().replace(/\s+/g, '_')}_stream`;
|
const cleanGroupName = groupName.toLowerCase().replace(/\s+/g, '_');
|
||||||
const sourceName = streamName.toLowerCase().replace(/\s+/g, '_') + '_twitch';
|
const cleanStreamName = streamName.toLowerCase().replace(/\s+/g, '_');
|
||||||
|
const streamGroupName = `${cleanGroupName}_${cleanStreamName}_stream`;
|
||||||
|
const sourceName = `${cleanGroupName}_${cleanStreamName}`;
|
||||||
const textSourceName = teamName.toLowerCase().replace(/\s+/g, '_') + '_text';
|
const textSourceName = teamName.toLowerCase().replace(/\s+/g, '_') + '_text';
|
||||||
|
|
||||||
// Create a nested scene for this stream (acts as a group)
|
// Create a nested scene for this stream (acts as a group)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue