SuspiciousLookingOwl / youtubei

Get Youtube data such as videos, playlists, channels, video information & comments, related videos, up next video, and more!
https://suspiciouslookingowl.github.io/youtubei
MIT License
240 stars 50 forks source link

Allow settings custom headers during request #51

Closed musso closed 2 years ago

musso commented 2 years ago

Currently, the new Client() allows to pass a custom requestOptions to construct the request object, however, it is not used in get and post request in src/common/HTTP.ts.

SuspiciousLookingOwl commented 2 years ago

I will probably fix this in stable release. I'm planning to just use node-fetch for the HTTP client, so my code will requires some refactoring

SuspiciousLookingOwl commented 2 years ago

This should be fixed in v1, but if the issue still persists, fill free to reopen the issue.

The way to do this on v1:

import { Client } from "youtubei";

const client = new Client({
    fetchOptions: {
        headers: {
            example: "abc",
        },
    },
});

client.search("foo");

(Also check the v1 migration guide)