baptistearno / node-youtube-music Goto Github PK
View Code? Open in Web Editor NEWUnofficial YouTube Music API for Node.js
License: GNU General Public License v3.0
Unofficial YouTube Music API for Node.js
License: GNU General Public License v3.0
i've been getting these errors everytime i try to normally require the module, probably due to a broken esm
const { searchMusics } = require('node-youtube-music');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\User\Desktop\Recycle Bin\lucspyt\node_modules\node-youtube-music\dist\index.js from C:\Users\User\Desktop\Recycle Bin\lucspyt\index.js not supported.
Instead change the require of ...\node_modules\node-youtube-music\dist\index.js in ...\index.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (...\index.js:7:26) {
code: 'ERR_REQUIRE_ESM'
}
luckily, i found a work-around with fix-esm:
const { searchMusics } = require("fix-esm").require('node-youtube-music');
searchMusics("Bound 2 - Kanye West")
.then(function(data) {
console.log(`https://www.youtube.com/watch?v=${data[0].youtubeId}`); //output should be https://www.youtube.com/watch?v=5gjKuISTMRE
});
TypeError: ytMusic.searchMusics is not a function
Thanks.
Your package is awesome, but i get error when running my project after install this package.
Error [ERR_REQUIRE_ESM]: require() of ES Module....not supported.
Version:
{
"node-youtube-music": "^0.9.0"
}
Hey, thanks for creating this amazing API. I have some issues with searching playlists, do you mind taking a look?
TypeError: Cannot destructure property 'contents' of 'body.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicShelfRenderer' as it is undefined.
Hello, I encounter non-result search when I use this API on my server. Anyone has an idea why ?
The search function returns same data as artist for album
It seems to not be able to parse YouTube's response anymore. Here is what getSuggestions(id)
returns for Stronger by Kanye:
[
{
youtubeId: '2ulp_AMut14',
title: 'Stronger',
artists: [ [Object] ],
isExplicit: true,
album: 'Graduation',
thumbnailUrl: 'https://lh3.googleusercontent.com/LENzUxyoVSRKUEZrw6nG5cOajuDDnFaIQIbD3LW95HaLLNOW4IHHvpGl0nmCoyFpiQE93jtT2FJTJk2Oqg=w544-h544-l90-rj',
duration: { label: '5:12', totalSeconds: 312 }
},
{
youtubeId: undefined,
title: undefined,
artists: undefined,
isExplicit: false,
album: undefined,
thumbnailUrl: undefined,
duration: undefined
}
]
There are also many warnings printed to the console, saying that it can't retrieve any of the attributes.
Specs don't pass: https://github.com/baptisteArno/node-youtube-music/runs/4148763353
Albums tests don't pass, maybe Youtube Music API changed a bit.
Ping @imLinguin
I got the error
npm ERR! Cannot read property 'version' of undefined
As I mentioned before songsPlaylistId isn't always defined. Also when artist has less than 5 songs songsPlaylistId isn't there too. I was thinking about featuredSongs, which would contain 5 or less songs listed in Songs section. There would be one caveat: API doesn't provide a duration of these songs.
What else should I add?
`node:internal/process/esm_loader:97
internalBinding('errors').triggerUncaughtException(
^
HTTPError: Response code 400 (Bad Request)
at Request. (C:\Users\obi_c\Desktop\project\music-test-node\node_modules\got\dist\source\as-promise\index.js:118:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1670437178318,
socket: 1670437178319,
lookup: 1670437178320,
connect: 1670437178383,
secureConnect: 1670437178462,
upload: 1670437178462,
response: 1670437178534,
end: 1670437178537,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 1,
tcp: 63,
tls: 79,
request: 0,
firstByte: 72,
download: 3,
total: 219
}
}
}`
{
"code": "ERR_NON_2XX_3XX_RESPONSE",
"timings": {
"start": 1699121342335,
"socket": 1699121342336,
"lookup": 1699121342336,
"connect": 1699121342375,
"secureConnect": 1699121342472,
"upload": 1699121342473,
"response": 1699121342596,
"end": 1699121342598,
"phases": {
"wait": 1,
"dns": 0,
"tcp": 39,
"tls": 97,
"request": 1,
"firstByte": 123,
"download": 2,
"total": 263
}
},
"name": "HTTPError",
"options": {
"agent": {},
"decompress": true,
"timeout": {},
"prefixUrl": "",
"body": "{"context":{"capabilities":{},"client":{"clientName":"WEB_REMIX","clientVersion":"0.1"}},"browseId":"https://www.youtube.com/watch?v=UCDxKh1gFWeYsqePvgVzmPoQ}\"}",
"ignoreInvalidCookies": false,
"context": {},
"hooks": {
"init": [],
"beforeRequest": [],
"beforeError": [],
"beforeRedirect": [],
"beforeRetry": [],
"afterResponse": []
},
"followRedirect": true,
"maxRedirects": 10,
"throwHttpErrors": true,
"username": "",
"password": "",
"http2": false,
"allowGetBody": false,
"headers": {
"user-agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
"accept-language": "en",
"origin": "https://music.youtube.com",
"content-type": "application/json",
"content-length": "160",
"accept-encoding": "gzip, deflate, br"
},
"methodRewriting": false,
"retry": {
"limit": 2,
"methods": [
"GET",
"PUT",
"HEAD",
"DELETE",
"OPTIONS",
"TRACE"
],
"statusCodes": [
408,
413,
429,
500,
502,
503,
504,
521,
522,
524
],
"errorCodes": [
"ETIMEDOUT",
"ECONNRESET",
"EADDRINUSE",
"ECONNREFUSED",
"EPIPE",
"ENOTFOUND",
"ENETUNREACH",
"EAI_AGAIN"
],
"backoffLimit": null,
"noise": 100
},
"method": "POST",
"cacheOptions": {},
"https": {},
"resolveBodyOnly": false,
"isStream": false,
"responseType": "text",
"url": "https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",
"pagination": {
"countLimit": null,
"backoff": 0,
"requestLimit": 10000,
"stackAllItems": false
},
"setHost": true,
"enableUnixSockets": true
}
}
geting thsi error
I assume that the API key used to query youtube music is hard coded here. It would be better to have a configurable API key so that any one can use their Youtube Data API key to search music.
Hello, I suggest you to add a license to this project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.