GithubHelp home page GithubHelp logo

reply2zain / node-ytsr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timeforaninja/node-ytsr

0.0 0.0 0.0 1.18 MB

Do anonymous YouTube search requests.

License: MIT License

JavaScript 3.48% HTML 96.52%

node-ytsr's Introduction

node-ytsr

NPM version NPM downloads codecov Known Vulnerabilities Discord

Simple js only 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

const ytsr = require('ytsr');

const searchResults = await ytsr('github');

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:
    • 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
    • safeSearch[Boolean] -> pull items in youtube restriction mode.
    • limit[integer] -> 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
    • pages[Number] -> 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
    • requestOptions[Object] -> 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

const ytsr = require('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);
  • searchString
    • string to search for
    • or previously optained filter ref
  • options
    • 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
    • requestOptions[Object] -> 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

const ytsr = require('ytsr');

const firstResultBatch = await ytsr('github', { pages: 1 });
const secondResultBatch = ytsr.continueReq(firstResultBatch.continuation);
const thirdResultBatch = ytsr.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 }

Related / Works well with

Install

npm install --save ytsr

License

MIT

node-ytsr's People

Contributors

androz2091 avatar catsmiaow avatar cbrown350 avatar cjh980402 avatar dependabot[bot] avatar greenkeeper[bot] avatar guilhermeasper avatar jontze avatar khoohaoyit avatar mattez02 avatar moisout avatar ovyerus avatar pyroignus avatar ragzouken avatar skick1234 avatar snyk-bot avatar timeforaninja avatar venkataramanab avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.