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

@freetube/yt-trending-scraper

v3.1.1

Published

Identifies the currently trending videos on YouTube and returns all trending site information about every video without accessing the YouTube API.

Downloads

67

Readme

YouTube Trending Videos Scraper NodeJS Documentation

This NodeJS library can scrape all available trending pages of YouTube without any API usage. It is developed for and tailored towards easy usage in FreeTube but can be used with any other project as well.

Therefore, this library does not require any API keys, with the attached maximum quotas, but instead might take longer to receive the required data.

The library works as long as YouTube keeps its web page layout the same. Therefore, there is no guarantee that this library will work at all times. If this library should not work at some point, please create an issue and let me know so that I can take a look into it. Pull requests are also welcomed in this case.

Installation

npm install @freetubeapp/yt-trending-scraper

Usage

const ytrend = require("@freetubeapp/yt-trending-scraper")

API

scrapeTrendingPage(parameters) Returns a list of objects containing all the information of the trending videos.

The parameters object can contain the following options:

 geoLocation:           String,
 parseCreatorOnRise:    Boolean,
 page:                  String

geoLocation is an optional parameter to change the country (e.g. JP for Japan) of the trending page. The alpha2 code of the country must be used

parseCreatorOnRise is an optional parameter which allows the parser to process any horizontal video list, which usually is a creator on the rise. But this is not always available, so the scraper will process as usual even when the parameter is set to true. Defaults to false

page is an optional parameter which allows to choose one of the 4 trending pages below.

  • default
  • music
  • gaming
  • movies

Example usage

const parameters = {
    geoLocation: 'JP',
    parseCreatorOnRise: false,
    page: 'music'
}

ytrend.scrapeTrendingPage(parameters).then((data) =>{
    console.log(data);
}).catch((error)=>{
    console.error(error);
});

// The data is a list of objects containing the following attributes:
{
    videoId:            String,
    title:              String,
    type:               "video",
    author:             String,
    authorId:           String,
    authorUrl:          String,
    videoThumbnails:    Array[Objects],
    description:        String,
    viewCount:          Number,
    published:          Number as timestamp,
    publishedText:      String,
    lengthSeconds:      Number,
    timeText:           String,
    liveNow:            false,
    paid:               false,
    premium:            false,
    isUpcoming:         false,
    isCreatorOnRise:    Boolean, // indicates whether the video is part of a creator on the rise
    isVerified:         Boolean,
    isVerifiedArist:    Boolean,
    isShort:            Boolean
}

// The thumbnail objects:
{
    quality:    "String",
    url:        "String",
    width:      Number,
    height:     Number
}

Credits

Thanks to PrestoN for the basic instructions and underlying request code and thanks to ~cadence for the HTML extractor RegEx.