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-stream-url-ts

v1.0.0

Published

Get stream url from youtube link

Downloads

2

Readme

youtube-stream-url-ts

Typescript version of (youtube-stream-url)[https://github.com/dangdungcntt/youtube-stream-url/]

Get stream url from youtube video in node.js (included Copyright Music Video).

Installation

With npm do:

npm install youtube-stream-url

Usage

const Youtube = require('youtube-stream-url');

Youtube.getInfo({url: 'https://www.youtube.com/watch?v=pJ7WN3yome4'}).then(video => console.log(video));

Full output

{
    videoDetails: {
        videoId: 'pJ7WN3yome4',
        title: 'M1 Ultra Mac Studio - Benchmarks & Thermals (The TRUTH!)',
        lengthSeconds: '1165',
        keywords: [
        'mac studio',
        'mac',
        'apple',
        'apple mac',
        'apple mac studio',
        'mac studio benchmarks',
        'mac studio teardown',
        'mac studio perfornance',
        'mac studio vs',
        'm1 ultra',
        'm1 ultra chip',
        'm1 ultra mac studio',
        'm1 ultra vs m1 max',
        'm1 max vs m1 ultra',
        'm1 max vs m1 ultra mac studio',
        'm1 ultra vs m1 max mac studio',
        'mac studio vs macbook pro',
        'mac studio vs imac',
        'mac studio vs mac mini',
        'mac studio thermal throttle test',
        'mac studio benchmarks test',
        'mac studio watt metere',
        'mac studio max tech',
        'mac studio ultra'
        ],
        channelId: 'UCptwuAv0XQHo1OQUSaO6NHw',
        isOwnerViewing: false,
        shortDescription: '...',
        isCrawlable: true,
        thumbnail: { thumbnails: [Array] },
        averageRating: 4.9487238,
        allowRatings: true,
        viewCount: '1124295',
        author: 'Thái Trinh Official',
        isPrivate: false,
        isUnpluggedCorpus: false,
        isLiveContent: false
    },
    formats: [
        {
        url: 'https://r4---sn-8qj-i5ol7.googlevideo.com/videoplayback...',
        type: 'video/mp4; codecs="avc1.64001F, mp4a.40.2"',
        itag: '22',
        quality: 'hd720'
        },
        ...
    ],
    liveData: { //For live video (videoDetails.isLiveContent == true)
        manifestUrl: 'https://manifest.googlevideo.com/...',
        data: {
            segments: [
                {
                    "isMasterPlaylist": true,
                    "streamInf": {
                        "bandwidth": 290288,
                        "codecs": [
                            "mp4a.40.5,avc1.42c00b"
                        ],
                        "resolution": 256,
                        "frameRate": 15,
                        "videoRange": "SDR",
                        "subtitles": "vtt",
                        "closedCaptions": "NONE"
                    },
                    "url": "https://manifest.googlevideo.com/api/manifest/hls_playlist/.../playlist/index.m3u8"
                },
                ...
            ],
            "media": {
                "SUBTITLES": {
                    "vtt": {
                        "en": {
                            "groupId": "vtt",
                            "uri": "https://manifest.googlevideo.com/...",
                            "type": "SUBTITLES",
                            "language": "en",
                            "name": "en",
                            "default": false,
                            "autoselect": "YES"
                        }
                    }
                }
            }
        }
    }
}

For live video, you can get HLS Stream URL via liveData field. liveData.data format is m3u8-file-parser output of manifest file from liveData.manifestUrl.

Handle error

By default, getInfo function return false when an error occurred while process. If you want manualy handle error, you can pass option throwOnError: true

try {
    await Youtube.getInfo({url: '...', throwOnError: true})
} catch (e) {
    //Handle error here
}

Update

Since the youtube-stream-url binary is updated regularly, you can run npm update to check for and download any updates for it.

License

MIT © Dang Dung