Skip to content

Commit

Permalink
temporary session id generation removed
Browse files Browse the repository at this point in the history
  • Loading branch information
adasq committed Mar 27, 2021
1 parent f5ca35e commit 61334a3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "youtube-studio",
"version": "0.0.16",
"version": "0.0.17",
"description": "Unofficial YouTube Studio API",
"main": "index.js",
"scripts": {
Expand Down
37 changes: 20 additions & 17 deletions src/youtube-studio-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let debug = {
text: '',
config: ''
};
let sessionToken = '';

async function init({
SID,
Expand All @@ -26,6 +27,7 @@ async function init({
APISID,
SAPISID,
LOGIN_INFO,
SESSION_TOKEN = ''
}) {
const DATE = Date.now().toString();

Expand All @@ -41,6 +43,8 @@ async function init({
'user-agent': USER_AGENT,
}

sessionToken = SESSION_TOKEN;

config = config || await getConfig();
}

Expand Down Expand Up @@ -126,24 +130,23 @@ async function setMonetisation(monetizationSettings) {
_.set(requestBody, 'context.user.onBehalfOfUser', config.DELEGATED_SESSION_ID);
_.set(requestBody, 'context.user.delegationContext.externalChannelId', config.CHANNEL_ID || "");

let { sessionToken } = await fetch(`${YT_STUDIO_URL}/youtubei/v1/att/esr?alt=json&key=${config.INNERTUBE_API_KEY}`, {
method: 'POST',
headers: {
"sec-ch-ua": "\"Google Chrome\";v=\"87\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"87\"",
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-goog-authuser": "0",
"x-goog-visitor-id": "Cgs0Z2JqQUVoMkg0RSil6Oz_BQ%3D%3D",
"x-origin": YT_STUDIO_URL,
...headers
},
body: `${JSON.stringify(requestBody)}`
})
.then(res => res.json())
// let { sessionToken } = await fetch(`${YT_STUDIO_URL}/youtubei/v1/att/esr?alt=json&key=${config.INNERTUBE_API_KEY}`, {
// method: 'POST',
// headers: {
// "sec-ch-ua": "\"Google Chrome\";v=\"87\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"87\"",
// "sec-ch-ua-mobile": "?0",
// "sec-fetch-dest": "empty",
// "sec-fetch-mode": "cors",
// "sec-fetch-site": "same-origin",
// "x-goog-authuser": "0",
// "x-goog-visitor-id": "Cgs0Z2JqQUVoMkg0RSil6Oz_BQ%3D%3D",
// "x-origin": YT_STUDIO_URL,
// ...headers
// },
// body: `${JSON.stringify(requestBody)}`
// })
// .then(res => res.json())

sessionToken = 'AbX5usaVblZEZl2lczOwxAxUibNffJq4vqh58zeBJ1j_Iy4Izj-wFpOIaNmzkKVgpXJ1PL7DWz5rgkyX2QEUq5XOMc-EJw==';
requestBody = _.cloneDeep(metadata_update_request_payload)

_.set(requestBody, 'context.user.onBehalfOfUser', config.DELEGATED_SESSION_ID);
Expand Down
3 changes: 2 additions & 1 deletion src/youtube-studio-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const {


const VIDEO_ID = nconf.get('VIDEO_ID')
const SESSION_TOKEN = nconf.get('SESSION_TOKEN')
const CLAIMS_VIDEO_ID = nconf.get('CLAIMS_VIDEO_ID')
const PLAYLIST_ID = nconf.get('PLAYLIST_ID')
const CHANNEL_ID = nconf.get('CHANNEL_ID')
const LESS_THAN_10MIN_VIDEO_ID = nconf.get('LESS_THAN_10MIN_VIDEO_ID');


describe('for authenticated user', () => {
jest.setTimeout(4 * 60 * 1000);

Expand All @@ -31,6 +31,7 @@ describe('for authenticated user', () => {
SSID,
APISID,
SAPISID,
SESSION_TOKEN
})
})

Expand Down

0 comments on commit 61334a3

Please sign in to comment.