- Add createTextSource function with automatic OBS text input detection - Implement createStreamGroup to create groups within team scenes instead of separate scenes - Add team name text overlays positioned at top-left of each stream - Refactor stream switching to use stream group names for cleaner organization - Update setActive API to write stream group names to files - Fix getActive API to return correct screen position data - Improve team UUID assignment when adding streams - Remove manage streams section from home page for cleaner UI - Add vertical spacing to streams list to match teams page - Support dynamic text input kinds (text_ft2_source_v2, text_gdiplus, etc.) This creates a much cleaner OBS structure with 10 team scenes containing grouped stream sources rather than 200+ individual stream scenes, while adding team name text overlays for better stream identification. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
56 lines
2 KiB
TypeScript
56 lines
2 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { FILE_DIRECTORY } from '../../../config';
|
|
import { getDatabase } from '../../../lib/database';
|
|
import { Stream } from '@/types';
|
|
import { validateScreenInput } from '../../../lib/security';
|
|
import { TABLE_NAMES } from '../../../lib/constants';
|
|
|
|
export async function POST(request: NextRequest) {
|
|
// Parse and validate request body
|
|
try {
|
|
const body = await request.json();
|
|
const validation = validateScreenInput(body);
|
|
|
|
if (!validation.valid) {
|
|
return NextResponse.json({
|
|
error: 'Validation failed',
|
|
details: validation.errors
|
|
}, { status: 400 });
|
|
}
|
|
|
|
const { screen, id } = validation.data!;
|
|
|
|
console.log('Writing files to', path.join(FILE_DIRECTORY(), `${screen}.txt`));
|
|
const filePath = path.join(FILE_DIRECTORY(), `${screen}.txt`);
|
|
|
|
try {
|
|
const db = await getDatabase();
|
|
const stream: Stream | undefined = await db.get<Stream>(
|
|
`SELECT * FROM ${TABLE_NAMES.STREAMS} WHERE id = ?`,
|
|
[id]
|
|
);
|
|
|
|
console.log('Stream:', stream);
|
|
|
|
if (!stream) {
|
|
return NextResponse.json({ error: 'Stream not found' }, { status: 400 });
|
|
}
|
|
|
|
// Use stream group name instead of individual obs_source_name
|
|
const streamGroupName = `${stream.name.toLowerCase().replace(/\s+/g, '_')}_stream`;
|
|
fs.writeFileSync(filePath, streamGroupName);
|
|
return NextResponse.json({ message: `${screen} updated successfully.` }, { status: 200 });
|
|
} catch (error) {
|
|
console.error('Error updating active source:', error);
|
|
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
|
|
return NextResponse.json(
|
|
{ error: 'Failed to update active source', details: errorMessage },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
} catch {
|
|
return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 });
|
|
}
|
|
}
|