Code Monkey home page Code Monkey logo

Comments (6)

xosrika avatar xosrika commented on May 30, 2024 1

+1

from youtube-studio.

cxovrika avatar cxovrika commented on May 30, 2024 1

@adasq So, after a lot of digging and comparing http requests made by browser and the script, I think I found what is the issue in my case.

I got more than one YouTube accounts on one email, and the channel I'm trying to automate is one of them (when I log in, by default this account is not selected, so I'm switching it manually). The information about which account is 'active', is probably held in the cookie called LOGIN_INFO which is present for me (you can also see it in the image I provided above).

So, all I had to do is add it to the list of cookies in the init function, something like this:

async function init({
    SID,
    HSID,
    SSID,
    APISID,
    SAPISID,
    LOGIN_INFO,
}) {
    ...
    const cookie = `SID=${SID}; HSID=${HSID}; SSID=${SSID}; APISID=${APISID}; SAPISID=${SAPISID}; ${LOGIN_INFO ? `LOGIN_INFO=${LOGIN_INFO}` : ''}`
    ...

What was actually happening previously for me (when I was not specifying LOGIN_INFO), is that YouTube studio was sending a page that was just showing oops, something went wrong. But for some reason, it also had a script, that was creating ytcfg and filling some of it's properties, including INNERTUBE_API_KEY, but not DELEGATED_SESSION_ID, so I never thought that it's an 'error' page, but then I tried to render it xD

I just submitted an MR with this change, feel free to merge or request some changes :P

from youtube-studio.

adasq avatar adasq commented on May 30, 2024 1

Wow, great job @cxovrika!

Thank you for your time and deep research.
Your changes published as of [email protected].

from youtube-studio.

adasq avatar adasq commented on May 30, 2024

Hey @cxovrika ,

Can you verify whether you can set an endscreen, with just one element, TYPE_RECENT_UPLOAD?

It works for two of my accounts so I think that might by related to account itself.

Please, try open file node_modules/youtube-studio/src/youtube-studio-api.js, search for function setEndScreen and try to replace line:
_.set(template, 'context.user.onBehalfOfUser', config.DELEGATED_SESSION_ID);
with:
delete template.context.user.onBehalfOfUser;

Then, please, let me know how the response look like

from youtube-studio.

cxovrika avatar cxovrika commented on May 30, 2024

@adasq I tried that but the result was the same.

Then I digged a bit more into what's happening and found out that config does noes not have DELEGATED_SESSION_ID at all. Then I checked how is it generated, and found that it's set in getConfig function:

        fetchConfig = {
            INNERTUBE_API_KEY: windowRef.ytcfg.data_.INNERTUBE_API_KEY,
            DELEGATED_SESSION_ID: windowRef.ytcfg.data_.DELEGATED_SESSION_ID,
        };

Here is how my windowRef looks like: https://pastebin.com/KSMp8sQT

So, after running the vm.run('${jsCode}; window.ytcfg = ytcfg;'); script, the ytcfg was generated and set. The problem is that it contains INNERTUBE_API_KEY but does not contain DELEGATED_SESSION_ID, which we are trying to get. Does it mean that something changed on YouTube API side?

I tried to use INNERTUBE_CONTEXT_SERIALIZED_DELEGATION_CONTEXT's value instead (just because it's also related to delegation, idk :V) but in that case I received:

{
    "error": {
        "code": 500,
        "message": "Internal error encountered.",
        "errors": [
            {
                "message": "Internal error encountered.",
                "domain": "global",
                "reason": "backendError"
            }
        ],
        "status": "INTERNAL"
    }
}

so probably I have to sett something else there. Btw, the DELEGATION_CONTEXT looks like this:

{
  externalChannelId: 'UC3AZ26x1NTKK3_lqFn4dMQg',
  roleType: { channelRoleType: 'CREATOR_CHANNEL_ROLE_TYPE_OWNER' }
}

Any ideas? Could you also please check if in case of your channels the DELEGATED_SESSION_ID is present?

from youtube-studio.

adasq avatar adasq commented on May 30, 2024

Thank you for digging into the code!

Well, in my case DELEGATED_SESSION_ID is set for one account, and it does not exist for another, but I am still able to set endscreens for both of them.

  1. I published a new version with some changes - I don't believe it will help at all, but it's worth checking anyway.
  2. What we can check on your side, is a payload template variable from node_modules/youtube-studio/src/youtube-studio-api.js:setEndscreen and compare it to the payload send on studio.youtube.com while adding end screen (POST https://studio.youtube.com/youtubei/v1/video_editor/edit_video?alt=json&key={yourKey}). Any differences spotted might be helpful. Additionally you can print global headers variable to verify http headers

Thanks in advance for your time!

from youtube-studio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.