Giter Site home page Giter Site logo

suspiciouslookingowl / youtubei Goto Github PK

View Code? Open in Web Editor NEW
217.0 9.0 49.0 3.35 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.70% TypeScript 99.30%

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

antoniojps avatar azutake avatar deadlinecode avatar jiangzhuo avatar jsydorowicz21 avatar kagchi avatar niek-o avatar suspiciouslookingowl avatar titong0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtubei's Issues

[ENHANCEMENT] Add `corsHost` option

Is your feature request related to a problem? Please describe.
Since this library is using an unofficial Youtube API and it doesn't allow CORS request, one of the solution to make it work is by using cors-anywhere. But currently there's no easy way to let the library know to use the cors-anywhere endpoint instead of sending the request directly to youtube.com

Describe the solution you'd like
Add corsHost option to the main class constructor

import { Client } from "youtubei"

const youtube = new Client({
    corsHost: "https://cors-anywhere.herokuapp.com/"
});

Additional context
Inspired by #10

[BUG] TypeError: playlist.next is not a function

Describe the bug

The playlist.next() function does not work in Youtube's own artist mixes and gives this error (TypeError: playlist.next is not a function) . As far as I understand, Youtube's artist mixes have 20-25 songs. However, the .next() function, which can be used even if the number of songs in the normal playlist is below 100 and does not give an error, results in an error in Youtube's mixes.

Expected behavior

I want playlist.next() to work on Youtube mixes (If the number of songs is less than 100 it should not give an error and if it is above 100 it should work.)

Additional context

People who don't want a problem until the bug is fixed they can use the code like :

if(playlist.channel) await playlist.next(0);
(Youtube's own mixes don't have a channel infos .)

[ENHANCEMENT] — Support more Mix Playlists

Hi !

Describe the bug
Getting information from the mixes does not seem to work

To Reproduce
Capture d’écran 2021-09-26 à 16 01 07

Expected behavior
Have information about the mix / videos contained in it

Screenshots

Full URL of the mix :
Capture d’écran 2021-09-26 à 16 02 25

The code
Capture d’écran 2021-09-26 à 16 02 52

Result :
Capture d’écran 2021-09-26 à 16 05 04

And sometimes :
Capture d’écran 2021-09-26 à 16 07 52

I'm now on version 0.0.1-rc.24

[ENHANCEMENT] Workaround for Video Upload Date

Is your feature request related to a problem? Please describe.
No

Describe the solution you would like*
Hi, I am using this package in my project and made a simple workaround to get the video upload date in Javascript Date format.
It's not ideal, but it can replace the current text.

I made a simple example using axios. I set the default language English in the request to get only date and time text in English.
After that, a function extracts the time from the text and converts it to the Date object.

https://gist.github.com/rafaeljustinox/620a0950c1e952c7ca4587aef0ba21ea

It is just an idea that works for me because I only need the date, but when the text allows, I convert to hours and minutes as well.

[ENHANCEMENT] Result finding improvement

Is your feature request related to a problem? Please describe.
When you click share a video button on Youtube, it gives you a link with ?feature=share at the end (usually in shorts videos). This is normal, but if you type this link in the search field, it says "no results found". If you remove the ?feature=share part from the link, it will give you the result you want at the top.

Describe alternatives you've considered
I think every developer can solve this problem very easily. For example :

const link = "https://www.youtube.com/watch?v=dQw4w9WgXcQ?feature=share"
link.replace("?feature=share",'')

I thought it would be better if the module did this automatically.

How to use on client side?

got an error when try running on windows nodejs.

c:\xampp\htdocs>node server.js
file:///c:/xampp/htdocs/server.js:3
import { Client } from "youtubei";
^^^^^^

