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
|
||||
*/
|
||||
discretionAdvised: boolean;
|
||||
discretionAdvised?: boolean;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
discretionAdvised: boolean;
|
||||
discretionAdvised?: boolean;
|
||||
/**
|
||||
* Constructor for YouTube Video Class
|
||||
* @param data JSON parsed data.
|
||||
@ -161,7 +161,7 @@ export class YouTubeVideo {
|
||||
this.live = !!data.live;
|
||||
this.private = !!data.private;
|
||||
this.tags = data.tags || [];
|
||||
this.discretionAdvised = !!data.discretionAdvised;
|
||||
this.discretionAdvised = data.discretionAdvised === undefined ? undefined : data.discretionAdvised;
|
||||
}
|
||||
/**
|
||||
* Converts class to title name of video.
|
||||
|
||||
@ -145,12 +145,14 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
||||
);
|
||||
discretionAdvised = true;
|
||||
const cookies =
|
||||
initial_response.topbar.desktopTopbarRenderer.interstitial.consentBumpV2Renderer.agreeButton
|
||||
initial_response.topbar.desktopTopbarRenderer.interstitial?.consentBumpV2Renderer.agreeButton
|
||||
.buttonRenderer.command.saveConsentAction;
|
||||
if (cookies) {
|
||||
Object.assign(cookieJar, {
|
||||
VISITOR_INFO1_LIVE: cookies.visitorCookie,
|
||||
CONSENT: cookies.consentCookie
|
||||
});
|
||||
}
|
||||
|
||||
const updatedValues = await acceptViewerDiscretion(vid.videoId, cookieJar, body, true);
|
||||
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.');
|
||||
|
||||
const cookies =
|
||||
JSON.parse(initial_data).topbar.desktopTopbarRenderer.interstitial.consentBumpV2Renderer.agreeButton
|
||||
JSON.parse(initial_data).topbar.desktopTopbarRenderer.interstitial?.consentBumpV2Renderer.agreeButton
|
||||
.buttonRenderer.command.saveConsentAction;
|
||||
if (cookies) {
|
||||
Object.assign(cookieJar, {
|
||||
VISITOR_INFO1_LIVE: cookies.visitorCookie,
|
||||
CONSENT: cookies.consentCookie
|
||||
});
|
||||
}
|
||||
|
||||
const updatedValues = await acceptViewerDiscretion(
|
||||
player_response.videoDetails.videoId,
|
||||
@ -463,7 +467,6 @@ export function getContinuationToken(data: any): string {
|
||||
.continuationEndpoint?.continuationCommand?.token;
|
||||
}
|
||||
|
||||
|
||||
async function acceptViewerDiscretion(
|
||||
videoId: string,
|
||||
cookieJar: { [key: string]: string },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user