Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): workaround streaming URLs returning 403 #390

Merged
merged 1 commit into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/core/endpoints/PlayerEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export const PATH = '/player';
* @returns The payload.
*/
export function build(opts: PlayerEndpointOptions): IPlayerRequest {
const is_android =
opts.client === 'ANDROID' ||
opts.client === 'YTMUSIC_ANDROID' ||
opts.client === 'YTSTUDIO_ANDROID';

return {
playbackContext: {
contentPlaybackContext: {
Expand All @@ -33,7 +38,9 @@ export function build(opts: PlayerEndpointOptions): IPlayerRequest {
videoId: opts.video_id,
...{
client: opts.client,
playlistId: opts.playlist_id
playlistId: opts.playlist_id,
// Workaround streaming URLs returning 403 when using Android clients.
params: is_android ? '8AEB' : opts.params
}
};
}
7 changes: 6 additions & 1 deletion src/types/Endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export interface IPlayerRequest {
videoId: string;
racyCheckOk: boolean;
contentCheckOk: boolean;
client?: InnerTubeClient;
playlistId?: string;
params?: string;
client?: InnerTubeClient;
}

export type PlayerEndpointOptions = {
Expand All @@ -44,6 +45,10 @@ export type PlayerEndpointOptions = {
* The playlist ID.
*/
playlist_id?: string;
/**
* Additional protobuf parameters.
*/
params?: string;
}

export type NextEndpointOptions = {
Expand Down