diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98461075..c103f1a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,16 +3,16 @@ Thank you for taking the time to contribute! The following is a set of guidelines for contributing to YouTube.js. ___ -* [Issues](#issues) - * [Create a new issue](#issue-1) - * [Solve an issue](#issue-2) - -* [Make changes](#changes) - * [Commit your updates](#changes-1) - * [Create a PR](#changes-2) - * [Run tests](#test) - * [Lint your code](#lint) - * [Build](#build) +- [Contributing to YouTube.js](#contributing-to-youtubejs) + - [Issues](#issues) + - [Create a new issue](#create-a-new-issue) + - [Solve an issue](#solve-an-issue) + - [Make changes](#make-changes) + - [Commit your updates](#commit-your-updates) + - [Pull Request](#pull-request) + - [Test](#test) + - [Lint](#lint) + - [Build](#build) ## Issues @@ -66,16 +66,26 @@ npm run lint:fix #### Build ```bash -# Node -npm run build:node - -# Browser -npm run build:browser -npm run build:browser:prod +# Build all +npm run build # Protobuf npm run build:proto # Parser map npm run build:parser-map + +# Deno +npm run build:deno + +# ES Module +npm run build:esm + +# Node +npm run bundle:node + +# Browser +npm run bundle:browser +npm run bundle:browser:prod + ``` \ No newline at end of file diff --git a/README.md b/README.md index 6b08ce16..000ec116 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ YouTube.js supports streaming of videos in the browser by converting YouTube's s The example below uses [`dash.js`](https://github.com/Dash-Industry-Forum/dash.js) to play the video. ```ts -import { Innertube } from 'youtubei.js'; +import { Innertube } from 'youtubei.js/web'; import dashjs from 'dashjs'; const youtube = await Innertube.create({ /* setup - see above */ }); @@ -210,7 +210,7 @@ Our cache uses the `node:fs` module in Node-like environments, `Deno.writeFile` import { Innertube, UniversalCache } from 'youtubei.js'; // By default, cache stores files in the OS temp directory (or indexedDB in browsers). const yt = await Innertube.create({ - cache: new UniversalCache() + cache: new UniversalCache(false) }); // You may wish to make the cache persistent (on Node and Deno) diff --git a/examples/auth/index.js b/examples/auth/index.js index 9953ab30..b6f2c70d 100644 --- a/examples/auth/index.js +++ b/examples/auth/index.js @@ -3,7 +3,7 @@ const { Innertube, UniversalCache } = require('youtubei.js'); (async () => { const yt = await Innertube.create({ // required if you wish to use OAuth#cacheCredentials - cache: new UniversalCache() + cache: new UniversalCache(false) }); // 'auth-pending' is fired with the info needed to sign in via OAuth. diff --git a/examples/browser/README.md b/examples/browser/README.md index 477c2ce3..960ee6b3 100644 --- a/examples/browser/README.md +++ b/examples/browser/README.md @@ -9,7 +9,7 @@ To use YouTube.js in the browser you must proxy requests through your own server We'll use our own fetch implementation to proxy requests through our server. This is a simple example, but you can use any fetch implementation you want. ```ts -import { Innertube } from "youtubei.js/build/browser"; +import { Innertube } from "youtubei.js/web.bundle.min"; const yt = await Innertube.create({ fetch: async (input, init) => { diff --git a/examples/channel/basic-info.ts b/examples/channel/basic-info.ts index 1ff87dc9..60ec97dd 100644 --- a/examples/channel/basic-info.ts +++ b/examples/channel/basic-info.ts @@ -1,7 +1,7 @@ import { Innertube, UniversalCache, YTNodes } from 'youtubei.js'; (async () => { - const yt = await Innertube.create({ cache: new UniversalCache(), generate_session_locally: true }); + const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true }); const channel = await yt.getChannel('UCX6OQ3DkcsbYNE6H8uQQuVA'); diff --git a/examples/comments/index.ts b/examples/comments/index.ts index 171ef8bd..39a07aa6 100644 --- a/examples/comments/index.ts +++ b/examples/comments/index.ts @@ -1,7 +1,7 @@ import { Innertube, UniversalCache } from 'youtubei.js'; (async () => { - const yt = await Innertube.create({ cache: new UniversalCache(), generate_session_locally: true }); + const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true }); const comment_section = await yt.getComments('a-rqu-hjobc'); diff --git a/examples/deno/index.ts b/examples/deno/index.ts index 38605ed0..9f14677d 100644 --- a/examples/deno/index.ts +++ b/examples/deno/index.ts @@ -1,4 +1,4 @@ -import { Innertube } from '../../bundle/browser.js'; +import { Innertube } from 'https://deno.land/x/youtubei/deno.ts'; const yt = await Innertube.create(); diff --git a/examples/download/index.ts b/examples/download/index.ts index 76e73ce5..9b59a04a 100644 --- a/examples/download/index.ts +++ b/examples/download/index.ts @@ -1,9 +1,8 @@ -import { Innertube, UniversalCache } from 'youtubei.js'; -import { readFileSync, existsSync, mkdirSync, createWriteStream } from 'fs'; -import { streamToIterable } from 'youtubei.js/dist/src/utils/Utils'; +import { Innertube, UniversalCache, Utils } from 'youtubei.js'; +import { existsSync, mkdirSync, createWriteStream } from 'fs'; (async () => { - const yt = await Innertube.create({ cache: new UniversalCache(), generate_session_locally: true }); + const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true }); const search = await yt.music.search('No Copyright Background Music', { type: 'album' }); @@ -34,7 +33,7 @@ import { streamToIterable } from 'youtubei.js/dist/src/utils/Utils'; const file = createWriteStream(`${dir}/${song.title?.replace(/\//g, '')}.m4a`); - for await (const chunk of streamToIterable(stream)) { + for await (const chunk of Utils.streamToIterable(stream)) { file.write(chunk); } diff --git a/examples/livechat/index.ts b/examples/livechat/index.ts index bbe5a325..75b5ab04 100644 --- a/examples/livechat/index.ts +++ b/examples/livechat/index.ts @@ -1,9 +1,8 @@ -import { Innertube, UniversalCache, YTNodes } from 'youtubei.js'; -import { LiveChatContinuation } from 'youtubei.js/dist/src/parser'; +import { Innertube, UniversalCache, YTNodes, LiveChatContinuation } from 'youtubei.js'; import { ChatAction, LiveMetadata } from 'youtubei.js/dist/src/parser/youtube/LiveChat'; (async () => { - const yt = await Innertube.create({ cache: new UniversalCache(), generate_session_locally: true }); + const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true }); const search = await yt.search('lofi hip hop radio - beats to relax/study to'); const info = await yt.getInfo(search.videos[0].as(YTNodes.Video).id); diff --git a/examples/upload/index.ts b/examples/upload/index.ts index 86c7b173..eab4f393 100644 --- a/examples/upload/index.ts +++ b/examples/upload/index.ts @@ -5,7 +5,7 @@ const creds_path = './my_yt_creds.json'; const creds = existsSync(creds_path) ? JSON.parse(readFileSync(creds_path).toString()) : undefined; (async () => { - const yt = await Innertube.create({ cache: new UniversalCache() }); + const yt = await Innertube.create({ cache: new UniversalCache(false) }); yt.session.on('auth-pending', (data: any) => { console.info(`Hello!\nOn your phone or computer, go to ${data.verification_url} and enter the code ${data.user_code}`);