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.