mirror of
https://github.com/FranP-code/classify_saved_videos_yt.git
synced 2025-10-13 00:32:25 +00:00
YouTube Video Classifier Platform
This commit is contained in:
committed by
GitHub
parent
5c59b2a301
commit
ed8ad48310
51
web/src/pages/api/videos.ts
Normal file
51
web/src/pages/api/videos.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
import { readFileSync, existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { parseCSV } from '../../utils/csvParser';
|
||||
|
||||
export const GET: APIRoute = async () => {
|
||||
try {
|
||||
// Look for CSV file in the project root (outside web folder)
|
||||
const csvPath = join(process.cwd(), '..', 'video_classifications.csv');
|
||||
|
||||
if (!existsSync(csvPath)) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: 'CSV file not found',
|
||||
message: 'video_classifications.csv not found in project root',
|
||||
path: csvPath
|
||||
}),
|
||||
{
|
||||
status: 404,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const csvContent = readFileSync(csvPath, 'utf-8');
|
||||
const videos = parseCSV(csvContent);
|
||||
|
||||
return new Response(JSON.stringify({ videos }), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error reading CSV file:', error);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: 'Failed to read CSV file',
|
||||
message: error instanceof Error ? error.message : 'Unknown error'
|
||||
}),
|
||||
{
|
||||
status: 500,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,27 +1,30 @@
|
||||
---
|
||||
import '../styles/global.css';
|
||||
// Component Imports
|
||||
import Button from '../components/Button.astro';
|
||||
import {Button as ShadcnButton} from '../components/ui/button.tsx';
|
||||
|
||||
// Full Astro Component Syntax:
|
||||
// https://docs.astro.build/basics/astro-components/
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>Astro + TailwindCSS</title>
|
||||
<title>YouTube Video Classifier</title>
|
||||
<meta name="description" content="AI-powered YouTube video classification and management platform" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="grid place-items-center h-screen content-center">
|
||||
<Button>Tailwind Button in Astro!</Button>
|
||||
<a href="/markdown-page" class="p-4 underline">Markdown is also supported...</a>
|
||||
<ShadcnButton>Shadcn Button</ShadcnButton>
|
||||
</div>
|
||||
<body class="min-h-screen bg-background">
|
||||
<div id="app"></div>
|
||||
|
||||
<script>
|
||||
import VideoClassifierApp from '../components/VideoClassifierApp.tsx';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import React from 'react';
|
||||
|
||||
const container = document.getElementById('app');
|
||||
if (container) {
|
||||
const root = createRoot(container);
|
||||
root.render(React.createElement(VideoClassifierApp));
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user