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 🙏

© 2026 – Pkg Stats / Ryan Hefner

amon-subtitles

v1.0.5

Published

## Description

Readme

YouTube Subtitles Fetcher

Description

This project provides a getSubtitles function to fetch subtitles from YouTube videos. You can specify preferred subtitle languages ​​(default is ['vi', 'en', 'fr']) and the function will return subtitles for YouTube videos.

Installation

First, you need to install the required libraries in the project:

  1. Axios: Used to make HTTP requests.

  2. Lodash: Used to process arrays and objects.

  3. HE: Used to decode special characters in subtitles.

  4. Striptags: Used to strip HTML tags in subtitles.

Install the required libraries:

npm i amon-subtitles

Importing the Functions:

import { getSubtitles, getContentPage } from 'amon-subtitles'

1. Fetching YouTube Subtitles

To fetch subtitles from a YouTube video, use the getSubtitles function. You can specify the videoID (the unique identifier of the YouTube video) and the preferredLangs (a list of languages you prefer for the subtitles). The function will return the subtitles for the video in the specified languages.

Usage

const data = await getSubtitles({
    videoID: 'wLuZ0WMyr9U',     // YouTube video ID
    preferredLangs: ['vi'],      // Preferred subtitle language(s)
});

Example response:


{
  lang: 'vi',  // Language of the subtitles
  lines: [
    {
      start: '0:01',
      dur: '0:05',
      seconds: 1,
      text: 'Welcome to the video!'
    },
    {
      start: '0:06',
      dur: '0:10',
      seconds: 6,
      text: 'Today, we will learn JavaScript programming.'
    },
    // Additional subtitle lines...
  ]
}

2. Fetching Content from a Website

You can use the getContentPage function to extract and clean the content from a website, even if the website has bot protection mechanisms (like captchas or JavaScript rendering). This function will remove HTML tags, scripts, and unnecessary content to return clean text from the page

Usage

const fetchDataWebsite = await getContentPage(url="https://www.base64decode.org/")

Example response:

[
  "Welcome to Base64 Decode and Encode",
  "Our tool allows you to decode and encode data in Base64 format.",
  // Other lines of clean content...
]

Additional Information:

getSubtitles will return the subtitles in the specified languages. If the preferred language is unavailable, it will attempt to use the first available language. If no subtitles are found, it throws an error.

getContentPage is a robust method for scraping and extracting content, especially useful for bypassing bot protection like CAPTCHAs or JavaScript rendering. It uses Puppeteer to simulate a real user browsing experience, allowing you to get data even from websites that block traditional scrapers