YouTube.js: 4.0.1 `InnertubeError: Streaming data not available`

Steps to reproduce

Try to get streaming data for https://music.youtube.com/watch?v=-mhgfXgwdls

Failure Logs

InnertubeError: Streaming data not available
    at FormatUtils.chooseFormat (C:\Git\youtube-music\node_modules\youtubei.js\bundle\node.cjs:12763:13)
    at TrackInfo.chooseFormat (C:\Git\youtube-music\node_modules\youtubei.js\bundle\node.cjs:13140:32)
    at run (C:\Git\youtube-music\test_download.js:24:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  date: 2023-03-22T20:40:47.162Z,
  version: '4.0.1'
}

Expected behavior

I have a nice alt-j song in my folder

Current behavior

Stream is hiding from me

Version

Default

Anything else?

To reproduce

const { Innertube, UniversalCache, Utils } = require("youtubei.js");

const { stdout } = require("process");
const { createWriteStream } = require("fs");

const run = async () => {
	const yt = await Innertube.create({
		cache: new UniversalCache(false),
		generate_session_locally: true,
	});

  const workingId = "Vu0nRz_bQ0Y";
  // https://music.youtube.com/watch?v=-mhgfXgwdls
  const brokenId = "-mhgfXgwdls";

	const info = await yt.music.getInfo(brokenId);

	console.log(`Downloading ${info.basic_info.title}, info.streaming_data = ${info.streaming_data}`);

	const options = {
		type: "audio",
		quality: "best",
		format: "mp4",
	};

	const format = info.chooseFormat(options);
	const stream = await info.download(options);

	const file = createWriteStream("./test_song.m4a");

	const total = format.content_length;
	let downloaded = 0;

	for await (const chunk of Utils.streamToIterable(stream)) {
		file.write(chunk);

		downloaded += chunk.length;

		stdout.write(`${Math.round((downloaded / total) * 100)}%`);
		stdout.cursorTo?.(0);
	}

	stdout.clearLine?.(0);
	stdout.write("Done!");
};

run();

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Yes, that’ll be why then. As we create a new session for everything, we have the luxury of being able to create a new one with different params.

revelant bits of code: https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/helpers/api/local.js#L122-L146 https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/helpers/api/local.js#L28-L46

Well this was great. I learned how to bypass stuff, and we found and fixed a new bug. great issue đŸ˜ƒ

That’s happening because you are mutating the original result and passing that to the download function, instead of the bypassed one.

You can check the playability status yourself, between getting the info and choosing the format.