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

sort-youtube-videos

v1.0.5

Published

sort youtube videos

Downloads

12

Readme

Sort YouTube Videos

Additional sorting options for YouTube channel videos.

Demo

Demo coming soon!!!

Support

Support development of this project.

Why?

YouTube only offers few sorting options, But, I want to use some other sorting options like Sort videos by least viewed video to most viewed video, sort by video duration, etc...

No API key is required

Installation

npm i sort-youtube-videos

with yarn:

yarn add sort-youtube-videos

sortByViews(url): - Sort videos by views.

| Parameter | Description | required | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | | URL | YouTube channel url or channel Id | true | | sorting options | Default option lh to sort videos from least viewed videos to most viewed videos, hl to sort videos from Most popular upload to least popular upload | false |

Example

const { sortByViews } = require("sort-youtube-videos");
// import { sortLowToHigh } from "sort-youtube-videos"

const url = "https://www.youtube.com/channel/UC5RRWuMJu7yP1DQwnW_nAvA"; //url or channel id
//Sort by views low to high
sortByViews(url).then((res) => console.log(res));

// response type
[
  {
    type: "video",
    title: "#shorts",
    videoId: "DOrVURA_O90",
    author: "Anas and Ammar",
    authorId: "UC5RRWuMJu7yP1DQwnW_nAvA",
    videoThumbnails: [[Object], [Object], [Object], [Object]],
    viewCountText: "10 views",
    viewCount: 17,
    publishedText: "4 months ago",
    durationText: "0:57",
    lengthSeconds: 57,
    liveNow: false,
    premiere: false,
    premium: false,
  },
  {
    type: "video",
    title: "Ramzan Ki Shan Episode 04",
    videoId: "7VO4ZLBVQiY",
    author: "Anas and Ammar",
    authorId: "UC5RRWuMJu7yP1DQwnW_nAvA",
    videoThumbnails: [[Object], [Object], [Object], [Object]],
    viewCountText: "17 views",
    viewCount: 17,
    publishedText: "5 months ago",
    durationText: "8:08",
    lengthSeconds: 488,
    liveNow: false,
    premiere: false,
    premium: false,
  },
  //   ... 109 more items
];

sortByDuration(url): - Sort videos by duration

| Parameter | Description | required | | --------------- | ---------------------------------------------------------------------------------------- | -------- | | URL | YouTube channel url or channel Id | true | | sorting options | Two sorting options are available: Default sl (short -> long) and ls (long -> short) | false |

Example

const { sortByDuration } = require("sort-youtube-videos");
// import { sortByDuration } "sort-youtube-videos";

const url = "https://www.youtube.com/channel/UC5RRWuMJu7yP1DQwnW_nAvA"; //url or channel id
const sortBy = "sl"; // options: sl - ls

sortByDuration(url, sortBy).then((res) => console.log(res));

// response type
[
  {
    type: "video",
    title: "Ramadan Ki Shan Episode 11 Digitally Presented by Spiced Foods",
    videoId: "dgoBBYbSKUQ",
    author: "Anas and Ammar",
    authorId: "UC5RRWuMJu7yP1DQwnW_nAvA",
    videoThumbnails: [[Object], [Object], [Object], [Object]],
    viewCountText: "15 views",
    viewCount: 15,
    publishedText: "5 months ago",
    durationText: "4:09",
    lengthSeconds: 249,
    liveNow: false,
    premiere: false,
    premium: false,
  },
  {
    type: "video",
    title:
      "Watch latest movies, web series and TV channels for free without any subscription ||Android",
    videoId: "ummVLFK17GI",
    author: "Anas and Ammar",
    authorId: "UC5RRWuMJu7yP1DQwnW_nAvA",
    videoThumbnails: [[Object], [Object], [Object], [Object]],
    viewCountText: "16 views",
    viewCount: 16,
    publishedText: "1 year ago",
    durationText: "4:11",
    lengthSeconds: 251,
    liveNow: false,
    premiere: false,
    premium: false,
  },
  //   ... 109 more items
];

search_channel(name): - Get YouTube channel URL

| Parameter | Description | required | | ------------ | ----------------------------- | -------- | | Channel Name | To get YouTube channel name | true |

Example

const { search_channel } = require("sort-youtube-videos");
// import { search_channel } from "sort-youtube-videos";

const channelName = "Codestick"; // YouTube  channel name
search_channel(channelName).then((res) => console.log(res));

// response type
// return all channel with this name
[
  {
    channelId: "UCYGZ4todIWGIUS1B8ZjML1w",
    description: "Learn Coding... Happy Coding.....",
    link: "https://www.youtube.com/channel/UCYGZ4todIWGIUS1B8ZjML1w",
    thumbnails: [[Object], [Object]],
    subscribed: false,
    uploadedVideos: 57,
    verified: false,
  },
  {
    channelId: "UCae4VwFs7LtQimLOhk6Gdow",
    description: "",
    link: "https://www.youtube.com/channel/UCae4VwFs7LtQimLOhk6Gdow",
    thumbnails: [[Object], [Object]],
    subscribed: false,
    uploadedVideos: 2,
    verified: false,
  },
  // all channels with this name
];

Sorting options:

  • Sort videos by views (least viewed video to most viewed video 1 view - 1M views) sortByViews(url);
  • Sort by video duration (shortest duration to longest duration and longest duration to shortest duration ) sortByDuration(channelName);
  • More sorting options coming soon

Contributing

Pull requests are welcome.