New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

sort-youtube-videos

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-youtube-videos

sort youtube videos

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

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.

ParameterDescriptionrequired
URLYouTube channel url or channel Idtrue
sorting optionsDefault option lh to sort videos from least viewed videos to most viewed videos, hl to sort videos from Most popular upload to least popular uploadfalse

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

ParameterDescriptionrequired
URLYouTube channel url or channel Idtrue
sorting optionsTwo 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

ParameterDescriptionrequired
Channel NameTo get YouTube channel nametrue

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.

Keywords

youtube

FAQs

Package last updated on 09 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts