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-dl-streamer

v1.0.1

Published

Script to capture yt-dl-core readable streams and write them to '.flv' or '.mp3' files on your disk.

Downloads

5

Readme

yt-dl-streamer

Script to capture yt-dl-core readable streams and write them to ".flv" or ".mp3" files on your disk.

Description

Basically a module that downloads Youtube audio and/or video to your disk using progress-stream to show you the progress.

Getting Started

Dependencies

  • Node.js
  • progress-stream
  • sanitize-filename
  • ytdl-core
  • fluent-ffmpeg (Optional, only for audio downloads)

Installing

$: npm i --save yt-dl-streamer

Examples in Javascript

  • Downloading a video:
const Streamer = require("yt-dl-streamer").Streamer;

try {
    const link = "4oMJIyVOWL4";
    const outPath = "/home/bgiannoti/Work/myStuff/videos";
    const format = "Video";
    const quality = "Highest";
    const timeoutBetweenProgressEmits = 1000;

    const ytStream = new Streamer(format, quality, outPath, timeoutBetweenProgressEmits, null);
    ytStream.download(link);
    ytStream.runQueue();
    
    ytStream.on("finished", (err, data) => {
        console.log(JSON.stringify(data));
        process.exit(0);
    });

    ytStream.on("error", (error) => {
        console.log(error);
    });

    ytStream.on("progress", (progress) => {
        console.log(JSON.stringify(progress));
    });
} catch (e) {
    console.error(e)
    process.exit(1);
}
  • Downloading a audio-only .mp3:
const Streamer = require("./tsc/Streamer").Streamer;

try {
    const link = "4oMJIyVOWL4";
    const outPath = "/home/bgiannoti/Work/bdv-yt-dl-streamer-to-file/videos";
    const format = "Audio";
    const quality = "Highest";
    const pathToFfmpeg = "/snap/bin/ffmpeg";
    const timeoutBetweenProgressEmits = 1000;

    const ytStream = new Streamer(format, quality, outPath, timeoutBetweenProgressEmits, pathToFfmpeg);
    ytStream.download(link);
    ytStream.runQueue();
    
    ytStream.on("finished", (err, data) => {
        console.log(data);
        process.exit(0);
    });

    ytStream.on("error", (error) => {
        console.log(error);
    });

    ytStream.on("progress", (progress) => {
        console.log(progress);
    });
} catch (e) {
    console.error(e)
    process.exit(1);
}

Types and definitions

In Javascript:

const Streamer = require("./tsc/Streamer").Streamer;

In Typescript:

import Streamer from "./src/Streamer;

The Streamer class is instantiated by passing the following parameters:

   "format": <const string>,
   "quality": <const string>,
   "out": <string>,
   "timeout": <number>,
   "codecPath"?: <string>
  • format accepts only two possible values: 'Audio' or 'Video'.
  • quality - accepts only two possible values: 'highest' or 'lowest'
  • 'out' - the strigified path of the output on your disk you want files to be saved to. If you present a invalid path, the script will try to create it for you.
  • 'timeout' - the timeout between each progress log emit of your downloaded file.
  • 'codecPath' - Not mandatory, only if you want a .mp3 conversion. In that case you need to provide the path in your disk for the ffmpeg installation. (https://www.ffmpeg.org/download.html)

[Streamer].download(link: <string>): null

  • download method is responsible for pushing your link to the download queue.

[Streamer].runQueue(link: <string>): null

  • runQueue method is responsible for actively executing the binded download links in order.

Events emitted

[Streamer].on("progress", [Function]) [Streamer].on("finished", [Function]) [Streamer].on("error", [Function])

Authors

Brunodev09 - Bruno Mayol Giannotti

License

MIT