Socket
Socket
Sign inDemoInstall

ytpl

Package Overview
Dependencies
1
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ytpl

Simple package to resolve YouTube playlists - no strings attached.


Version published
Weekly downloads
3.5K
decreased by-62.59%
Maintainers
1
Install size
57.2 kB
Created
Weekly downloads
 

Readme

Source

node-ytpl

NPM version NPM downloads codecov Known Vulnerabilities Discord

Simple js only package to resolve YouTube Playlists. Does not require any login or Google-API-Key.

Support

You can contact us for support on our chat server

Usage

const ytpl = require('ytpl');

const playlist = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg');

API

ytpl(id, [options])

Attempts to resolve the given playlist id

  • id

    • id of the yt-playlist
    • or a playlist url
    • or a user url (resolves to uploaded playlist)
    • or a channel url (resolves to uploaded playlist)
  • options

    • object with options
    • possible settings:
    • gl[String] -> 2-Digit Code of a Country, defaults to US - Allows for localisation of the request
    • hl[String] -> 2-Digit Code for a Language, defaults to en - Allows for localisation of the request
    • limit[Number] -> limits the pulled items, defaults to 100, set to Infinity to get the whole playlist - numbers <1 result in the default being used
    • pages[Number] -> limits the pulled pages, pages contain 100 items, set to Infinity to get the whole playlist - numbers <1 result in the default limit being used - overwrites limit
    • requestOptions[Object] -> Additional parameters to passed to miniget, which is used to do the https requests
  • returns a Promise

  • Example response

ytpl.continueReq(continuationData)

Continues a previous request by pulling yet another page.
The previous request had to be done using pages limitation.

Usage
const ytpl = require('ytpl');

const firstResultBatch = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg', { pages: 1 });
const secondResultBatch = ytpl.continueReq(firstResultBatch.continuation);
const thirdResultBatch = ytpl.continueReq(secondResultBatch.continuation);

// You can now use the .items property of all result batches e.g.:
console.log(firstResultBatch.items);
console.log(secondResultBatch.items);
console.log(thirdResultBatch.items);
  • returns a Promise resolving into { continuation, items }

ytpl.validateID(string)

Returns true if able to parse out a (formally) valid playlist ID.

ytpl.getPlaylistID(string)

Returns a playlist ID from a YouTube URL. Can be called with the playlist ID directly, in which case it just resolves.

  • returns a promise resolving into a string containing the id

Install

npm install --save ytpl

License

MIT

Keywords

FAQs

Last updated on 04 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc