agrego nombre de archivo proto para omitir escritura si es la misma informacion

master
Francisco Sandoval 2023-12-13 10:15:53 -03:00
parent 98dee26134
commit a6c86a4753
1 changed files with 13 additions and 4 deletions

17
main.py
View File

@ -15,11 +15,18 @@ def main():
print(datetime.now(tz))
# print("hola")
content = download_file_proto()
if content == None:
fileproto = download_file_proto()
if fileproto == None:
return False
data = read_file_proto_x_stop(content)
namefile = r.get('fileproto')
if namefile == fileproto['name']:
print(namefile)
return
r.set('fileproto', fileproto['name'])
print(fileproto['name'])
data = read_file_proto_x_stop(fileproto['content'])
# save data to redis db
for key in data:
@ -31,7 +38,9 @@ def main():
def download_file_proto():
response = requests.get('https://app.ilab.cl/gtfs-rt/api/concepcion')
if response.status_code == 200:
return response.content
content_disposition = response.headers['Content-Disposition']
nombre_archivo = content_disposition.split('filename=')[1]
return { 'name': nombre_archivo, 'content': response.content }
return None