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

vid_data

v1.0.0

Published

Get youtube channel, video or playlist information

Downloads

16

Readme

get_video_id(url)

Given Youtube video URL, returns video id

Parameter :

  • url : A youtube video watch URL as string. Supported URL format example :
    • https://www.youtube.com/watch?...
    • https://m.youtube.com/watch?...
    • https://youtu.be/...
    • https://www.youtube.com/embed/...
    • https://www.youtube-nocookie.com/embed/...

Returns :

  • A string containing video id, or
  • null

get_channel_id(url, offline, print_error)

Given Youtube channel, video or user URL, returns channel id

Parameters :

  • url : A youtube video watch, channel or user URL as string. Supported URL format example :
    • https://www.youtube.com/channel/...
    • https://www.youtube.com/user/...
    • https://www.youtube.com/watch?...
    • https://m.youtube.com/watch?...
    • https://youtu.be/...
    • https://www.youtube.com/embed/...
    • https://www.youtube-nocookie.com/embed/...
  • offline : An optional boolean argument to indicate whether or not to make HTTP request to get channel ID.
    • Default is false, which makes a single HTTP request to https://www.youtube.com/watch?... or https://www.youtube.com/user/... URL.
    • Setting it to true would return null to all URL other than those formatted like this https://www.youtube.com/channel/...
  • print_error : An optional boolean argument to indicate whether or not to print any possible error message to console. Only useful for debugging. Default false.

Returns :

  • A promise that resolves a string containing channel ID or,
  • A promise that resolves null

is_valid_to_get_channel_id(url)

Given a URL, returns a Boolean indicating whether or not it is valid URL to get channel id

Parameter :

  • url : Any type

Returns :

  • True if url is one of the valid format to get channel ID information
    • See get_channel_id() above for URL formats that are considered valid
  • False if url is not one of the valid format

get_playlist_id(url)

Given a playlist URL, returns the playlist's ID

Parameter :

  • url : A youtube account user created playlist URL. Supported url format example:
    • https://www.youtube.com/playlist?list=...
    • https://m.youtube.com/playlist?list=...
    • https://www.youtube.com/watch?v=naHNhDHK4VU&list=...
    • https://m.youtube.com/watch?v=naHNhDHK4VU&list=...

Returns :

  • A string containing playlist ID, or
  • null

get_playlist_videos(url, offline, print_error)

Given playlist URL, returns an ordered array of playlist video IDs

Parameters :

  • url : A youtube account user created or custom playlist URL. Supported url format example:
    • https://www.youtube.com/playlist?list=...
    • https://m.youtube.com/playlist?list=...
    • https://www.youtube.com/watch?v=naHNhDHK4VU&list=...
    • https://m.youtube.com/watch?v=naHNhDHK4VU&list=...
    • https://www.youtube.com/embed/naHNhDHK4VU?playlist=...,...,...
  • offline : An optional boolean argument to indicate whether or not to make HTTP request to get channel ID.
    • Default is false (makes HTTP request). Note that only URLs formatted as https://www.youtube.com/embed/naHNhDHK4VU?playlist=...,...,... are parsable offline
  • print_error : An optional boolean argument to indicate whether or not to print any possible error message to console. Only useful for debugging. Default false.

Returns :

  • A promise that resolves a non-empty array of ordered video IDs of the playlist
    • The maximum length of this array is currently 100
  • If invalid, error, or not parsable, returns a promise that resolves null

get_channel_id_and_name(url)

Given a video/video shortcut/embed/channel/user url, makes a single HTTP request and returns an object containing keys channel_id and channel_name with string values. On error or invalid url, returns null.

NOTE: this function is comparatively more susceptible to break on changes.


This software was not produced by or directly for YouTube, LLC and has no affiliation with the LLC. Use this software only at your own volition.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.