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

easy-youtube-searcher

v1.0.1

Published

A package to find and get informations about YouTube videos.

Downloads

9

Readme

NPM

Note: This package is a copy of https://github.com/RemyK888/quick-yt-search

The QuickYtSearch is a simple way to find videos, playlists and channels on YouTube and get informations about them.

Basic Stuff

const QuickYtSearch = require('easy-youtube-searcher'); // Require the package
const YoutubeSearcher = new QuickYtSearch({
    YtApiKey: 'Your key here', // Place your YouTube API key here
});

Note: The YouTube API key is required.

Find YouTube video

YoutubeSearcher.getVideo('some video').then(video => {
    // Do what you want
});

Find YouTube playlist

YoutubeSearcher.getPlaylist('some playlist').then(playlist => {
    // Do what you want
});

Find YouTube channel

YoutubeSearcher.getChannel('some channel').then(channel => {
    // Do what you want
});

Check video URL

if(YoutubeSearcher.isVideoUrl('some video url') === true) {
    console.log('OMG, it\'s a video');
} else {
    console.log('NOPE');
};

Check playlist URL

if(YoutubeSearcher.isPlaylistUrl('some playlist url') === true) {
    console.log('OMG, it\'s a playlist');
} else {
    console.log('NOPE');
};

Check channel URL

if(YoutubeSearcher.isChannelUrl('some channel url') === true) {
    console.log('OMG, it\'s a channel');
} else {
    console.log('NOPE');
};

Video properties

    Video.channelId,
    Video.channelTitle,
    Video.defaultThumbnail,
    Video.description,
    Video.highThumbnail,
    Video.id,
    Video.liveBroadcastContent,
    Video.mediumThumbnail,
    Video.publishedAt,
    Video.publishedTime,
    Video.title,
    Video.url

Playlist properties

    Playlist.channelId,
    Playlist.channelTitle,
    Playlist.defaultThumbnail,
    Playlist.description,
    Playlist.highThumbnail,
    Playlist.id,
    Playlist.liveBroadcastContent,
    Playlist.mediumThumbnail,
    Playlist.publishedAt,
    Playlist.publishedTime,
    Playlist.title,
    Playlist.url

Channel properties

    Channel.createdAt,
    Channel.createdTime,
    Channel.defaultThumbnail,
    Channel.description,
    Channel.highThumbnail,
    Channel.id,
    Channel.liveBroadcastContent,
    Channel.mediumThumbnail, 
    Channel.title,
    Channel.url

Code example (with Discord bot, using discord.js and ytdl-core)

const QuickYtSearch = require('easy-youtube-searcher'); // Require the package
const Discord = require('discord.js'); // Require Discord.Js
const ytdl = require('ytdl-core'); // Require ytdl-core
const client = new Discord.Client({ disableMentions: 'everyone' }); // Create new Discord client
const YoutubeSearcher = new QuickYtSearch({ // Init the YouTubeSearch system
    YtApiKey: 'Some YouTube Api key', // Place your YouTube API key here
});
const config = {
    token: 'Some Discord bot token', // Place your Discord bot token here
    prefix: '!' // Place your bot prefix here
};

client.on('message', async message => { // When client receive message
    if (message.content.startsWith(config.prefix + 'play')) { // If message starts with '!(prefix)play'
        if (message.member.voice.channel) { // Check if message author is in a voice channel
            let args = message.content.split(' ').slice(1).join(' '); // Define the args
            if (!args) { // If no args in the message
                message.reply('No args inserted.'); // Reply with mention the message author
            };
            message.member.voice.channel.join() // Join the message author voice channel
                .then(connection => {
                    if (YoutubeSearcher.isVideoUrl(args) === false) { // If it's not a YouTube video url
                        YoutubeSearcher.getVideo(args).then(video => { // Search video
                            const volume = { volume: 0.5 }; // Set the volume
                            const dispatcher = connection.play(ytdl(video.url, { filter: 'audioonly' }, volume)); // Play the track using ytdl-core
                            message.reply('Now playing ' + video.url); // Send a message with song informations
                            dispatcher.on("end", () => { // When the stream is finish
                                message.reply('End of the song.');
                                message.member.voice.channel.leave(); // Leave user voice channel
                                dispatcher.end(); // Stop dispatcher
                            });
                        });
                    } else {
                        const volume = { volume: 0.5 }; // Set the volume
                        const dispatcher = connection.play(ytdl(args, { filter: 'audioonly' }, volume)); // Play the track using ytdl-core
                        message.reply('Now playing ' + args); // Send a message with song informations
                        dispatcher.on("end", () => { // When the stream is finish
                            message.reply('End of the song.')
                            message.member.voice.channel.leave(); // Leave user voice channel
                            dispatcher.end();// Stop dispatcher
                        });
                    };
                });
        } else {
            message.reply('You need to join a voice channel.');
        };
    };
});

client.login(config.token); // Login with Discord bot token

Note: This package is not affiliated with YouTube Inc.