iv-org / youtube-trusted-session-generator

This is a generator for getting a session that passes all the checks from YouTube side
GNU Affero General Public License v3.0
65 stars 7 forks source link

Add HTTP webserver interface #6

Open 15532th opened 2 weeks ago

15532th commented 2 weeks ago

This PR implements enhancements discussed in #1, namely serving token as a JSON endpoint. It is meant to be a starting point for discussing the HTTP interface, specifically endpoints names and responses formats, so all the new code is placed into a separate file to avoid affecting any existing functionality.

Token generation runs independently from the webserver process, launching an update every 12 hours by default. Webserver uses port 8080 (configurable), with the latest token value being available on the /token endpoint:

$ curl 127.0.0.1:8080/token
{"updated": 1724445426, "potoken": "...", "visitor_data": "..."}

Additionally, it is possible to initiate immediate unscheduled token generation by accessing /update endpoint. While handy for testing, this feature seems to add more complications than it's worth, so it probably should be removed, unless it finds some practical use.