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-videos-helper

v2.4.0

Published

It helps to get the videos from youtube in the way you want!

Downloads

4

Readme

Youtube Videos Helper

Description

videos helper is a tiny library that helps you get normalized and customized data of the videos fetched from youtube. You can supply your own categories and the videos fetched will be added to your custom categories.

Installation


npm i youtube-videos-helper

Using the library

Step 1

You need to have youtube id's of the videos that the details of. You will get the id's from the end of the URL when you play a particular video.

Youtube Video Id

Whatever you see after ?v= is the id of youtube video.

You need to collect id's of all such youtube videos that you want to be a part of your database.

You can store all these id's in an array.

Step 2

Now define all your categories. The categories can be custom and completely depends on you.

After both these steps your code should look somehting like this:

const CricketDatabase = {
  ipl: ["JnC2zmLTd9A", "ivB5rJv2rsc"],
  worldcup: ["WHDlSWTJ7MM", "7vGsFiOhsF0"],
};

You can add as many categories as you want and as many videos as you want in the array of id's.

Step 3

The database is ready. Now, install the library using the command mentioned in the beginning.

Step 4

There are 3 helper functions in the package.

You will need only 2 functions initially.

  • getVideoDetails
  • getNormalizedVideoDetails

getVideoDetails

  • Input Parameter: It takes the database which should be an array of objects as input

  • Returns: Array. The object has 2 members: a pending promise and the corresponding category that you had provided for a particular video in your database.

Now call getVideoDetails with the mentioned inputs and store the received output in a variable.

getNormalizedVideoDetails

  • Input Paramater: It takes an object which should have the following properties:

    • arrayOfPromises: Array Whatever output you get from getVideoDetails should be assigned to arrayOfPromises.

    • originalViews: Boolean

      If you want the originalViews on that video then pass it as true.

      Note: By default the value is true

    • originalLikes: Boolean

      If you want the originalLikes on that video then pass it as true.

      Note: By default the value is true

  • Returns: Array

    • It returns an array og objects. The object has all the video details and the corresponding category that you had provided in the database.

Step 5 [Optional]

The duration property of the video is standard in ISO_8601 format. The library function getFormattedTime helps you in getting the time in useful format.

getFormattedTime

  • Input Paramater: string

    • It takes time in ISO_8601 format.
  • Returns: Object It returns you the time in an object as shown below

    {hours: `2`, minutes: `12`, seconds: `47`}

    Note that the values for hours, minutes and seconds are in string format