Compare commits

...

3 Commits

Author SHA1 Message Date
LuanRT
398cd8728d 1.3.6 2022-03-07 19:30:14 -03:00
LuanRT
459c30528e fix: decipher n param only if necessary 2022-03-07 19:29:39 -03:00
LuanRT
6e1e96610c docs: fix table of contents 2022-03-07 19:25:09 -03:00
4 changed files with 20 additions and 15 deletions

View File

@@ -49,17 +49,17 @@ npm install youtubei.js
## Usage
[1. Getting Started](https://github.com/LuanRT/YouTube.js#usage)
[1. Getting Started](#usage)
[2. Interactions](https://github.com/LuanRT/YouTube.js#interactions)
[2. Interactions](#interactions)
[3. Live chats](https://github.com/LuanRT/YouTube.js#fetching-live-chats)
[3. Live chats](#fetching-live-chats)
[4. Downloading videos](https://github.com/LuanRT/YouTube.js#downloading-videos)
[4. Downloading videos](#downloading-videos)
[5. Signing-in](https://github.com/LuanRT/YouTube.js#signing-in)
[5. Signing-in](#signing-in)
[6. Disclaimer](https://github.com/LuanRT/YouTube.js#disclaimer)
[6. Disclaimer](#disclaimer)
First of all we're gonna start by initializing the Innertube instance.
And to make things faster, you should do this only once and reuse the Innertube object when needed.
@@ -761,7 +761,7 @@ async function start() {
const search = await youtube.search('Looking for life on Mars - documentary');
const stream = youtube.download(search.videos[0].id, {
format: 'mp4', // Optional, ignored when type is set to audio and defaults to mp4, and I recommend to leave it as it is
format: 'mp4', // Optional, defaults to mp4 and I recommend to leave it as it is unless you know what you're doing
quality: '360p', // if a video doesn't have a specific quality it'll fall back to 360p, also ignored when type is set to audio
type: 'videoandaudio' // can be “video”, “audio” and “videoandaudio”
});

View File

@@ -657,7 +657,10 @@ class Innertube {
const url_components = new URL(format.url);
url_components.searchParams.set('cver', this.context.client.clientVersion);
url_components.searchParams.set('ratebypass', 'yes');
url_components.searchParams.set('n', new NToken(this.#player.ntoken_sc).transform(url_components.searchParams.get('n')));
if (url_components.searchParams.get('n')) {
url_components.searchParams.set('n', new NToken(this.#player.ntoken_sc).transform(url_components.searchParams.get('n')));
}
format.url = url_components.toString();
format.has_audio = !!format.audioBitrate || !!format.audioQuality;

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "youtubei.js",
"version": "1.3.5",
"version": "1.3.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "youtubei.js",
"version": "1.3.0",
"version": "1.3.6",
"license": "MIT",
"dependencies": {
"axios": "^0.21.4",

View File

@@ -1,12 +1,13 @@
{
"name": "youtubei.js",
"version": "1.3.5",
"version": "1.3.6",
"description": "An object-oriented library that allows you to search, get detailed info about videos, subscribe, unsubscribe, like, dislike, comment, download videos and much more!",
"main": "index.js",
"scripts": {
"test": "node test"
},
"author": "LuanRT",
"funding": "https://ko-fi.com/luanrt",
"license": "MIT",
"directories": {
"example": "examples",
@@ -24,6 +25,7 @@
},
"keywords": [
"yt",
"ytdl",
"youtube",
"youtube-dl",
"youtubedl",
@@ -31,13 +33,13 @@
"innertube",
"innertubeapi",
"livechat",
"dl",
"api",
"like",
"downloader",
"dislike",
"search",
"comment",
"downloader"
"like",
"api",
"dl"
],
"bugs": {
"url": "https://github.com/LuanRT/YouTube.js/issues"