Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e65aca2
commit 64513ab
Showing
2 changed files
with
49 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const CHANNEL_ID = 'UC7LE4pbfb4e2voEASj3RscA'; | ||
|
||
interface Thumbnail { | ||
url: string; | ||
width: number; | ||
height: number; | ||
} | ||
|
||
export interface Video { | ||
id: string; | ||
title: string; | ||
description: string; | ||
thumbnails: { | ||
default: Thumbnail; | ||
medium: Thumbnail; | ||
high: Thumbnail; | ||
}; | ||
} | ||
|
||
export async function getVideos(): Promise<Array<Video>> { | ||
const res = await fetch( | ||
`https://www.googleapis.com/youtube/v3/search?key=${process.env.YOUTUBE_API_KEY}&channelId=${CHANNEL_ID}&part=snippet,id&order=date&maxResults=5` | ||
); | ||
const { items } = await res.json(); | ||
const videos: Array<Video> = items.map(({ id, snippet }: any) => { | ||
return { | ||
id: id.videoId, | ||
title: snippet.title, | ||
description: snippet.description, | ||
thumbnails: snippet.thumbnails, | ||
} as Video; | ||
}); | ||
return videos; | ||
} | ||
// import Youtube from 'youtube.ts'; | ||
|
||
// const CHANNEL_URL = 'https://www.youtube.com/c/MaxProgramming'; | ||
|
||
// export default async function fetchVideos() { | ||
// const yt = new Youtube(process.env.YOUTUBE_API_KEY!); | ||
// const channel = await yt.channels.get(CHANNEL_URL); | ||
// const videos = await yt.api.get() | ||
|
||
// return channel; | ||
// } |
64513ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
usman-sme – ./
usman-portfolio.vercel.app
usman-sme-max-programming.vercel.app
usman-sme-git-main-max-programming.vercel.app
www.usman-s.me
usman-s.me