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

@ibaraki-douji/youtube

v1.3.4

Published

A little YouTube API + Downloader

Downloads

9

Readme

YouTube

Simple YouTube scrapper for everyone

Getting started

npm i @ibaraki-douji/youtube --save

Usage

Import the lib

const YouTube = require('@ibaraki-douji/youtube').YouTube

Search

const YouTube = require('@ibaraki-douji/youtube').YouTube

YouTube.search("rick roll", "video").then(console.log)
YouTube.search("John Doe", "channel").then(console.log)
YouTube.search("rick roll", "playlist").then(console.log)

First parameter is the query
Second parameter is the type of search (Optionnal : default = video).

Get All Video information

const YouTube = require('@ibaraki-douji/youtube').YouTube

YouTube.getVideoInformations({
    url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}).then(console.log);

You can have all information about the video + streaming infos

Get All Channel information

const YouTube = require('@ibaraki-douji/youtube').YouTube

YouTube.getChannelInformations({
    url: "https://www.youtube.com/channel/UCYLNVyL_PjgLvTgJ2h-ixtw"
}).then(console.log)

There is a lot of information here like the 30 last videos, last created playlists, the RSS url for new videos and more...

Get All Playlist information

const YouTube = require('@ibaraki-douji/youtube').YouTube

YouTube.getPlaylistInformations({
    url: "https://www.youtube.com/playlist&list=PLjiPh7vdm10JBUJ4mZcQu2PCGJeYy4X09"
}).then(console.log)

You have name, last update, videoCount, 100 first videos

Downaloader

Import the lib

const Downloader = require("@ibaraki-douji/youtube").Downloader;

Download video

const Downloader = require("@ibaraki-douji/youtube").Downloader;
const YouTube = require('@ibaraki-douji/youtube').YouTube

(async () => {
    const video = await YouTube.getVideoInformations({
        url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    });
    Downloader.downloadVideo(video, "1080", "./my/path.mp4", (stdout) => {
        console.log(stdout)
    })
})()

1080 is the quality of the video. It can be "2160" | "1440" | "1080" | "720" | "480" | "360" | "240" | "144".
./my/path.mp4 is the location of the file.
The las one is a function to the current text of the conversion (to remove it just put (s)=>{})

Download Audio

const Downloader = require("@ibaraki-douji/youtube").Downloader;
const YouTube = require('@ibaraki-douji/youtube').YouTube

(async () => {
    const video = await YouTube.getVideoInformations({
        url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    });
    Downloader.downloadAudio(video, "./my/path.mp4", (stdout) => {
        console.log(stdout)
    })
})()

./my/path.mp4 is the location of the file.
The las one is a function to the current text of the conversion (to remove it just put (s)=>{})

Download Playlist Videos

const Downloader = require("@ibaraki-douji/youtube").Downloader;
const YouTube = require('@ibaraki-douji/youtube').YouTube

(async () => {
    const playlist = await YouTube.getPlaylistInformations({
        url: "https://www.youtube.com/playlist&list=PLjiPh7vdm10JBUJ4mZcQu2PCGJeYy4X09"
    });
    Downloader.downloadPlaylistVideo(playlist, "1080", "./my/path", (stdout) => {
        console.log(stdout)
    })
})()

1080 is the quality of the video. It can be "2160" | "1440" | "1080" | "720" | "480" | "360" | "240" | "144".
./my/path is the location of the folder, All the videos goes inside with the title.
The las one is a function to the current text of the conversion (to remove it just put (s)=>{})

Download Playlist Audios

const Downloader = require("@ibaraki-douji/youtube").Downloader;
const YouTube = require('@ibaraki-douji/youtube').YouTube

(async () => {
    const playlist = await YouTube.getPlaylistInformations({
        url: "https://www.youtube.com/playlist&list=PLjiPh7vdm10JBUJ4mZcQu2PCGJeYy4X09"
    });
    Downloader.downloadPlaylistAudio(playlist, "./my/path", (stdout) => {
        console.log(stdout)
    })
})()

./my/path is the location of the folder, All the videos goes inside with the title.
The las one is a function to the current text of the conversion (to remove it just put (s)=>{})

Function alternative

I aslo implement a function fully Typed to have a simple view

    //VIDEO
    Downloader.download(video, quality, path, stdout);
    //AUDIO
    Downloader.download(video, path, stdout);
    //VIDEO PLAYLIST
    Downloader.download(playlist, quality, path, stdout);
    //AUDIO PLAYLIST
    Downloader.download(playlist, path, stdout);

Exemple

const YouTube = require('@ibaraki-douji/youtube').YouTube

// MAKE A ASYNC FUNCTION AT START
(async () => {
    const search = await YouTube.search("rick roll");
    const RR = await YouTube.getVideoInformations(search.res[0]);
    const stream = RR.streams[0]
    console.log("Good quality video : " + stream.url);
})()

More Help and Support

Discord : https://discord.gg/mD9c4zP4Er

Ask me what you want in the Discord server