diff --git a/NUXT/plugins/constants.js b/NUXT/plugins/constants.js index bccd461..b0ea3f3 100644 --- a/NUXT/plugins/constants.js +++ b/NUXT/plugins/constants.js @@ -40,6 +40,19 @@ module.exports = { return headers; }, + INNERTUBE_NEW_HEADER: (info) => { + let headers = { + accept: "*/*", + "user-agent": info.userAgent, + "accept-language": `${info.hl}-${info.gl},${info.hl};q=0.9`, + "content-type": "application/json", + "x-goog-authuser": 0, + "x-goog-visitor-id": info.visitorData || "", + "x-youtube-client-name": "2", + "x-youtube-client-version": "2.20230502.01.00", + }; + return headers; + }, INNERTUBE_CLIENT: (info) => { let client = { gl: info.gl, @@ -59,4 +72,43 @@ module.exports = { }; return client; }, + INNERTUBE_VIDEO: (info) => { + let client = { + gl: info.gl, + hl: info.hl, + deviceMake: info.deviceMake, + deviceModel: info.deviceModel, + userAgent: info.userAgent, + clientName: "MWEB", + clientVersion: "2.20230502.01.00", + osName: info.osName, + osVersion: info.osVersion, + platform: "MOBILE", + playerType: "UNIPLAYER", + screenPixelDensity: "3", + originalUrl: info.originalUrl, + configInfo: info.configInfo, + remoteHost: info.remoteHost, + visitorData: info.visitorData, + clientFormFactor: "SMALL_FORM_FACTOR", + screenDensityFloat: "1", + timeZone: info.timeZone, + browserName: info.browserName, + browserVersion: info.browserVersion, + acceptHeader: + "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", + deviceExperimentId: info.deviceExperimentId, + screenWidthPoints: info.screenWidthPoints, + screenHeightPoints: info.screenHeightPoints, + utcOffsetMinutes: info.utcOffsetMinutes, + userInterfaceTheme: "USER_INTERFACE_THEME_LIGHT", + memoryTotalKbytes: "8000000", + clientScreen: "WATCH", + mainAppWebInfo: { + webDisplayMode: "WEB_DISPLAY_MODE_BROWSER", + isWebNativeShareAvailable: true, + }, + }; + return client; + }, }; diff --git a/NUXT/plugins/innertube.js b/NUXT/plugins/innertube.js index 075f628..90ae2ee 100644 --- a/NUXT/plugins/innertube.js +++ b/NUXT/plugins/innertube.js @@ -32,7 +32,7 @@ class Innertube { this.ErrorCallback(html.message, true); try { const data = JSON.parse( - getBetweenStrings(html.data, "ytcfg.set(", ");") + "{" + getBetweenStrings(html.data, "ytcfg.set({", ");") ); if (data.INNERTUBE_CONTEXT) { this.key = data.INNERTUBE_API_KEY; @@ -81,7 +81,11 @@ class Innertube { //--- API Calls ---// async browseAsync(action_type, args = {}) { - let data = { context: this.context }; + let data = { + context: { + client: constants.INNERTUBE_CLIENT(this.context.client), + }, + }; switch (action_type) { case "recommendations": @@ -160,7 +164,12 @@ class Innertube { } async getVidAsync(id) { - let data = { context: this.context, videoId: id }; + let data = { + context: { + client: constants.INNERTUBE_VIDEO(this.context.client), + }, + videoId: id, + }; const responseNext = await Http.post({ url: `${constants.URLS.YT_BASE_API}/next?key=${this.key}`, data: { @@ -179,8 +188,33 @@ class Innertube { const response = await Http.post({ url: `${constants.URLS.YT_BASE_API}/player?key=${this.key}`, - data: data, - headers: constants.INNERTUBE_HEADER(this.context.client), + data: { + ...data, + ...{ + contentCheckOk: false, + mwebCapabilities: { + mobileClientSupportsLivestream: true, + }, + playbackContext: { + contentPlaybackContext: { + currentUrl: "/watch?v=" + id, + vis: 0, + splay: false, + autoCaptionsDefaultOn: false, + autonavState: "STATE_NONE", + html5Preference: "HTML5_PREF_WANTS", + signatureTimestamp: 19473, + referer: "https://m.youtube.com/", + lactMilliseconds: "-1", + watchAmbientModeContext: { + watchAmbientModeEnabled: true, + }, + }, + }, + }, + }, + // headers: constants.INNERTUBE_HEADER(this.context.client), + headers: constants.INNERTUBE_NEW_HEADER(this.context.client), }).catch((error) => error); if (response.error) @@ -336,7 +370,6 @@ class Innertube { const ownerData = vidMetadata.contents.find( (content) => content.slimOwnerRenderer )?.slimOwnerRenderer; - const vidData = { id: details.videoId, title: details.title,