react-native-ytpl

1.0.3 • Public • Published

react-native-ytpl

NPM version NPM downloads Discord

this is a fork & port to react native of TimeForANinja/node-ytpl

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

var ytpl = require('react-native-ytpl');

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

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

var ytpl = require('react-native-ytpl');

const playlist = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg', { pages: 1 });
console.log(playlist.items);
const r2 = ytpl.continueReq(playlist.continuation);
console.log(r2.items);
const r3 = ytpl.continueReq(r2.continuation);
console.log(r3.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

Related / Works well with

Install

npm install --save react-native-ytpl

License

MIT

Package Sidebar

Install

npm i react-native-ytpl

Weekly Downloads

6

Version

1.0.3

License

ISC

Unpacked Size

26.3 kB

Total Files

7

Last publish

Collaborators

  • shaharbrandman