import { NextRequest, NextResponse } from 'next/server'; // TRANSCODING DISABLED: These imports are no longer needed // import { getDatabase } from '@/db'; // import fs from 'fs'; // import { spawn } from 'child_process'; // import { Readable } from 'stream'; // import { ffmpegRegistry } from '@/lib/ffmpeg/process-registry'; // TRANSCODING DISABLED: Request tracking no longer needed // const activeRequests = new Map>(); export async function HEAD( request: NextRequest, { params }: { params: Promise<{ id: string }> } ) { // TRANSCODING DISABLED: Return 410 Gone with local player guidance try { const { id } = await params; return NextResponse.json({ error: 'Transcoding is disabled. This format requires a local video player.', suggestedPlayers: ['VLC Media Player', 'Elmedia Player', 'PotPlayer'], directStreamUrl: `/api/stream/direct/${id}`, helpUrl: '/help/local-players', status: 'transcoding-disabled' }, { status: 410 }); // 410 Gone } catch (error) { console.error('HEAD request error:', error); return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); } } export async function OPTIONS( request: NextRequest, { params }: { params: Promise<{ id: string }> } ) { // TRANSCODING DISABLED: Return 410 Gone for OPTIONS as well return new Response(null, { status: 410, // Gone headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type, Range', 'Access-Control-Max-Age': '86400', 'X-Status': 'transcoding-disabled', }, }); } export async function GET( request: NextRequest, { params }: { params: Promise<{ id: string }> } ) { // TRANSCODING DISABLED: Return 410 Gone with comprehensive local player guidance try { const { id } = await params; return NextResponse.json({ error: 'Transcoding is disabled. This format requires a local video player.', message: 'This video format is not supported for direct browser playback. Please use a local video player application.', suggestedPlayers: [ { name: 'VLC Media Player', id: 'vlc', platforms: ['Windows', 'macOS', 'Linux'], url: 'https://www.videolan.org/vlc/' }, { name: 'IINA', id: 'iina', platforms: ['macOS'], url: 'https://iina.io/' }, { name: 'Elmedia Player', id: 'elmedia', platforms: ['macOS'], url: 'https://www.elmedia-video-player.com/' }, { name: 'PotPlayer', id: 'potplayer', platforms: ['Windows'], url: 'https://potplayer.daum.net/' } ], directStreamUrl: `/api/stream/direct/${id}`, streamInfo: { supportsRangeRequests: true, contentType: 'video/*', authentication: 'none' }, action: 'use-local-player', helpUrl: '/help/local-players', status: 'transcoding-disabled', alternative: 'direct-stream' }, { status: 410 }); // 410 Gone } catch (error) { console.error('Transcoding API error:', error); return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); } } // TRANSCODING DISABLED: Comment out transcoding functionality // This function is no longer used but kept for reference during transition /* async function createTranscodeStream( id: string, filePath: string, seekTime: number, quality: string, duration: number, settings: { width: number, height: number, bitrate: string } ): Promise { // Original transcoding logic disabled // See git history for implementation details throw new Error('Transcoding is disabled. Use local player instead.'); } */ // TRANSCODING DISABLED: Cleanup function no longer needed export async function DELETE( request: NextRequest, { params }: { params: Promise<{ id: string }> } ) { // TRANSCODING DISABLED: Return 410 Gone - no processes to clean up try { const { id } = await params; return NextResponse.json({ error: 'Transcoding cleanup is disabled. No processes to terminate.', status: 'transcoding-disabled', message: 'Transcoding functionality has been removed. Use local video players instead.' }, { status: 410 }); // 410 Gone } catch (error) { console.error('Cleanup API error:', error); return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); } }