emoteJAM icon indicating copy to clipboard operation
emoteJAM copied to clipboard

[Research] Upload directly to BTTV

Open rexim opened this issue 3 years ago • 4 comments

We need to research if it's even possible to have something like a button that uploads the final emote directly to BTTV.

rexim avatar May 03 '21 09:05 rexim

bad solution, but it could help the user has to provide id and token

alert user id and token:

(function() {
    t = localStorage.getItem('USER_TOKEN').slice(1, -1);
    fetch('https://api.betterttv.net/3/account', {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'authorization': `Bearer ${t}`
        }
    }).then(r => r.json()).then(j => j.id).then(i => prompt('', `${i} ${t}`));
})();

upload from emoteJAM:

function upload(user_id, token, data) {
    // data: {
    //     "code": <str - emote name>,
    //     "image: <str - base64 png or gif>,
    //     "justification": <str - approval notes>,
    //     "sharing": <bool>
    // }
    fetch(`https://api.betterttv.net/3/users/${user_id}/emotes`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'authorization': `Bearer ${token}`
        },
        body: JSON.stringify(data)
    }).then(r => console.log(`success: ${r.ok}`));
}

Ciremun avatar May 03 '21 19:05 Ciremun

@Ciremun is there any convenient way for the user to get the token? Or does that require some hackerman skills with DevTools console?

rexim avatar May 10 '21 09:05 rexim

I searched bttv issues page They say, they doesn't provide oauth or api documentation so yeah, being hackerman seems the only option now

l4zygreed avatar May 10 '21 11:05 l4zygreed

@l4zygreed thank you for checking it out!

rexim avatar May 10 '21 11:05 rexim