Skip to content

Commit

Permalink
Merge pull request #1161 from SujithThirumalaisamy/new
Browse files Browse the repository at this point in the history
Added vizolv service endpoint
  • Loading branch information
siinghd authored Sep 15, 2024
2 parents bd1f029 + b8a5ce6 commit 164842f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/api/admin/content/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const POST = async (req: NextRequest) => {
video_360p_mp4_3: metadata.video_360p_mp4_3,
video_360p_mp4_4: metadata.video_360p_mp4_4,

subtitles: metadata.subtitles || '',
subtitles: metadata.subtitles,
segments: metadata.segments || [],
duration: metadata.duration,
thumbnail_mosiac_url: metadata.thumbnail_mosiac_url,
Expand Down
1 change: 0 additions & 1 deletion src/app/api/admin/services/subtitle/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export async function GET(req: NextRequest) {
});
return NextResponse.json(video);
} catch (error) {
console.log(error);
return NextResponse.json(
{ message: 'Error fetching video' },
{ status: 500 },
Expand Down
54 changes: 54 additions & 0 deletions src/app/api/admin/services/vizolv/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import db from '@/db';
import { NextRequest, NextResponse } from 'next/server';

export async function GET(req: NextRequest) {
const authKey = req.headers.get('Authorization');
const videoId = req.nextUrl.searchParams.get('videoId');

if (authKey !== process.env.VIZOLV_SECRET)
return NextResponse.json({ message: 'Unauthorized' }, { status: 403 });

if (!videoId)
return NextResponse.json(
{ message: 'No videoId provided' },
{ status: 400 },
);

try {
const videoMetadata = await db.videoMetadata.findFirst({
where: {
id: parseInt(videoId, 10),
},
select: {
content: {
select: {
title: true,
description: true,
parentId: true,
courses: {
select: {
courseId: true,
},
},
},
},
duration: true,
contentId: true,
subtitles: true,
},
});

if (!videoMetadata)
return NextResponse.json(
{ message: 'Unable to fetch video metadata' },
{ status: 404 },
);

return NextResponse.json(videoMetadata);
} catch (error) {
return NextResponse.json(
{ message: 'Error fetching video metadata' },
{ status: 500 },
);
}
}

0 comments on commit 164842f

Please sign in to comment.