YouTube.js: Better error message when using certain APIs with unsupported ClientType

Steps to reproduce

import { writeFileSync } from 'fs';
import { Innertube, ClientType } from 'youtubei.js';

(async () => {
    const yt = await Innertube.create({
        client_type: ClientType.WEB
    });
    const videoInfo = await yt.getInfo('y9n6HkftavM');    

    const manifest = await videoInfo.toDash(undefined, undefined, { include_thumbnails: false });
    writeFileSync('manifest.mpd', manifest);
  })();
node dash.js

This works. Set it to ClientType.ANDROID, ClientType.IOS or ClientType.TV_EMBEDDED then it does not

Failure Logs

InnertubeError: Request to https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false&alt=json failed with status 404
    at HTTPClient.<anonymous> (file:///Users/brahim/Roku/YouTube.js/dist/src/utils/HTTPClient.js:99:19)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/brahim/Roku/YouTube.js/node_modules/tslib/tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  info: '{\n' +
    '  "error": {\n' +
    '    "code": 404,\n' +
    '    "message": "Requested entity was not found.",\n' +
    '    "errors": [\n' +
    '      {\n' +
    '        "message": "Requested entity was not found.",\n' +
    '        "domain": "global",\n' +
    '        "reason": "notFound"\n' +
    '      }\n' +
    '    ],\n' +
    '    "status": "NOT_FOUND"\n' +
    '  }\n' +
    '}\n',
  date: 2023-12-09T15:50:17.497Z,
  version: '8.0.0'
}

Expected behavior

For different clients to be able to pull video info and generate dash manifest

Current behavior

Only WEB seems to work

Version

Edge

Anything else?

No response

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: open
  • Created 7 months ago
  • Reactions: 1
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Will likely require throwing errors in most methods if a client isn’t the web one. Not great, but at least people will know that they are doing unsupported stuff, instead of being confused by other errors.