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

yt-dude

v1.0.13

Published

here is a package for crawling and downloading videos from youtube

Downloads

15

Readme

yt-dude

yt-dude is an advanced crawler for YouTube.

Installation

npm i --save yt-dude

Dependencies

There is no additional dependency other than modules ;)

Usage

  const ytdude = require('yt-dude');
  const { resolve } = require('path');

  Array(
    ['channel', 'https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ'],
    ['channelPlaylistPage', 'https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/playlists'],
    ['video', 'https://www.youtube.com/watch?v=Rq3y7w_Lkgk'],
    ['homepage', 'https://www.youtube.com/'],
    ['trending', 'https://www.youtube.com/feed/trending'],
    ['gaming', 'https://www.youtube.com/gaming'],
    ['playlist', 'https://www.youtube.com/playlist?list=PLFgquLnL59an-05S-d-D1md6qdfjC0GOO']
  ).map(([name, url]) => {
    // crawling method can crawl anywhere
    // it returns a Promise which resolves Youtube.Video[] or Youtube.Playlist[]

    ytdude.crawl(url).then(results => {
      console.log(name, results.length, 'result(s)');
    }, console.error);
  });

  // for specificly crawling videos
  // you can use search method directly
  ytdude.search('gazirovka black').then(results => {
    let result = results[0];

    // to be sure that we have a result
    if (result) {
      // filename can point to a folder that does not exist
      // in this condition ytdude will create the path for you
      const filename = resolve(__dirname, 'mp3', result.title + '.mp3');
      ytdude.download(result, filename)
        .on('progress', progress => {
          write(filename + ": " + progress.percent + "%");
        })
        .on('done', () => {
          write();
          console.log(filename + ": Done");
        })
        .then(() => {
          // download method also can be
          // converted to a promise
          console.log('done with promise')
        }, error =>{
          // second callback as error handler
          console.error(error);
        })
        .catch(error => {
          // another method for error handling
          console.error(error);
        });
    }
  });

  // just a little helper
  function write(str = "") {
    process.stdout.cursorTo(0);
    process.stdout.clearLine(1);
    process.stdout.write(str);
  }

Interfaces

Youtube.Video

  interface Video {
    channelId: string
    channelName: string
    channelThumbnail: string
    channelUrl: string
    channelVerified: boolean
    descriptionSnippet: string
    duration: number
    durationText: string
    durationTextLong: string
    length: number
    lengthText: string
    lengthTextLong: string
    longBylineText: string
    publishedTimeText: string
    richThumbnail: string
    shortViewCount: number
    shortViewCountText: string
    showActionMenu: boolean
    thumbnail: string
    title: string
    titleLong: string
    trackingParams: string
    videoId: string
    viewCount: number
    viewCountText: string
  }

Youtube.Playlist

  interface Playlist {
    longBylineText: string
    playlistId: string
    shortBylineText: string
    thumbnail: string
    thumbnailText: string
    title: string
    trackingParams: string
    videoCount: number
    videoCountShort: number
    videoCountShortText: string
    videoCountText: string
  }

Youtube.Channel

  interface Channel {
    channelId: string
    channelName: string
    channelThumbnail: string
    channelUrl: string
    channelVerified: boolean
  }