SyntaxError: Identifier 'Client' has already been declared
←[90m at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)←[39m
←[90m at async link (internal/modules/esm/module_job.js:63:21)←[39m

c:\xampp\htdocs>node server.js
file:///c:/xampp/htdocs/server.js:1
const { Client } = require("youtubei");
^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and 'c:\xampp\htdocs\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///c:/xampp/htdocs/server.js:1:20
←[90m at ModuleJob.run (internal/modules/esm/module_job.js:169:25)←[39m
←[90m at async Loader.import (internal/modules/esm/loader.js:177:24)←[39m
←[90m at async Object.loadESM (internal/process/esm_loader.js:68:5)←[39m

How can this actually being used in client server?

Set default value for result to avoid throwing error

When using await youtube.getChannel("UCni1rOH6_7JL8Nm4QtZvFXw") to crawl a channel without thumbnail, it throws error TypeError: Cannot read property 'thumbnails' of undefined.
Better to check if it is undefined or null before accessing it. Not all channel got thumbnail or join date etc

[BUG] Unresolved function or method

These two functions are not working.

  const channelVideos = await video.channel.getVideos();
  const channelPlaylists = await video.channel.getPlaylists();

Attached screenshot -

Screenshot 2021-08-30 at 12 38 50 PM

[BUG] CORS error from localhost

Describe the bug

I'm trying this library out for the first time and I'm running into a cross origin resource sharing error in my browser (Brave, privacy shields disabled):

Access to fetch at 'https://www.youtube.com/watch?v=wEVit5lILno&pbj=1' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
www.youtube.com/watch?v=wEVit5lILno&pbj=1:1 Failed to load resource: net::ERR_FAILED
asyncToGenerator.js?1da1:6 Uncaught (in promise) TypeError: Failed to fetch

To Reproduce

The code I am using in my Vue app running on localhost:

import { Client } from "youtubei"

const youtube = new Client()

(async () => {
  const video = await youtube.getVideo("wEVit5lILno")
  console.log(video)
})()

Expected behavior

I was expecting this to just work, or alternatively the documentation to call this out in some way and if there are workarounds.

Additional context

  • Is this only a problem on localhost?
  • Am I doing something wrong? Should there have been an additional set up step?
  • Is this same request expected to work in production when deployed to a real URL? Is only localhost not allowed?

[ENHANCEMENT] Examples on how to use cookies

Is your feature request related to a problem? Please describe.
429's are hard to avoid, cookies are one way to slow down the inevitable problem.

Describe the solution you'd like
Better documentation on how to use cookies, such as which format it accepts.
Examples on how to use cookies from node-ytdl-core or youtube-dl would be a great addition.

Any additional info and examples on how to extract the cookies would be a great addition too.

Thank you.

[BUG] JSON parse Error

Describe the bug
Library wont continue due to parsing error.

uncaughtException: Unexpected token < in JSON at position 0
SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Gunzip.<anonymous> (C:\Users\Thunderbolt XV\Desktop\soundwave\SoundWave-dev\node_modules\youtubei\dist\common\HTTP.js:75:39)
    at Gunzip.emit (events.js:315:20)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

[BUG] Playlist return undefined

Describe the bug
A clear and concise description of what the bug is.
When i load this playlist PLVH_c0JJpuSpTf3MI7vqz_6UKwvbbtitk its return undefined, but if i post using Client#http video content is available

To Reproduce
Steps to reproduce the behavior:
Client.getPlaylist("PLVH_c0JJpuSpTf3MI7vqz_6UKwvbbtitk")

Expected behavior
A clear and concise description of what you expected to happen.
Should return all videos in playlist.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Additional context
Add any other context about the problem here.

[ENHANCEMENT] Expose pagination / continuation key

Is your feature request related to a problem? Please describe.
Continuation keys are currently not exposed, making it not possible to fetch contents on n-th page using continuation key

Describe the solution you'd like
Expose continuation key on all paginated property, e.g.:

const videos = await channel.nextVideos();
const paginationKey = channel.videoPaginationKey;

// on different state...
const videos = await channel.nextVideos(paginationKey)

[BUG]

Describe the bug
When searching for certain songs ("bandit" for example) it comes back without any results.

To Reproduce
^

Expected behavior
I expected it to pull up a result

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

[BUG] Errors on limited videos (age, members, etc)

Describe the bug
Age-restricted and members-only videos throw errors on fetching.

Versioning
Module: v0.0.1-rc.14
Node: v14.15.4

To Reproduce
Steps to reproduce the behavior:

  1. find an age-restricted/members-only video
  2. Client.getVideo('<the ID of the video>')
  3. observe result

Expected behavior
No errors (or another kind of "more-clear error", I guess)

Real Behavior
Age restricted:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
    at Video.load (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\BaseVideo.js:58:49)   
    at Video.load (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\Video.js:28:15)       
    at Client.<anonymous> (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\Client.js:68:50)
    at Generator.next (<anonymous>:null:null)
    at fulfilled (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\Client.js:5:58)        
    at runMicrotasks (<anonymous>:null:null)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Members-only:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'defaultText' of undefined
    at Video.load (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\BaseVideo.js:47:92)   
    at Video.load (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\Video.js:28:15)       
    at Client.<anonymous> (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\Client.js:68:50)
    at Generator.next (<anonymous>:null:null)
    at fulfilled (C:\amogus\sus\mysusbot\node_modules\youtubei\dist\classes\Client.js:5:58)        
    at runMicrotasks (<anonymous>:null:null)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Additional context
For step 1 of the reproduction steps, here are two videos I tested it on:

'https://www.youtube.com/watch?v=y7QkjrHmF18' // Age restricted
'https://www.youtube.com/watch?v=oPz6wk76buE' // Members-only

[BUG] 'contents' , 'playerResponse' of undefined

Describe the bug
.getVideo() function returns an undefined error.

To Reproduce
Steps to reproduce the behavior:

Note : I'm not writing all the code. I only write the part that needs to be corrected. I used three dots for the remaining parts.

  1. Client.js
    77 : if (!response.data[3].response.contents)
    79 : return (!response.data[2].playerResponse...

  2. BaseVideo.js
    58 : const secondaryContents = data[3].response.contents...
    100 : const contents = data[3].response.contents...
    104 : const videoDetails = data[2].playerResponse.videoDetails;

  3. Video.js
    39 : const itemSectionRenderer = data[3].response.contents...

Additional context
I think it's give error because something changed inside Youtube or the module used.

Client#options are missing

Describe the bug
Hey, seems you accidently removed the Client#options value from the Client class. Is that intended?

Uncaught (in promise) Error: incorrect header check

I am a noob developer simply trying to use youtubei to get search results. After struggling for days fighting CORS issues, I was able to disable chrome security and finally get some kind of reply other than a cors error. I am unsure if the error below is still due to a CORS as in the Network tab of Chrome Inspect I am able to see the search results but not print them in the console.

Furthermore, I am using Browserify to bundle the code.

Expected behavior
Produce an array of search results. The code works fine in the npm runkit. Was hoping to be pushed in the right direction as searching google has not returned much useful information as to Uncaught (in promise) Error: incorrect header check.

Screenshots
t7cIae3
9snGYeu

Support for IPv6

Is your feature request related to a problem? Please describe.
Not really, maybe ratelimits.

Describe the solution you'd like
I suggest adding IPv6 support, if you can't do it for now, I can work on it, as that could help me.

Additional context
None

youtubei Should handle 404 or private videos

Describe the bug
youtubei Should throw useful error messages or handle 404 / private videos

Currently using getVideo with non-existing video for example https://www.youtube.com/watch?v=not-exists or a private video
https://www.youtube.com/watch?v=mSBZvjbf7yM throws an error (see screenshot)

To Reproduce

const { Client } = require("youtubei");

const youtube = new Client();

youtube.getVideo("https://www.youtube.com/watch?v=not-exists"); // throws error
youtube.getVideo("https://www.youtube.com/watch?v=mSBZvjbf7yM"); // also throws errors

Expected behavior
youtubei Should throw useful error messages or just return undefined

Screenshots
image

Additional context
Hazmi35/jukebox#761

🚀Stable Release Roadmap

As you can see, this library is still in prerelease (-rc.*). When I started developing this library, I didn't expect to have this many rc versions.

While I don't have too much time to maintain this library (I will still fix major bugs immediately if exists), I'm still planning to publish a stable release ASAP.


Progress: #53


Some changes and additions to be made before I publish a stable release are:

  • Add Client#getChannel
  • Change Playlist#next to #Playlist#nextVideos
  • Add more params for Client#search
  • Make Client#search accepts continuation token
  • Add Client#getRelatedVideo (accepts continuation token)
  • Add Client#getComment (accepts continuation token)
  • Add CI/CD for NPM publishing
  • Add CI/CD for docs publishing
  • Resolve #11
  • Some code cleanup (this one is huge, I have internal list of what to refactor)

Migration Guide

List of breaking changes on v1:

  1. ChannelCompact renamed to BaseChannel
  2. Comment#isPinnedComment renamed to Comment#isPinned
  3. Client constructor parameters changes:
    1. cookie renamed to initialCookie
    2. requestOptions renamed to fetchOptions
    3. https removed
  4. Remove URL support from Client#getVideo and Client#getPlaylist, you will have to extract video / playlist id from URL string before passing it
  5. SearchResult replaced with SearchManager, and extending a Continuable (look below)
  6. Continuable implementations. All .next*() methods in all classes will be removed (e.g. Channel#nextVideos, Channel#nextPlaylists, or Video#nextComments), and the property used to store fetched data (e.g Channel.videos, Channel.playlists, or Video.comments) will be replaced with a Continuable. Instead of doing:
await channel.nextVideos();
await channel.nextPlaylists();
await video.nextComments();

console.log(channel.videos, channel.playlists, video.comments);

on v1:

await channel.videos.next();
await channel.playlists.next();
await video.comments.next();

console.log(channel.videos.items, channel.playlists.items, video.comments.items);

Better support for channel shelves

Originated from #39

Is your feature request related to a problem? Please describe.
Some shelves data are not available on channel.shelves (e.g alternate Channel)
image

Describe the solution you'd like
More complete data for channel shelves

[BUG] youtubei Should handle empty playlists

Describe the bug
youtubei Fails to extract information from an empty playlist

It throws "TypeError: Cannot read properties of undefined (reading '0')", located in youtubei/dist/classes/Playlist.js:34:45

To Reproduce
Steps to reproduce the behavior:

import { Client } from "youtubei";

const youtube = new Client();

client.getPlaylist("PLky9DvBorFRkMOKxobqEVz4C3tcUrEPku"); // Throws an error

Expected behavior
youtubei Should return the Playlist info with the "videos" property containing an empty array

Screenshots
None

Additional context
None

[BUG] — The last video of a playlist is missing

Describe the bug
The last video of all the playlist I tested is missing

My code

// —— I always tested on playlists with less than 30 items, and using ".next()" only returns an empty array
const test = await youtube.getPlaylist( query )

console.log( test.videoCount );
console.log( test.videos );

Screenshots

Capture d’écran 2021-09-13 à 05 50 42

Protobuf Endpoints?

Hey @SuspiciousLookingOwl,

First up - great work on Youtubei! We are currently looking at collecting some data from YouTube's API that seems to only be available via the mobile app at the moment. Did a little man-in-the-middle sniffing to see which requests are being sent, and they definitely all go to youtubei.googleapis.com/youtubei/v1/...

Unfortunately it looks like the content-encoding is different and they are using protobuf for the iOS apps instead of application/json. Do you think it is possible to either find the right .proto schemas for the protocol or convert the requests to json somehow? Please let me know!

All the best,
Oskar

Undefined sub count :(

Describe the bug
item.channel.subscriberCount returns undefined when searching for videos.

To Reproduce
Steps to reproduce the behavior:

const results = await client.search("Overwatch").then(items => {
    return items.forEach(item => {
        if (item.constructor.name === "VideoCompact") console.log({subCount: item.channel.subscriberCount});
    });
})
console.log(results);

Expected behavior
A clear and concise description of what you expected to happen.
Show me the sub counts instead of saying "undefined"

[BUG] Certain videos throw Uncaught Error originating in the Video.js load() method

Describe the bug
For certain videos being loaded by the client via the getVideo() method, an error occurs during the load() method of the video due to expected results from the Youtube API being in an unexpected index. As such, the code is searching for an undefined field, because the field is in a different index of the array.

To Reproduce
When creating a Client object and calling the getVideo() method with the following value as parameter videoIdOrUrl, "kzBx8TWcrG4", it will attempt to create a new instance of a Video object and call its load() method. During this load() method it will attempt to set this.commentContinuation with a sub property of contents[2].itemSectionRenderer.contents

For this example, the itemSectionRender property is actually in contents[3], and the existing code attempts to access a property of an undefined field, and as such errors out. Ideally, this should be altered such that it searches the indices of the array to find the correct index with the itemSectionRenderer property.

Expected behavior
I would expect that any youtube video should be able to run through this process and be loaded correctly. It should search for the itemSelectionRenderer property in whatever index of the array it exists in.

Screenshots
Below is a screenshot of the contents array mentioned above. You can see that the itemSectionRenderer property is actually in index 3 instead of index 2.
image

Below is a screenshot of the load() method in question. This is in classes/Video.js, and you can see the contents array highlighted
image

Below is a screenshot of the load() method which I slightly altered to allow for this scenario to work. By wrapping it in a try/catch and checking index 3 on a failure, I did get this video to work. Ideally, this should be fixed to accommodate the value coming from any index?
image

Additional context
This is the exact Youtube Video I was testing with to produce this error:
https://www.youtube.com/watch?v=kzBx8TWcrG4&ab_channel=-MichaelGhelfi-RPGAudio

I believe this error may have something to do with newer merchandise functionality on youtube videos, based on the "merchandiseShelfRender" being in index 2 of the array in this example. You may even be able to replicate this with other videos with the merchandise shelf.

I found this error because the youtubei module is a dependency of the "discord-music-player" which I am using for a discord bot. I was able to trace the error I was dealing with down to the code above. If you want to fix this, and have any questions feel free to reach out!

Thank you for maintaining this great module :)

v1 Migration Guide

v1 is now finally on RC!

The 0-rc version won't be maintained anymore.

New v1 docs: https://suspiciouslookingowl.github.io/youtubei

Migration Guide

List of breaking changes on v1:

  1. youtubei now requires Node version >= 16
  2. ChannelCompact renamed to BaseChannel
  3. Comment#isPinnedComment renamed to Comment#isPinned
  4. Client constructor parameters changes:
    1. cookie renamed to initialCookie
    2. requestOptions changed to fetchOptions (which is a node-fetch request options)
    3. https removed
  5. Remove URL support from Client#getVideo and Client#getPlaylist, you will have to extract video / playlist id from URL string before passing it
  6. SearchResult now is a Continuable (look below)
  7. Continuable implementations. All .next*() methods in all classes will be removed (e.g. Channel#nextVideos, Channel#nextPlaylists, or Video#nextComments), and the property used to store fetched data (e.g Channel.videos, Channel.playlists, or Video.comments) will be replaced with a Continuable. Instead of doing:
await channel.nextVideos();
await channel.nextPlaylists();
await video.nextComments();

console.log(channel.videos, channel.playlists, video.comments);

on v1:

await channel.videos.next();
await channel.playlists.next();
await video.comments.next();

console.log(channel.videos.items, channel.playlists.items, video.comments.items);

[BUG] Comment URL was build wrong

Describe the bug
The Comment URL generated is wrong

Let's se a comment URL generated by youtubei:
https://www.youtube.com?watch=dQw4w9WgXcQ&lc=Ugy-gzZqIURUOZXa3JB4AaABA

It is build by the following sequence:
youtube + ? + watch + = + videoId + = + commentId

And the url build by clicking on youtube comment date is:
youtube + /watch + ? + v= + videoId + &lc= + commentId

Resulting in the following url:
https://www.youtube.com/watch?v=dQw4w9WgXcQ&lc=Ugy-gzZqIURUOZXa3JB4AaABAg

To Reproduce
Just get the URL from video comment

Expected behavior
The URL should open the Youtube video with the comment highlighted.

[BUG] Client#search errors when no results exist

Describe the bug
When passing a query into Client#search that produces no results, the following error is thrown:

TypeError: Cannot read property 'continuationItemRenderer' of undefined
    at SearchResult.loadSearchResult (/Users/inquire_kinect/VSC/Repos/TommyBot/node_modules/.pnpm/[email protected]/node_modules/youtubei/dist/classes/SearchResult.js:107:19)
    at SearchResult.<anonymous> (/Users/inquire_kinect/VSC/Repos/TommyBot/node_modules/.pnpm/[email protected]/node_modules/youtubei/dist/classes/SearchResult.js:63:18)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/inquire_kinect/VSC/Repos/TommyBot/node_modules/.pnpm/[email protected]/node_modules/youtubei/dist/classes/SearchResult.js:11:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

To Reproduce

const YTI = require("youtubei")
const yt = new YTI.Client()

yt.search("ewiqur6iuwraflojksadbvasadfgshp2sr")
  .then(console.log, console.error)

Expected behavior
What should happen instead is that either an empty array or null should be returned.

Cannot read properties of undefined (reading 'map')

Node version: 16.16.0

Searching for

official audio lyrics Eliza Rose, Interplanetary Criminal B.O.T.A. (Baddest Of Them All) - Edit

or

official audio lyrics Solardo, Vintage Culture, LOWES Adidas & Pearls

results in the following error:

C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\VideoCompact\VideoCompactParser.js:16
            (detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs.map((r) => r.text).join("")) || "";
                                                                                                                                              ^

TypeError: Cannot read properties of undefined (reading 'map')
    at Function.loadVideoCompact (C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\VideoCompact\VideoCompactParser.js:16:143)
    at VideoCompact.load (C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\VideoCompact\VideoCompact.js:32:49)
    at Function.parseSearchResult (C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\SearchResult\SearchResultParser.js:33:75)
    at Function.parseInitialSearchResult (C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\SearchResult\SearchResultParser.js:13:38)
    at SearchResult.<anonymous> (C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\SearchResult\SearchResult.js:65:88)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Trike\Documents\Projects\lucille-bot-dev\node_modules\youtubei\dist\cjs\classes\SearchResult\SearchResult.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

getVideo() method returns undefined for every input

Describe the bug
The getVideo() method currently returns undefined for every case (presumably due to a restructure in response data?)

To Reproduce
Use getVideo() in any way, even the example code breaks.

Expected behavior
A video containing the metadata is returned.

Additional context
I was able to fix the issue myself by just removing all the [3]s and [2]s after 'data' in every relevant file. Seems to work fine now.

[ENHANCEMENT] Add `Channel.posts`

Is your feature request related to a problem? Please describe.
Currently it's not possible to get channel's community post

Describe the solution you'd like
add BaseChannel.posts

const posts = await channel.posts.next();

Some Channels throw error: "Cannot read property 'items' of undefined"

Describe the bug
A clear and concise description of what the bug is.
Some channels such as PewDiePie throw error.

(node:18860) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'items' of undefined
    at Channel.load (E:\WatchSquad\server\node_modules\youtubei\dist\classes\Channel.js:46:58)
    at Client.<anonymous> (E:\WatchSquad\server\node_modules\youtubei\dist\classes\Client.js:93:53)
    at Generator.next (<anonymous>)
    at fulfilled (E:\WatchSquad\server\node_modules\youtubei\dist\classes\Client.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18860) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18860) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce
Steps to reproduce the behavior:

// PewDiePie Channel ID is used.
client.getChannel("UC-lHJZR3Gqxm24_Vd_AJ5Yw").then(res => {
    console.log(res)
})

Expected behavior
A clear and concise description of what you expected to happen.
Should return Channel object.

Issue with getPlaylist returning wrong VideoCompact#channel object

Describe the bug
Playlist object that contains the VideoCompact returned by getPlaylist() method shows wrong channel information.

To Reproduce

  1. Send a request via getPlaylist(),
  2. Observe the Playlist#videos returning wrong channel data.

Expected behavior
It should return the Video channel object, not the Playlist channel object.

[ENHANCEMENT] Channel Subscribers Count

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
I would like to get the channel subscribers count.

Describe alternatives you've considered
Exploring the channel result

Additional context
No aplicable

WebUrl

Hello, I was wondering if there is a web URL that can be called upon to get results from the API, and if so, what is it?

Videos not available in topic channels

Describe the bug
The channel.videos.items property doesn't change after calling the channel.videos.items.next() method.

To Reproduce
Get a topic channel's id like UCRY5dYsbIN5TylSbd7gVnZg

const channelInfo = await youtube.getChannel(channelId);

console.log(channelInfo?.videos.items); // []
await channelInfo?.videos.next();
console.log(channelInfo?.videos.items); // still []

Expected behavior
console.log(channelInfo?.videos.items); should log videos' information

Cannot read property 'continuations' of undefined

Describe the bug
An error occurs due to the deficiency in the part of receiving the data of the live broadcasts in the module.

this.chatContinuation =
            data[3].response.contents.twoColumnWatchNextResults.conversationBar.liveChatRenderer.continuations[0].reloadContinuationData.continuation;

The chat section can be turned off in Youtube live broadcasts. The system gives an error because it cannot receive the chat data.

To Reproduce
Steps to reproduce the behavior:

  1. If the chat section is closed, it should be returned as null

If the chat section is closed, the response should be like this

 watchingCount: 1000,
 chatContinuation: null

Expected behavior
Data that cannot be received (chatContinuation) should be sent as null so that the system does not malfunction. So the system will work better.

Get video length

Is your feature request related to a problem? Please describe.
I would like to get the length of a video

Describe the solution you'd like
A lengthSeconds key in the video object would be great

Describe alternatives you've considered
Manually making the request?

Cannot read property '0' of undefined [BUG]

Describe the bug
For some reason I can only play one song, when I try to find another it gives me an error.
The song is Panini by Lil Nas X

Expected behavior
Search the songs and receive no error.

Screenshots
Error
image
Usage
code

Additional context
Youtubei Version: [0.0.1-rc.16]
Node.js Version: [14.16.1]
Discord.js Version: [12.3.1]

how stable do you think the internal API will be?

First off, congratulations on what looks like a promising project. I'm currently working on creating a pipeline for scraping YouTube data for research projects, and since the YouTube API quotas are laughably tiny in that context, this is quickly shaping up to be one of my favourite packages.

I do have some questions...

You describe using an internal API, and I've noticed that you're using a key that presumably was dug up with some clever youtube archaeology. Considering this is far from an officially endorsed product, how stable do you expect the API to be?

  • Have you experienced any rate-limiting or IP bans in development?
  • From your experience with yt-scrape, how aggressive do you expect YouTube will be in trying to block this tool?
  • How successful do you expect to be in keeping the package working?

And as the success of this project could play a large role in the creation of a data pipeline for our research projects;

  • Is there anything I can do to help with development, testing or documentation?

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.