Download pool/shard007/JavaScript/0044135_getVideoInfo.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard007/JavaScript/0044135_getVideoInfo.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard007/JavaScript/0044135_getVideoInfo.js
-
curl -L -o 0044135_getVideoInfo.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard007/JavaScript/0044135_getVideoInfo.js
945 Bytes
| import youtubeUrl from 'youtube-url'; | |
| import camelCaseRecursive from 'camelcase-keys-recursive'; | |
| import getYoutubeInfo from './getYoutubeInfo'; | |
| import getVimeoInfo from './getVimeoInfo'; | |
| import getVimeoId from './getVimeoId'; | |
| export default (videoUrl, cb) => { | |
| if (youtubeUrl.valid(videoUrl)) { | |
| getYoutubeInfo(videoUrl, (err, data) => { | |
| if (err) { | |
| cb(err); | |
| return; | |
| } | |
| const videoData = camelCaseRecursive(data); | |
| cb(null, videoData); | |
| }); | |
| } else if (videoUrl.indexOf('vimeo.com') >= 0) { | |
| const videoId = getVimeoId(videoUrl); | |
| if (videoId) { | |
| getVimeoInfo(videoId, (err, data) => { | |
| if (err) { | |
| cb(err); | |
| return; | |
| } | |
| const videoData = { | |
| thumbnailUrl: data.thumbnail_medium, | |
| url: data.url, | |
| title: data.title, | |
| authorName: data.user_name, | |
| }; | |
| cb(null, videoData); | |
| }); | |
| } | |
| } | |
| }; | |