1.0.7 • Published 3 years ago

react-native-ytsr v1.0.7

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

react-native-ytsr

NPM version NPM downloads Known Vulnerabilities Discord

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

Simple react native package to search for Youtube for Videos, Playlists and many more. Does not require any login or Google-API-Key.

Support

You can contact us for support on our chat server

Usage

import ytsr from 'react-native-ytsr'

const search = await ytsr('TimeForNinjaIsAwesome')
console.log(search)

API

ytsr(searchString, options)

Searches for the given string

  • searchString
    • search string or url (from getFilters) to search from
  • options

    • object with options
    • possible settings:
    • glString -> 2-Digit Code of a Country, defaults to US - Allows for localisation of the request
    • hlString -> 2-Digit Code for a Language, defaults to en - Allows for localisation of the request
    • safeSearchBoolean -> pull items in youtube restriction mode.
    • limitinteger -> limits the pulled items, defaults to 100, set to Infinity to get the whole list of search results - numbers <1 result in the default being used
    • pagesNumber -> limits the pulled pages, pages contain 20-30 items, set to Infinity to get the whole list of search results - numbers <1 result in the default limit being used - overwrites limit
    • requestOptionsObject -> Additional parameters to passed to miniget, which is used to do the https requests
  • returns a Promise

  • Example response

ytsr.getFilters(searchString, options)

Pulls avaible filters for the given string or link

Usage

import ytsr from 'react-native-ytsr'

const filters1 = await ytsr.getFilters('github');
const filter1 = filters1.get('Type').get('Video');
const filters2 = await ytsr.getFilters(filter1.url);
const filter2 = filters2.get('Features').get('Live');
const options = {
  pages: 2,
}
const searchResults = await ytsr(filter2.url, options);

console.log(searchResults)
  • searchString
    • string to search for
    • or previously optained filter ref
  • options
    • glString -> 2-Digit Code of a Country, defaults to US - Allows for localisation of the request
    • hlString -> 2-Digit Code for a Language, defaults to en - Allows for localisation of the request
    • requestOptionsObject -> Additional parameters to passed to miniget, which is used to do the https requests
  • returns a Promise resulting in a Map<String, Map<String, Filter>>
  • Example response

ytsr.continueReq(continuationData)

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

Usage

import ytsr from 'react-native-ytsr'

const search = await ytsr('github', { pages: 1 });
console.log(search)

const r2 = ytsr.continueReq(search.continuation);
console.log(r2.items)

const r3 = ytsr.continueReq(r2.continuation);
console.log(r3.items)
  • returns a Promise resolving into { continuation, items }

Related / Works well with

Install

npm install --save react-native-ytsr
  

License

MIT