Skip to content

Commit

Permalink
fix: use direct method for most of moderation APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed May 26, 2022
1 parent 0c0ba71 commit ff73d0e
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 179 deletions.
9 changes: 5 additions & 4 deletions .env.placeholder
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MC_MSG_TEST_CREDENTIALS=
MC_MSG_TEST_CREDENTIALS_SECOND=
MC_MSG_TEST_ID=
MC_MSG_TEST_CHANNEL_ID=
MC_TEST_VIDEO_ID=
MC_TEST_CHANNEL_ID=
MC_TEST_CHANNEL_ID_2=
MC_TEST_CREDENTIAL=
MC_TEST_CREDENTIAL_2=
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- Move video comments API to Masterchat class
- `mc.getComments()`
- Use direct method for `hide`, `unhide`, `pin`, `unpin`, `addModerator`, `removeModerator` and `timeout`
- Add `executor` to `MarkChatItemAsDeletedAction`

### Fixes
Expand Down
41 changes: 23 additions & 18 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ function h(b: TemplateStringsArray): string {
return new TextDecoder().decode(hextou8(b.raw[0]));
}

function hj(b: TemplateStringsArray): any {
return JSON.parse(h(b));
}
export const DH = {
"Accept-Language": "en",
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
};
export const DC = { clientName: "WEB", clientVersion: "2.20211014.05.00" };

export const DO = "https://www.youtube.com";
export const DAK = h`41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_GLCR = "/youtubei/v1/live_chat/get_live_chat_replay?key=" + DAK;
export const EP_GLC = "/youtubei/v1/live_chat/get_live_chat?key=" + DAK;
export const EP_SM = "/youtubei/v1/live_chat/send_message?key=" + DAK;
export const EP_MOD = "/youtubei/v1/live_chat/moderate?key=" + DAK;
export const EP_LCA = "/youtubei/v1/live_chat/live_chat_action?key=" + DAK;
export const EP_MU = "/youtubei/v1/live_chat/manage_user?key=" + DAK;
export const EP_GTS = "/youtubei/v1/get_transcript?key=" + DAK;
export const EP_NXT = "/youtubei/v1/next?key=" + DAK;
export const EP_GICM =
"/youtubei/v1/live_chat/get_item_context_menu?key=" + DAK;

export const DH = hj`7b224163636570742d4c616e6775616765223a22656e222c22557365722d4167656e74223a224d6f7a696c6c612f352e3020284d6163696e746f73683b20496e74656c204d6163204f5320582031305f31355f3729204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f39302e302e343433302e3933205361666172692f3533372e3336227d`;
// export const DC = hj`7b22636c69656e744e616d65223a22574542222c22636c69656e7456657273696f6e223a22322e32303231303831332e30302e3030227d`;
export const DC = hj`7b22636c69656e744e616d65223a22574542222c22636c69656e7456657273696f6e223a22322e32303231313031342e30352e3030227d`;
export const DO = h`68747470733a2f2f7777772e796f75747562652e636f6d`;
export const EP_GLCR = h`2f796f7574756265692f76312f6c6976655f636861742f6765745f6c6976655f636861745f7265706c61793f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_GLC = h`2f796f7574756265692f76312f6c6976655f636861742f6765745f6c6976655f636861743f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_SM = h`2f796f7574756265692f76312f6c6976655f636861742f73656e645f6d6573736167653f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_GICM = h`2f796f7574756265692f76312f6c6976655f636861742f6765745f6974656d5f636f6e746578745f6d656e753f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_M = h`2f796f7574756265692f76312f6c6976655f636861742f6d6f6465726174653f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_NXT = h`2f796f7574756265692f76312f6e6578743f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738`;
export const EP_GTS = h`68747470733a2f2f7777772e796f75747562652e636f6d2f796f7574756265692f76312f6765745f7472616e7363726970743f6b65793d41497a615379414f5f464a32536c7155385134535445484c4743696c775f59395f313171635738267072657474795072696e743d66616c7365`;
export const XO = h`582d4f726967696e`;
export const XGAU = h`582d476f6f672d4175746855736572`;
export const XGPID = h`582d476f6f672d506167654964`;
export const SASH = h`5341504953494448415348`;
export const SASH = "SAPISIDHASH";
export const XO = "X-Origin";
export const XGAU = "X-Goog-AuthUser";
export const XGPID = "X-Goog-PageId";
6 changes: 3 additions & 3 deletions src/context/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { buildAuthHeaders } from "../auth";
import { DH } from "../constants";
import { findCfg, findInitialData } from ".";

const id = process.env.MC_MSG_TEST_ID;
const channelId = process.env.MC_MSG_TEST_CHANNEL_ID;
const credentialsB64 = process.env.MC_MSG_TEST_CREDENTIALS_SECOND;
const id = process.env.MC_TEST_VIDEO_ID;
const channelId = process.env.MC_TEST_CHANNEL_ID;
const credentialsB64 = process.env.MC_TEST_CREDENTIAL_2;
const credentials = credentialsB64
? JSON.parse(Buffer.from(credentialsB64!, "base64").toString())
: undefined;
Expand Down

0 comments on commit ff73d0e

Please sign in to comment.