1.0.6 • Published 3 years ago

ytube-nm v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

ytube-nm

A Javascript tool for getting the youtube thumbnail urls.

How to Use

The Resolution Type Definition:

export type RESOLUTION_TYPE = "default" | "hqdefault" | "mqdefault" | "sddefault" | "maxresdefault"

Example 1 : Getting a single url

import { getYoutubeThumbnailURL, RESOLUTION_TYPE } 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: Getting a single url

import { getYoutubeThumbnailURL, RESOLUTION_TYPE } 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: Getting all thumbnail urls of a youtube url

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 the thumbnail is available

Because some youtube videos don't have all the tumbnail types

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

import { getAvailableThumbnails } from 'ytube-nm'

const youtubeUrl = "https://www.youtube.com/watch?v=6XBpQvFEfTk" 
const isAvailable = getAvailableThumbnails(url) //return an array of thumbnail url(s)
1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago