This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

yt-scraper

2.2.0 • Public • Published

yt-scraper

Modern YouTube scraper capable of retrieving video and channel info.

Install

First install through NPM:

npm install yt-scraper

Then import into your project:

const ytScraper = require("yt-scraper")

Usage

All returned keys should be treated as optional and may suddenly stop working due to YouTube changes.

Video Info

ytScraper.videoInfo(videoUrl, options = {})

Argument Type Description
videoUrl String (www.)youtube.com and youtu.be links are accepted alongside simply providing the video ID without a url.
options.includeRawData Bool raw key will contain JSON data provided by YouTube. Is false by default.
options.bypassIdCheck Bool Make the video request without verifying the ID, only works with a url provided. Is false by default.

Returns a Promise with the object described in the table below. Throws (see Errors below).

Key Type Description
id String ID of the video.
url String URL of the video (https://www.youtube.com/watch?v=ID).
title String Title of the video.
views Number Video views.
description String Description of the video, will contain \n.
category String Category of the video.
length Number Length of the video in seconds.
thumbnails Array<Thumbnail> Array of thumbnails, most likely contains at least one. Documentation can be found below.
live Bool Is video a live stream
privacy.private Bool Is video private.
privacy.unlisted Bool Is video unlisted.
privacy.familySafe Bool Is video family safe (deemed by YouTube).
privacy.availableCountries Array<String> Array of two letter capitalized country coded where video can be viewed (e.g. US). Note it can contain 150+ items.
dates.published Date Video published video. May vary from upload date.
dates.uploaded Date Video uploaded date. May vary from publish date.
streams.formats Array Array of video files that contain audio, may be lower quality than using adaptive formats.
streams.adaptiveFormats Array Array of video or audio files but the video files don't contain audio. Higher quality than traditional formats but video and audio must be assembled before playback.
raw Object If options.includeRawData is set to true then contains the raw object given by YouTube that is then parsed to get metadata.

Thumbnail

Thumbnails are provided by the YouTube API. Each thumbnail may represent the same image at a different size.

Key Type Description
url String URL of the thumbnail, most likely a jpg.
width Number Width of thumbnail.
height Number Height of thumbnail.

Errors

Error Name Description
YTScraperInvalidVideoURL An invalid video url was provided.
YTScraperInvalidVideoID An invalid video id was provided. Can be bypassed for videoInfo method, check documentation.
YTScraperInvalidChannelID An invalid channel id was provided.
YTScraperInvalidChannelURL An invalid channel url was provided.
YTScraperMissingData The webpage provided missing data and the scrape could not be completed.

Contributing

We heavily value contributions, if you would like to contribute please feel free to put in a pull request.

Contributors

  • Thanks to elBarkey for bug fixes and stability contributions in v1.

Package Sidebar

Install

npm i yt-scraper

Weekly Downloads

1

Version

2.2.0

License

MIT

Unpacked Size

11.7 kB

Total Files

9

Last publish

Collaborators

  • npm-support