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

discord-youtube-api

v0.1.0

Published

An uncomplete YouTube API wrapper specifically made for ease of use when creating discord music bots

Downloads

383

Readme

About

This is an uncomplete YouTube API wrapper made specifically for ease of use when creating a discord music bot. Why is it more convenient? This module always returns a useful Video where all properties are guaranteed, so there is no real need to make more than one request manually to retrieve something like the duration of the video, also things that aren't really useful for a discord music bot have also been left out such as channel-related information and playlist information, playlists are still available but rather than returning a playlist object, the playlist retrieval methods will return arrays of videos. All unsuccessful requests will throw easy to understand errors.

THIS PACKAGE USES ASYNC/AWAIT, download the latest node version.

Install

npm install --save discord-youtube-api

Example

const YouTube = require("discord-youtube-api");

const youtube = new YouTube("google api key");

async function testAll() {
	const video1 = await youtube.getVideo("https://www.youtube.com/watch?v=5NPBIwQyPWE");
	const video2 = await youtube.getVideoByID("5NPBIwQyPWE");
	const video3 = await youtube.searchVideos("big poppa biggie smalls");
	const videoArray1 = await youtube.getPlaylist("https://www.youtube.com/playlist?list=PLxyf3paml4dNMlJURcEOND0StDN1Q4yWz");
	const videoArray2 = await youtube.getPlaylistByID("PLxyf3paml4dNMlJURcEOND0StDN1Q4yWz");

	console.log(video1, video2, video3, videoArray1, videoArray2);
}

/*
Example video object:

Video {
    title: 'Dr. Dre - I Need A Doctor (Explicit) ft. Eminem, Skylar Grey',
    id: 'VA770wpLX-Q',
    description: 'Get COMPTON the NEW ALBUM from Dr. Dre on Apple Music: http://smarturl.it/Compton \n\nMusic
	video by Dr. Dre performing I Need A Doctor featuring Eminem and Skylar Grey (Explicit). © 2011 Aftermath
	 Records\n#VEVOCERTIFIED on Aug. 17, 2012. http://www.youtube.com/vevocertified',
    duration:
     { weeks: 0,
       years: 0,
       months: 0,
       days: 0,
       hours: 0,
       minutes: 7,
       seconds: 37 },
    durationSeconds: 457 },

as well as a few getters:

video.length
video.thumbnail
video.url

video.length is the duration formatted as HH:MM:SS
*/