-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* begin work on validating videos utilizing yt api. * check in youtube form validation.
- Loading branch information
Showing
4 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = { | ||
images: { | ||
remotePatterns: [{ protocol: "https", hostname: "i.ytimg.com" }], | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,93 @@ | ||
"use server"; | ||
|
||
import { PrismaClient } from "@prisma/client"; | ||
import config from "@/lib/config"; | ||
|
||
export const submitUpdates = async (props: any) => { | ||
console.log(props); | ||
}; | ||
|
||
export const getYTVid = async (videoId: string) => { | ||
const prisma = new PrismaClient(); | ||
const sessions = await prisma.session.findMany(); | ||
const sessionURL = sessions.find( | ||
(session) => session.sessionUrl.split("=")[1] === videoId, | ||
); | ||
console.log(sessionURL); | ||
if (!sessionURL) { | ||
const YTvideo = await fetch( | ||
`https://youtube.googleapis.com/youtube/v3/videos?part=snippet&part=player&id=${videoId}&key=${config.YOUTUBE_LOCAL_API_KEY}`, | ||
); | ||
console.log( | ||
`https://youtube.googleapis.com/youtube/v3/videos?part=snippet&part=player&id=${videoId}&key=${config.YOUTUBE_LOCAL_API_KEY}`, | ||
); | ||
console.log(YTvideo, videoId); | ||
!config.YOUTUBE_LOCAL_API_KEY && | ||
console.log("YOUTUBE API KEY NOT CONFIGURED"); | ||
|
||
if (!YTvideo.ok) return undefined; | ||
|
||
const json = (await YTvideo.json()) as YouTubeVideoListResponse; | ||
console.log(json); | ||
const video = json.items[0]; | ||
|
||
if (video.snippet.channelTitle !== "RDC Live") return undefined; | ||
|
||
const session = { | ||
sessionUrl: `https://youtube.com/watch?v=${video.id}`, | ||
date: video.snippet.publishedAt, | ||
sessionName: video.snippet.title, | ||
thumbnail: | ||
video.snippet.thumbnails.maxres || video.snippet.thumbnails.high, | ||
}; | ||
return session; | ||
} | ||
await prisma.$disconnect(); | ||
|
||
return undefined; | ||
}; | ||
|
||
type YouTubeVideoListResponse = { | ||
kind: "youtube#videoListResponse"; | ||
etag: string; | ||
items: { | ||
kind: "youtube#video"; | ||
etag: string; | ||
id: string; | ||
snippet: { | ||
publishedAt: string; | ||
channelId: string; | ||
title: string; | ||
description: string; | ||
thumbnails: { | ||
default: Thumbnail; | ||
medium: Thumbnail; | ||
high: Thumbnail; | ||
standard?: Thumbnail; | ||
maxres?: Thumbnail; | ||
}; | ||
channelTitle: string; | ||
tags?: string[]; | ||
categoryId: string; | ||
liveBroadcastContent: string; | ||
localized: { | ||
title: string; | ||
description: string; | ||
}; | ||
defaultAudioLanguage?: string; | ||
}; | ||
player: { | ||
embedHtml: string; | ||
}; | ||
}[]; | ||
pageInfo: { | ||
totalResults: number; | ||
resultsPerPage: number; | ||
}; | ||
}; | ||
|
||
type Thumbnail = { | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters