#πŸ”’ YouTube API Request Cookie Help

14 messages Β· Page 1 of 1 (latest)

twilit hemlock
#

Hi all,

I'm trying to make my YouTube account send a comment with HTTP POST requests in Python.

However, the way that the YouTube api is laid out makes this task a little tough to accomplish.

The request cookies have many parameters which I don't have a clue about. I don't know what 90% of them are or how to generate them. I don't even know if they're actually necessary.

My code so far is this:

from datetime import datetime, timezone
import hashlib
import time
import requests

def sapisidhash(sapisid: str, origin: str) -> str:
    now = datetime.now(timezone.utc)
    timesec = round(now.timestamp())

    hashed = sha1_hash(
        f"{timesec} {sapisid} {origin}"
    )

    return f"{timesec}_{hashed}"

    # generates the sapisidhash

def get_sapisid():
    # here, i would run some dummy request to get my SAPISID from the request cookies

Then below a standard POST request with headers I can't show for privacy reasons.

Does anyone know how strict the YouTube API is with this? I don't really want to waste time trying to trial and error this.

hazy gullBOT
#

@twilit hemlock

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

twilit hemlock
#

Also, yes this is a very open ended question but I can't even really start with this until I have an idea of what the YouTube API even requires of me or how to begin generating these cookie params

prime ridge
#

Which part of their api is it? I'm quite good at deciphering api docs, so if you send a link to docs, I might be able to help

twilit hemlock
#

There isn't any documentation

#

It's for a user account

#

@prime ridge

prime ridge
hazy gullBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

twilit hemlock
#

Huh. Alright. Apologies.

harsh notch
# twilit hemlock Huh. Alright. Apologies.

Well since it's against the TOS here, here's a little help for ur next projects that don't break the TOS, Ctrl shift i, go to network tab, clear all logs, do the action u want and it'll record it, copy the same action into python, don't do this for YouTube as it breaks their TOS, this is just for future reference

prime ridge
hazy gullBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.