Fix fetching info outside of Europe for videos with tagged as inappropriate or offensive
This commit is contained in:
parent
08d92d6026
commit
8bdebe1180
@ -65,7 +65,7 @@ interface VideoOptions {
|
|||||||
/**
|
/**
|
||||||
* `true` if the video has been identified by the YouTube community as inappropriate or offensive to some audiences and viewer discretion is advised
|
* `true` if the video has been identified by the YouTube community as inappropriate or offensive to some audiences and viewer discretion is advised
|
||||||
*/
|
*/
|
||||||
discretionAdvised: boolean;
|
discretionAdvised?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Class for YouTube Video url
|
* Class for YouTube Video url
|
||||||
@ -134,7 +134,7 @@ export class YouTubeVideo {
|
|||||||
/**
|
/**
|
||||||
* `true` if the video has been identified by the YouTube community as inappropriate or offensive to some audiences and viewer discretion is advised
|
* `true` if the video has been identified by the YouTube community as inappropriate or offensive to some audiences and viewer discretion is advised
|
||||||
*/
|
*/
|
||||||
discretionAdvised: boolean;
|
discretionAdvised?: boolean;
|
||||||
/**
|
/**
|
||||||
* Constructor for YouTube Video Class
|
* Constructor for YouTube Video Class
|
||||||
* @param data JSON parsed data.
|
* @param data JSON parsed data.
|
||||||
@ -161,7 +161,7 @@ export class YouTubeVideo {
|
|||||||
this.live = !!data.live;
|
this.live = !!data.live;
|
||||||
this.private = !!data.private;
|
this.private = !!data.private;
|
||||||
this.tags = data.tags || [];
|
this.tags = data.tags || [];
|
||||||
this.discretionAdvised = !!data.discretionAdvised;
|
this.discretionAdvised = data.discretionAdvised === undefined ? undefined : data.discretionAdvised;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Converts class to title name of video.
|
* Converts class to title name of video.
|
||||||
|
|||||||
@ -145,12 +145,14 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
);
|
);
|
||||||
discretionAdvised = true;
|
discretionAdvised = true;
|
||||||
const cookies =
|
const cookies =
|
||||||
initial_response.topbar.desktopTopbarRenderer.interstitial.consentBumpV2Renderer.agreeButton
|
initial_response.topbar.desktopTopbarRenderer.interstitial?.consentBumpV2Renderer.agreeButton
|
||||||
.buttonRenderer.command.saveConsentAction;
|
.buttonRenderer.command.saveConsentAction;
|
||||||
|
if (cookies) {
|
||||||
Object.assign(cookieJar, {
|
Object.assign(cookieJar, {
|
||||||
VISITOR_INFO1_LIVE: cookies.visitorCookie,
|
VISITOR_INFO1_LIVE: cookies.visitorCookie,
|
||||||
CONSENT: cookies.consentCookie
|
CONSENT: cookies.consentCookie
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const updatedValues = await acceptViewerDiscretion(vid.videoId, cookieJar, body, true);
|
const updatedValues = await acceptViewerDiscretion(vid.videoId, cookieJar, body, true);
|
||||||
player_response.streamingData = updatedValues.streamingData;
|
player_response.streamingData = updatedValues.streamingData;
|
||||||
@ -270,12 +272,14 @@ export async function video_stream_info(url: string, options: InfoOptions = {}):
|
|||||||
if (!initial_data) throw new Error('Initial Response Data is undefined.');
|
if (!initial_data) throw new Error('Initial Response Data is undefined.');
|
||||||
|
|
||||||
const cookies =
|
const cookies =
|
||||||
JSON.parse(initial_data).topbar.desktopTopbarRenderer.interstitial.consentBumpV2Renderer.agreeButton
|
JSON.parse(initial_data).topbar.desktopTopbarRenderer.interstitial?.consentBumpV2Renderer.agreeButton
|
||||||
.buttonRenderer.command.saveConsentAction;
|
.buttonRenderer.command.saveConsentAction;
|
||||||
|
if (cookies) {
|
||||||
Object.assign(cookieJar, {
|
Object.assign(cookieJar, {
|
||||||
VISITOR_INFO1_LIVE: cookies.visitorCookie,
|
VISITOR_INFO1_LIVE: cookies.visitorCookie,
|
||||||
CONSENT: cookies.consentCookie
|
CONSENT: cookies.consentCookie
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const updatedValues = await acceptViewerDiscretion(
|
const updatedValues = await acceptViewerDiscretion(
|
||||||
player_response.videoDetails.videoId,
|
player_response.videoDetails.videoId,
|
||||||
@ -463,7 +467,6 @@ export function getContinuationToken(data: any): string {
|
|||||||
.continuationEndpoint?.continuationCommand?.token;
|
.continuationEndpoint?.continuationCommand?.token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function acceptViewerDiscretion(
|
async function acceptViewerDiscretion(
|
||||||
videoId: string,
|
videoId: string,
|
||||||
cookieJar: { [key: string]: string },
|
cookieJar: { [key: string]: string },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user