chore: use timestamp in seconds for visitorData

YouTube also accepts timestamps in milliseconds, but since all clients generate visitorData with timestamps in seconds then the library should do the same.
This commit is contained in:
LuanRT
2022-05-15 21:49:28 -03:00
parent c60babcf25
commit 6312e97f95
2 changed files with 2 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ class SessionBuilder {
const user_agent = new UserAgent({ deviceCategory: 'desktop' });
const id = Utils.generateRandomString(11);
const timestamp = new Date().getTime();
const timestamp = Math.floor(Date.now() / 1000);
const visitor_data = Proto.encodeVisitorData(id, timestamp);

View File

@@ -13,7 +13,7 @@ class Proto {
*/
static encodeVisitorData(id, timestamp) {
const buf = messages.VisitorData.encode({ id, timestamp });
return encodeURIComponent(Buffer.from(buf).toString('base64'));
return encodeURIComponent(Buffer.from(buf).toString('base64').replace(/\//g, '_'));
}
/**