npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scrape-youtube

v2.4.0

Published

A lightning fast package to scrape YouTube search results. This was made for Discord Bots.

Downloads

1,490

Readme

scrape-youtube

Version Downloads Documentation Maintenance License: MIT

A lightning fast package to scrape YouTube search results. This was made for Discord Bots.

Install

npm install scrape-youtube --save

Example

import { youtube } from 'scrape-youtube';
// const { youtube } = require('scrape-youtube');

youtube.search('Short Change Hero').then((results) => {
    // Unless you specify a custom type you will only receive 'video' results
    console.log(results.videos);
});
// or
const { videos } = await youtube.search('Short Change Hero');

Custom Types

Supported types are: video, live, movie, channel, playlist and any

youtube.search('lofi hip hop beats to relax/study to', { type: 'live' }).then((results) => {
    console.log(results.streams);
});

Examples

Please see the examples directory for examples on what data you will receive from each search.
Your IDE should have autocompletion that works with the interface files, but these are here just in case.

If you want help using this in Discord Bot, please visit the wiki page for TS/JS examples.

Playlists

Please note that the "videos" listed in playlist responses will only contain 1-2 items. This is what is available from the search results.
If you wish to load an entire playlist, consider using ytdl-core.

Custom Filters

You can pass { sp: 'ABC' } as the second parameter to use custom filters like upload date, duration, features ect.
You will need to fetch the SP parameter yourself from youtube. Please see this image for an example.

Request Options

You can pass { request: { } } as the second parameter to use a proxy, custom headers, agents ect.
See http.request for more information.

const options = {
    type: 'video',
    request: {
        headers: {
            Cookie: 'PREF=f2=8000000',
            'Accept-Language': 'de'
        }
    }
};

youtube.search('Poets of the fall', options);

For example, using Cookie: 'PREF=f2=8000000' will enable restricted mode to filter out videos with bad language or adult themes.
Additionally, 'Accept-Language': 'de' will load YouTube in German, sometimes resulting in different titles and content responses.

Extra Info

You can use ytdl-core by fent to load extra information like exact upload dates, full descriptions, like/dislike ratio, video ads ect.
Please see this example in the wiki to see how.

Subscriber count

As mentioned in issue #57 some channels appear to have the subscriber count hidden. In this case the package will default to 0.

Handles

Channel handles will be used if available. Some channels do not have handles, if this is the case the channel link will use the old ID, EG: /channel/12345 vs /@user I recommend sticking to the ID as handles are unreliable.

Quick Info

  • Multiple pages currently can not be loaded. This may change in the future, but currently you will be limited to 20 results.
  • This package will only make 1 request per search, even when using any types.
  • If this package stops working, please open an issue on GitHub. I will fix it within a day.

👤 Author

This project was made by Kain (ksir.pw) Feel free to contact me if you have any trouble with this package.

🤝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2018 Kain (ksir.pw). This project is MIT licensed.