Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supendi/ytube-nm
Youtube library for getting the id from URL and get youtube thumbnail urls by the video id from URL
https://github.com/supendi/ytube-nm
Last synced: 28 days ago
JSON representation
Youtube library for getting the id from URL and get youtube thumbnail urls by the video id from URL
- Host: GitHub
- URL: https://github.com/supendi/ytube-nm
- Owner: supendi
- Created: 2021-04-22T01:19:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T23:28:29.000Z (over 3 years ago)
- Last Synced: 2024-04-26T14:45:16.928Z (7 months ago)
- Language: TypeScript
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ytube-nm
A Javascript tool for getting the youtube thumbnail urls.## How to Use
**The Resolution Type Definition:**
```javascript
export type RESOLUTION_TYPE = "default" | "hqdefault" | "mqdefault" | "sddefault" | "maxresdefault"
```**Example 1 : Get a single url**
```javascript
import { getYoutubeThumbnailURL } from 'ytube-nm'const youtubeUrl = "https://www.youtube.com/watch?v=6XBpQvFEfTk"
//the "default" argument is the resolution type
const thumbnail = getYoutubeThumbnailURL(youtubeUrl, "default") //https://img.youtube.com/vi/6XBpQvFEfTk/default.jpg
```**Example 2: Get a single url**
```javascript
import { getYoutubeThumbnailURL } from 'ytube-nm'const youtubeUrl = "https://www.youtube.com/watch?v=6XBpQvFEfTk"
//the "hqdefault" argument is the resolution type
const thumbnail = getYoutubeThumbnailURL(youtubeUrl, "hqdefault") //https://img.youtube.com/vi/6XBpQvFEfTk/hqdefault.jpg
```**Example 3: Get all thumbnail urls of a youtube url**
```javascript
import { getAllYoutubeThumbnailURLs } from 'ytube-nm'const youtubeUrl = "https://www.youtube.com/watch?v=6XBpQvFEfTk"
const thumbnails = getAllYoutubeThumbnailURLs(youtubeUrl)
//thumbnails result
//[
// 'https://img.youtube.com/vi/6XBpQvFEfTk/default.jpg',
// 'https://img.youtube.com/vi/6XBpQvFEfTk/hqdefault.jpg',
// 'https://img.youtube.com/vi/6XBpQvFEfTk/mqdefault.jpg',
// 'https://img.youtube.com/vi/6XBpQvFEfTk/sddefault.jpg',
// 'https://img.youtube.com/vi/6XBpQvFEfTk/maxresdefault.jpg'
//]
```**Example 4: Check if a thumbnail url is available**
Because some youtube videos don't have all the tumbnail types
```javascript
import { thumbnailIsAvailable } from 'ytube-nm'const youtubeUrl = "https://img.youtube.com/vi/6XBpQvFEfTk/default.jpg"
const isAvailable = thumbnailIsAvailable(url) //return a promise of boolean
```**Example 5: Or get only the available ones**
```javascript
import { getAvailableThumbnails } from 'ytube-nm'const youtubeUrl = "https://www.youtube.com/watch?v=6XBpQvFEfTk"
const thumbnails = getAvailableThumbnails(url) //return an array of thumbnail url(s)
```