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

youtube-dl2

v1.0.0

Published

A different youtube-dl

Downloads

7

Readme

youtube-dl2

WIP - Not exactly functional right now.

Its literally the same functionality of the original youtube-dl, but more in my style and hopefully better tested and updated

Last tested with version: 2018.03.10

IMPORTANT: This version does not come with youtube-dl pre-installed. install it and have it in your path, else its not going to work.

Differences

The original youtube-dl downloads the video on request. This kills a lot of functionality in youtube-dl itself like extracting audio. This module gives more control over your output and what the module does.

This module also improves on some things like better process cleanup with some updated methods.

End goal is a more testable, updated and controllable youtube-dl.

Usage

options

Options are not pushed to youtube-dl in the normal fashion, instead you can pass an object like this:

{
  format: 'best' // --format=best
  min_views: 1000 // --min-views=1000
  r: '50K' // --limit-rate=50K,
  geo_bypass: true // --geo-bypass
}

Underscores (_) are replaced with minus signs (-) and aliases are replaced by their full flag name.

This just makes it a bit easier to manipulate and read.

youtubedl2(url, [options])

Downloads url and returns it as a stream.

Returns an execa returnable where .stdout is the output stream. This is subject to change.

Note: Does not support arguments like extract_audio due to the nature of youtube-dl outputting to stdout. Read more below.

youtubedl2.buffer(url, [options])

Returns a promise which returns the file as buffer

Note: Not recommended as it writes everything to memory.

youtubedl2.file(filename, url, [options])

Returns a promise which resolves when file is written.

youtubedl2.getInfo(url, [options])

Gets info of url in --dump-json format

Url can be some sort of playlist or an array of urls too.

Returns a promise

Downloading audio

Due to the nature of youtube-dl's outputting to stdout, it does not support flags like --extract-audio. There are a few ways around this.

Selecting audio format

The format option allows a few different arguments.

  • bestaudio
  • worstaudio
  • Any sound file extension (make sure the queried url supports it by checking the info.formats from youtube-dl2.sgetInfo)

More info here: https://github.com/rg3/youtube-dl/blob/master/README.md#format-selection

Manually converting it with ffmpeg

Example: ffmpeg -i video.mp4 -f mp3 -ab 192000 -vn music.mp3

This is just a really simple example, but you can get more complicated.

Check the ffmpeg docs for more info.

Note: I might implement this natively into the module itself.