Skip to content

Commit

Permalink
chore(docs): fix download example
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Sep 6, 2022
1 parent e3d483e commit ddbf9e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/download/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Innertube, UniversalCache } from 'youtubei.js';
import { readFileSync, existsSync, mkdirSync, createWriteStream } from 'fs';
import { streamToIterable } from 'youtubei.js/dist/src/utils/Utils';

(async () => {
const yt = await Innertube.create({ cache: new UniversalCache() });
Expand Down Expand Up @@ -32,7 +33,7 @@ import { readFileSync, existsSync, mkdirSync, createWriteStream } from 'fs';
}

const file = createWriteStream(`${dir}/${song.title?.replace(/\//g, '')}.m4a`);

for await (const chunk of streamToIterable(stream)) {
file.write(chunk);
}
Expand Down

0 comments on commit ddbf9e9

Please sign in to comment.