GithubHelp home page GithubHelp logo

revelts / youtubei Goto Github PK

View Code? Open in Web Editor NEW

This project forked from suspiciouslookingowl/youtubei

0.0 0.0 0.0 2.23 MB

Get Youtube data such as videos, playlists, channels, video information & comments, related videos, up next video, and more!

Home Page: https://suspiciouslookingowl.github.io/youtubei

License: MIT License

JavaScript 0.80% TypeScript 99.20%

youtubei's Introduction

Youtubei

Youtubei is made to replace my other library scrape-yt. Instead of scrapping data from Youtube page, youtubei fetches data by sending a request directly to https://www.youtube.com/youtubei/v1, which should be faster and provide more reliable result.

Requires Node >= 16

Installation

npm i youtubei

or use the dev build directly from GitHub:

npm i git://github.com/suspiciouslookingowl/youtubei.git#dist

Example

const { Client, MusicClient } = require("youtubei");
// or for TS / ES6
import { Client, MusicClient } from "youtubei";

const youtube = new Client();
const music = new MusicClient();

const run = async () => {
	const videos = await youtube.search("Never gonna give you up", {
		type: "video", // video | playlist | channel | all
	});

	console.log(videos.items.length); // 20
	const nextVideos = await videos.next(); // load next page
	console.log(nextVideos.length); // 18-20, inconsistent next videos count from youtube
	console.log(videos.items.length); // 38 - 40

	// you can also pass the video URL
	const video = await youtube.getVideo("dQw4w9WgXcQ");

	const channelVideos = await video.channel.videos.next();
	const channelPlaylists = await video.channel.playlists.next();

	// you can also pass the playlist URL
	const playlist = await youtube.getPlaylist("UUHnyfMqiRRG1u-2MsSQLbXA");
	console.log(playlist.videos.items.length); // first 100 videos;
	let newVideos = await playlist.videos.next(); // load next 100 videos
	console.log(playlist.videos.items.length); // 200 videos;
	await playlist.videos.next(0); // load the rest videos in the playlist

	// search using music client
	const shelves = await music.search("Never gonna give you up");
	console.log(shelves);
};

run();

youtubei's People

Contributors

jiangzhuo avatar kagchi avatar niek-o avatar suspiciouslookingowl avatar titong0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.