1
0
Fork 0

Create basic watch page for YouTube videos

This commit is contained in:
Korbs 2024-06-22 16:52:08 -04:00
parent 24cdb90ecf
commit 3128919705
No known key found for this signature in database

28
src/pages/watch.astro Normal file
View file

@ -0,0 +1,28 @@
---
// Layout
import Base from "@layouts/Default.astro";
// Environment Variables
const DEFAULT_INVIDIOUS_INSTANCE = import.meta.env.DEFAULT_INVIDIOUS_INSTANCE
// Components
// Fetch
const SWV = Astro.url.href.split("watch?v=").pop();
const video = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/videos/" + SWV).then((response) => response.json());
const comments = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/comments/" + SWV).then((response) => response.json());
---
<Base Title={video.title}>
<div class="video-container">
<video
autoplay
controls
poster={'https://i.ytimg.com/vi/' + video.videoId + '/maxresdefault.jpg'}
video-title={video.title}
style="width: 100%;"
src={'https://' + DEFAULT_INVIDIOUS_INSTANCE + '/latest_version?id=' + video.videoId}
>
</video>
</div>
</Base>