From 2a78d77aa396f33bc7ee311586e51754226e27d3 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Thu, 13 Oct 2022 16:39:56 -0300 Subject: [PATCH] refactor: get visitor data from the API [skip ci] --- src/core/Session.ts | 9 ++------- src/proto/index.ts | 10 +--------- src/proto/youtube.proto | 5 ----- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/core/Session.ts b/src/core/Session.ts index 7cfc247e..b174a96d 100644 --- a/src/core/Session.ts +++ b/src/core/Session.ts @@ -1,12 +1,11 @@ import Player from './Player'; -import Proto from '../proto/index'; import Actions from './Actions'; import Constants from '../utils/Constants'; import UniversalCache from '../utils/Cache'; import EventEmitterLike from '../utils/EventEmitterLike'; import HTTPClient, { FetchFunction } from '../utils/HTTPClient'; -import { DeviceCategory, generateRandomString, getRandomUserAgent, InnertubeError, SessionError } from '../utils/Utils'; +import { DeviceCategory, getRandomUserAgent, InnertubeError, SessionError } from '../utils/Utils'; import OAuth, { Credentials, OAuthAuthErrorEventHandler, OAuthAuthEventHandler, OAuthAuthPendingEventHandler } from './OAuth'; export enum ClientType { @@ -140,16 +139,12 @@ export default class Session extends EventEmitterLike { const [ [ device_info ], api_key ] = ytcfg; - const id = generateRandomString(11); - const timestamp = Math.floor(Date.now() / 1000); - const visitor_data = Proto.encodeVisitorData(id, timestamp); - const context: Context = { client: { hl: device_info[0], gl: device_info[2], remoteHost: device_info[3], - visitorData: visitor_data, + visitorData: data[3], userAgent: device_info[14], clientName: client_name, clientVersion: device_info[16], diff --git a/src/proto/index.ts b/src/proto/index.ts index 473a7c2c..ef98cc73 100644 --- a/src/proto/index.ts +++ b/src/proto/index.ts @@ -1,17 +1,9 @@ import { CLIENTS } from '../utils/Constants'; import { u8ToBase64 } from '../utils/Utils'; import { VideoMetadata } from '../core/Studio'; -import { ChannelAnalytics, CreateCommentParams, CreateCommentReplyParams, GetCommentsSectionParams, InnertubePayload, LiveMessageParams, MusicSearchFilter, NotificationPreferences, PeformCommentActionParams, SearchFilter, SoundInfoParams, VisitorData } from './youtube'; +import { ChannelAnalytics, CreateCommentParams, CreateCommentReplyParams, GetCommentsSectionParams, InnertubePayload, LiveMessageParams, MusicSearchFilter, NotificationPreferences, PeformCommentActionParams, SearchFilter, SoundInfoParams } from './youtube'; class Proto { - static encodeVisitorData(id: string, timestamp: number) { - const buf = VisitorData.toBinary({ - id, - timestamp - }); - return encodeURIComponent(u8ToBase64(buf).replace(/\/|\+/g, '_')); - } - static encodeChannelAnalyticsParams(channel_id: string) { const buf = ChannelAnalytics.toBinary({ params: { diff --git a/src/proto/youtube.proto b/src/proto/youtube.proto index e598adef..21e2776b 100644 --- a/src/proto/youtube.proto +++ b/src/proto/youtube.proto @@ -3,11 +3,6 @@ syntax = "proto2"; package youtube; -message VisitorData { - required string id = 1; - required int32 timestamp = 5; -} - message ChannelAnalytics { message Params { required string channel_id = 1001;