fix: headers

Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
Omar Sánchez Pizarro
2025-12-01 17:37:26 +01:00
parent 1612510301
commit 5fdfbf1927
2 changed files with 16 additions and 8 deletions

View File

@@ -10,6 +10,9 @@ args = arg_parser.ArgParser().parse()
config = config_parser.ConfigParser().loadConfig() config = config_parser.ConfigParser().loadConfig()
tnv_string = "Tn-V"
tnd_string = "Tn-D"
class timenetManager: class timenetManager:
telegram = None telegram = None
message_acumulator = "" message_acumulator = ""
@@ -24,8 +27,13 @@ class timenetManager:
self.headers = { self.headers = {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8", "Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"Tn-V": "wcp_8.0.0.2", "Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" "Referer": "https://timenet-wcp.gpisoftware.com/",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Linux\"",
"Sec-Ch-Ua": "\"Chromium\";v=\"138\", \"Not=A?Brand\";v=\"8\", \"Google Chrome\";v=\"138\"",
tnv_string: "wcp_8.0.0.2",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
} }
self.login() self.login()
@@ -55,6 +63,7 @@ class timenetManager:
if response.status_code != 200: if response.status_code != 200:
print("Error al iniciar sesión: %s" % response.text) print("Error al iniciar sesión: %s" % response.text)
exit(20)
self.headers["Token"] = response.text self.headers["Token"] = response.text
@@ -67,10 +76,10 @@ class timenetManager:
self.message_acumulator = "" self.message_acumulator = ""
def updateTime(self): def updateTime(self):
self.headers["Tn-D"] = "\"" + datetime.now().astimezone(pytz.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") + "\"" self.headers[tnd_string] = "\"" + datetime.now().astimezone(pytz.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") + "\""
def updateVersion(self): def updateVersion(self):
self.headers["Tn-V"] = self.getVersion() self.headers[tnv_string] = self.getVersion()
def getVersion(self): def getVersion(self):
self.updateTime() self.updateTime()
@@ -120,17 +129,17 @@ class timenetManager:
rand = utils.numero_aleatorio_con_probabilidad(230, 0.5) rand = utils.numero_aleatorio_con_probabilidad(230, 0.5)
self.addMessage("Esperando %s segundos para %s en un minuto aleatorio" % (rand,conditional_response[int(typ)]["text2"])) self.addMessage("Esperando %s segundos para %s en un minuto aleatorio" % (rand,conditional_response[int(typ)]["text2"]))
self.sendReport() self.sendReport()
sleep(rand) #sleep(rand)
self.updateTime() self.updateTime()
data = { data = {
"typ": typ, "typ": typ,
"date": self.headers['tn-d'], "date": self.headers[tnd_string],
"geoLatitude": config['geo']['latitude'], "geoLatitude": config['geo']['latitude'],
"geoLongitude": config['geo']['longitude'], "geoLongitude": config['geo']['longitude'],
"geoError": "", "geoError": "",
"geoAccuracy": config['geo']['accuracy'] "geoAccuracy": config['geo']['accuracy']
} }
response = self.post("cp/checks", data, self.headers) #response = self.post("cp/checks", data, self.headers)
else: else:
self.addMessage('Corriendo en modo debug. No se realizará ninguna acción') self.addMessage('Corriendo en modo debug. No se realizará ninguna acción')
self.sendReport() self.sendReport()

View File

@@ -17,7 +17,6 @@ from app import timenet_manager
if __name__ == '__main__': if __name__ == '__main__':
af = timenet_manager.timenetManager() af = timenet_manager.timenetManager()
#print(af.getVersion().text)
af.sendUpdate() af.sendUpdate()