diff --git a/app/api/detail/route.ts b/app/api/detail/route.ts
index a9ba576..1b9b551 100644
--- a/app/api/detail/route.ts
+++ b/app/api/detail/route.ts
@@ -7,60 +7,67 @@ import { NextRequest, NextResponse } from 'next/server';
import { getVideoDetail } from '@/lib/api/client';
import { getSourceById } from '@/lib/api/video-sources';
+/**
+ * Shared handler for fetching video details
+ */
+async function handleDetailRequest(id: string | null, source: string | null, method: string) {
+ // Validate input
+ if (!id) {
+ return NextResponse.json(
+ { error: 'Missing video ID parameter' },
+ { status: 400 }
+ );
+ }
+
+ // Validate source
+ if (!source) {
+ return NextResponse.json(
+ { error: 'Missing source parameter' },
+ { status: 400 }
+ );
+ }
+
+ const sourceConfig = getSourceById(source);
+
+ if (!sourceConfig) {
+ return NextResponse.json(
+ { error: 'Invalid source ID' },
+ { status: 400 }
+ );
+ }
+
+ // Fetch video detail without validation (already validated during search)
+ try {
+ const videoDetail = await getVideoDetail(id, sourceConfig);
+
+ // Skip validation - videos are already checked during search
+ // Just return the episodes as-is
+ console.log(`[${method}] Fetching video details for ${id} from ${sourceConfig.name}`);
+
+ return NextResponse.json({
+ success: true,
+ data: videoDetail,
+ });
+ } catch (error) {
+ console.error('Detail API error:', error);
+
+ return NextResponse.json(
+ {
+ success: false,
+ error: error instanceof Error ? error.message : 'Failed to fetch video detail',
+ },
+ { status: 500 }
+ );
+ }
+}
+
export async function GET(request: NextRequest) {
try {
const searchParams = request.nextUrl.searchParams;
const id = searchParams.get('id');
const source = searchParams.get('source');
- // Validate input
- if (!id) {
- return NextResponse.json(
- { error: 'Missing video ID parameter' },
- { status: 400 }
- );
- }
-
- // Validate source
- if (!source) {
- return NextResponse.json(
- { error: 'Missing source parameter' },
- { status: 400 }
- );
- }
-
- const sourceConfig = getSourceById(source);
-
- if (!sourceConfig) {
- return NextResponse.json(
- { error: 'Invalid source ID' },
- { status: 400 }
- );
- }
-
- // Fetch video detail without validation (already validated during search)
- try {
- const videoDetail = await getVideoDetail(id, sourceConfig);
-
- // Skip validation - videos are already checked during search
- // Just return the episodes as-is
- console.log(`[GET] Fetching video details for ${id} from ${sourceConfig.name}`);
-
- return NextResponse.json({
- success: true,
- data: videoDetail,
- });
- } catch (error) {
- console.error('Detail API error:', error);
-
- return NextResponse.json(
- {
- success: false,
- error: error instanceof Error ? error.message : 'Failed to fetch video detail',
- },
- { status: 500 }
- );
- }
+ return await handleDetailRequest(id, source, 'GET');
} catch (error) {
console.error('Detail API error:', error);
@@ -80,54 +87,7 @@ export async function POST(request: NextRequest) {
const body = await request.json();
const { id, source } = body;
- // Validate input
- if (!id) {
- return NextResponse.json(
- { error: 'Missing video ID parameter' },
- { status: 400 }
- );
- }
-
- // Validate source
- if (!source) {
- return NextResponse.json(
- { error: 'Missing source parameter' },
- { status: 400 }
- );
- }
-
- const sourceConfig = getSourceById(source);
-
- if (!sourceConfig) {
- return NextResponse.json(
- { error: 'Invalid source ID' },
- { status: 400 }
- );
- }
-
- // Fetch video detail without validation (already validated during search)
- try {
- const videoDetail = await getVideoDetail(id, sourceConfig);
-
- // Skip validation - videos are already checked during search
- // Just return the episodes as-is
- console.log(`[POST] Fetching video details for ${id} from ${sourceConfig.name}`);
-
- return NextResponse.json({
- success: true,
- data: videoDetail,
- });
- } catch (error) {
- console.error('Detail API error:', error);
-
- return NextResponse.json(
- {
- success: false,
- error: error instanceof Error ? error.message : 'Failed to fetch video detail',
- },
- { status: 500 }
- );
- }
+ return await handleDetailRequest(id, source, 'POST');
} catch (error) {
console.error('Detail API error:', error);
diff --git a/public/file.svg b/public/file.svg
deleted file mode 100644
index 004145c..0000000
--- a/public/file.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/public/globe.svg b/public/globe.svg
deleted file mode 100644
index 567f17b..0000000
--- a/public/globe.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/public/next.svg b/public/next.svg
deleted file mode 100644
index 5174b28..0000000
--- a/public/next.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/public/vercel.svg b/public/vercel.svg
deleted file mode 100644
index 7705396..0000000
--- a/public/vercel.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/public/window.svg b/public/window.svg
deleted file mode 100644
index b2b2a44..0000000
--- a/public/window.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file