File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
- import YoutubeIframe from "./src/YoutubeIframe" ;
1
+ import YoutubeIframe from './src/YoutubeIframe' ;
2
+ import { getYoutubeMeta } from './src/oEmbed' ;
2
3
3
4
export default YoutubeIframe ;
5
+ export { getYoutubeMeta } ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @typedef {Object } youtubeMeta
3
+ * @property {String } author_name
4
+ * @property {String } author_url
5
+ * @property {Number } height
6
+ * @property {String } html
7
+ * @property {String } provider_name
8
+ * @property {String } provider_url
9
+ * @property {Number } thumbnail_height
10
+ * @property {String } thumbnail_url
11
+ * @property {Number } thumbnail_width
12
+ * @property {String } title
13
+ * @property {String } type
14
+ * @property {String } version
15
+ * @property {Number } width
16
+ */
17
+
18
+ /**
19
+ * Fetch metadata of a youtube video using the oEmbed Spec -
20
+ * https://oembed.com/#section7
21
+ *
22
+ * @param {String } videoId - youtube video id
23
+ * @returns {Promise<youtubeMeta> } A promise that resolves into an object with the video metadata
24
+ */
25
+ export const getYoutubeMeta = async videoId => {
26
+ const response = await fetch (
27
+ `https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${ videoId } &format=json` ,
28
+ ) ;
29
+ return await response . json ( ) ;
30
+ } ;
You can’t perform that action at this time.
0 commit comments