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

you-stream-js

v1.0.2

Published

A library to fetch YouTube video streams.

Downloads

197

Readme

You Stream

NPM License

You Stream is a simple and efficient JavaScript library for fetching YouTube video streams. It allows you to retrieve audio and video formats, get the best quality streams, and manage adaptive formats with ease.

pic

Table of Contents

Features

  • Fetch the best audio and video streams from YouTube videos.
  • Retrieve all available adaptive formats.
  • Get specific format information using its itag.
  • Lightweight and easy to use.

Installation

You can install you-stream via npm:

npm install you-stream-js

Usage

Here's how to use the you-stream library to get the best audio and video streams from a YouTube video.

Import the Library

const { getBestAudio, getBestVideo, getAllAdaptiveFormats, getFormatInfoByItag } = require('you-stream-js');

API Methods

  • getBestAudio(videoID)

    • Fetches the best available audio stream for the specified video ID.
    • Parameters: videoID (string): The ID of the YouTube video.
    • Returns: An object containing the best audio stream URL and its itag.
  • getBestVideo(videoID)

    • Fetches the best available video stream for the specified video ID.
    • Parameters: videoID (string): The ID of the YouTube video.
    • Returns: An object containing the best video stream URL and its itag.
  • getAllAdaptiveFormats(videoID)

    • Retrieves all adaptive formats available for the specified video.
    • Parameters: videoID (string): The ID of the YouTube video.
    • Returns: An array of all adaptive formats.
  • getFormatInfoByItag(videoID, itag)

    • Gets the format information based on the specified itag.
    • Parameters:
      • videoID (string): The ID of the YouTube video.
      • itag (number): The itag of the desired format.
    • Returns: The format information or a message indicating that the format was not found.

Example

Here’s an example demonstrating how to use the library:

const { getBestAudio, getBestVideo, getAllAdaptiveFormats, getFormatInfoByItag } = require('you-stream-js');

const videoID = 'YOUR_VIDEO_ID_HERE'; // Replace with a valid YouTube video ID

async function example() {
    try {
        const bestAudio = await getBestAudio(videoID);
        console.log('Best Audio:', bestAudio);

        const bestVideo = await getBestVideo(videoID);
        console.log('Best Video:', bestVideo);

        const allFormats = await getAllAdaptiveFormats(videoID);
        console.log('All Adaptive Formats:', allFormats);

        const formatInfo = await getFormatInfoByItag(videoID, 140);
        console.log('Format Info for itag 140:', formatInfo);
    } catch (error) {
        console.error('Error:', error);
    }
}

example();

Testing

To run the tests provided in test.js, you can execute the following command:

node test.js

Make sure to replace YOUR_VIDEO_ID_HERE with a valid YouTube video ID in the test.js file for testing.

Contributing

Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add new feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a pull request.

Acknowledgments

  • Inspired by yt-dlp for extracting YouTube streams.
  • Thanks to YouTube Data API for providing a way to interact with YouTube data.