New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@neeraj-x0/ytsearch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neeraj-x0/ytsearch

Simple package to search YouTube - no strings attached.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-ytsearch

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 ytsearch = require('@neeraj-x0/ytsearch');

const searchResults = await ytsearch('github');

API

ytsearch(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

ytsearch.getFilters(searchString, options)

Pulls avaible filters for the given string or link

Usage
const ytsearch = require('@neeraj-x0/ytsearch');

const filters1 = await ytsearch.getFilters('github');
const filter1 = filters1.get('Type').get('Video');
const filters2 = await ytsearch.getFilters(filter1.url);
const filter2 = filters2.get('Features').get('Live');
const options = {
  pages: 2,
}
const searchResults = await ytsearch(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>>

ytsearch.continueReq(continuationData)

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

Usage
const ytsearch = require('@neeraj-x0/ytsearch');

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

Install

npm install --save @neeraj-x0/ytsearch

License

MIT

Keywords

FAQs

Package last updated on 15 Jun 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc