Open Arcegis opened 1 year ago
Adding a message to notice that https://f1tokenx.deta.dev/ displays now "Service No Longer Available"
yep, deta is now down. i'm considering deploying elsewhere
Is this a component that we could also self-host? Is the source code for what used to be running on deta publicly available?
Essentially, I guess what I'm asking is, is there a way for us to host everything on our own servers so we don't have to rely on third-party services?
Maybe config file to place the token in or a token login field. Token can be extracted here > https://github.com/SoMuchForSubtlety/f1viewer/wiki/Getting-your-subscription-token
At a second glance, it looks like that deta instance was proxying requests to https://api.formula1.com/6657193977244c13...
Is this a component that we could also self-host? Is the source code for what used to be running on deta publicly available?
Essentially, I guess what I'm asking is, is there a way for us to host everything on our own servers so we don't have to rely on third-party services?
Yep, that's planned, but I'm pretty busy previously but the all-in-one thing should work before next GP
Music to my ears, thanks mate.
I have hacked together something and it's working for today.
If it's of any help to anyone else, this is what I have running on a domain from freedns to rewrite the URL and a couple of headers.
from flask import Flask, request
from flask_cors import CORS
import requests
import logging
import sys
app = Flask(__name__)
CORS(app)
API_HOST="https://api.formula1.com/6657193977244c13?d=account.formula1.com"
@app.route('/6657193977244c13', methods=["GET"])
def getjs():
return requests.get("https://api.formula1.com/6657193977244c13").text
@app.route('/6657193977244c13', methods=["POST"])
def rewrite():
app.logger.debug(request.headers)
headers = {k:v for k,v in request.headers if k.lower() != 'host'}
headers['Origin'] = "https://account.formula1.com"
headers['Referer'] = "https://account.formula1.com/"
res = requests.request(
method = "POST",
url = API_HOST,
headers = headers,
data = request.get_data(),
cookies = request.cookies,
allow_redirects = False,
)
return res.text, res.status_code
if __name__ == "__main__":
app.run()
I'm sure it's doable in express & node-fetch but I couldn't get the raw data from a request in time for the GP today so I just did it in python Flask which I'm much more comfortable with!
for quick fix: just built a version which is using api endpoint deployed at vercel.
https://github.com/iebb/F1WebViewer-SelfHosted/releases/tag/v0.2.1
check this, it should work
@Arcegis @christovic @s0fax @FelixSFD
Niiiiiice thanks @iebb ! I will deploy that after this GP and report back 🤞
@iebb thank you works, so i can run it on LG webos Browser :)
Hello, I can confirm that, as of today, the message pops up once again. Beside, f1-api.jeb.nom.za gives a NS_ERROR_UNKNOWN_HOST response. I suppose that the API you use is now EoL...
christovic's Script above works, when you self host the F1-Web-Viewer and the Script. I have now configured both into an alpine container, hung caddy with ssl cert in front, then I was able to sign in and watch warm-up show.
Python and the modules flask, flask_cors and requests are required to run the script.
Flask defaults on localhost:5000, so I have adapted the last line in the script
app.run(host='0.0.0.0', port=5000)
The following variable is required to build F1-Web-Viewer with current nodejs
export NODE_OPTIONS=--openssl-legacy-provider
and the Public/index.html must be adjusted in line 13 with your domain.
I ended up writing my own F1 viewer that handles the login process a bit smoother than this one, but it's not as feature rich. Super simple static page - it's a bit lighter on resources and just automatically loads and plays the live GP if there is one.
In this, I ended up writing a reese84 handler in golang, dropping here too if it is useful for anyone else:
func reeseHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
resp, err := http.Get("https://api.formula1.com/6657193977244c13")
if err != nil {
upstreamF1TVApiError(err, w)
return
}
body, err := io.ReadAll(resp.Body)
if err != nil {
upstreamF1TVApiError(err, w)
return
}
w.Write(body)
} else if r.Method == "POST" {
proxyReq, err := http.NewRequest(r.Method, "https://api.formula1.com/6657193977244c13?d=account.formula1.com", r.Body)
if err != nil {
http.Error(w, "Error creating proxy request", http.StatusInternalServerError)
return
}
for name, values := range r.Header {
for _, value := range values {
proxyReq.Header.Add(name, value)
}
}
proxyReq.Header.Add("Origin", "https://account.formula1.com")
proxyReq.Header.Add("Referer", "https://account.formula1.com")
resp, err := http.DefaultClient.Do(proxyReq)
if err != nil {
upstreamF1TVApiError(err, w)
return
}
upstreamBody, err := io.ReadAll(resp.Body)
if err != nil {
upstreamF1TVApiError(err, w)
return
}
w.Write(upstreamBody)
}
}
func upstreamF1TVApiError(err error, w http.ResponseWriter) {
log.Println(err)
http.Error(w, "Error from api.formula1.com", http.StatusBadGateway)
}
I'm using latest exec.
As soon as I enter email and password, a message pops in red "window.reese84 is undefined". See hereby screenshot, and Console logs.
Uncaught (in promise) TypeError: window.reese84 is undefined authenticate index.js:117 w vuex.esm.js:851 dispatch vuex.esm.js:516 dispatch vuex.esm.js:406 submit Login.vue:90 submit Login.vue:1 VueJS 3 https://pixheb.ovh/images/a4a40a8a21bd2cf08a185fc1e1122f8d.png