Merge pull request #8 from MathiasDPX/main

Cleanup + Utilisation de l'api plutot que de scraper
This commit is contained in:
Solène 2025-01-26 14:32:52 +01:00 committed by GitHub
commit e2eecb9b65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

382
app.py
View file

@ -107,81 +107,12 @@ def translateDay(weekday: int):
def health():
return "OK"
def format(cinema, nb):
return ({
"salle": cinema["salle"],
"url": decalageDate(cinema["url"], nb)
})
cinemas_data = [
{
"salle" : "Écoles Cinéma Club",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0071.html"
},
{
"salle" : "MK2 Bibliothèque",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C2954.html",
},
{
"salle" : "MK2 Beaubourg",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0050.html"
},
{
"salle" : "Épée de bois",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=W7504.html"
},
{
"salle" : "Cinéma du Panthéon",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0076.html"
},
{
"salle" : "Max Linder Panorama",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0089.html"
},
{
"salle" : "Luminor Hotel de Ville",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0013.html"
},
{
"salle" : "Le Grand Action",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0072.html"
},
{
"salle" : "MK2 Parnasse",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0099.html"
},
{
"salle" : "Le Champo",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0073.html"
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0020.html"
},
{
"salle" : "Reflet Medicis",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0074.html"
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0159.html"
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0026.html"
}
]
@app.route('/')
def home():
delta = request.args.get("delta", default=0, type=int)
<<<<<<< HEAD
cinemas = cinemas_data;
=======
if delta > 6: delta = 6
if delta < 0: delta = 0
>>>>>>> 142c74e5ab8db960a2486bc4c838a4833b807664
dates = []
@ -197,316 +128,5 @@ def home():
return render_template('index.html', page_actuelle='home', films=showtimes[delta], dates=dates)
<<<<<<< HEAD
@app.route('/jour1')
@cache.cached(timeout=3600)
def jour1():
date = {
"jour1" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 0),
"chiffre" : testChiffreJour(datetime.today().day, 0),
"mois" : testMoisNumero(datetime.today().day, 0)
},
"jour2" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 1),
"chiffre" : testChiffreJour(datetime.today().day, 1),
"mois" : testMoisNumero(datetime.today().day, 1)
},
"jour3" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 2),
"chiffre" : testChiffreJour(datetime.today().day, 2),
"mois" : testMoisNumero(datetime.today().day, 2)
},
"jour4" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 3),
"chiffre" : testChiffreJour(datetime.today().day, 3),
"mois" : testMoisNumero(datetime.today().day, 3)
},
"jour5" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 4),
"chiffre" : testChiffreJour(datetime.today().day, 4),
"mois" : testMoisNumero(datetime.today().day, 4)
},
"jour6" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 5),
"chiffre" : testChiffreJour(datetime.today().day, 5),
"mois" : testMoisNumero(datetime.today().day, 5)
},
"jour7" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 6),
"chiffre" : testChiffreJour(datetime.today().day, 6),
"mois" : testMoisNumero(datetime.today().day, 6)
}
}
films = []
cinemas = list(map(lambda cinema: format(cinema, 1), cinemas))
films = get_data(cinemas)
filmsClean = cleanFilms(films)
return render_template('jours/jour1.html', page_actuelle='jour1', films=filmsClean, date=date)
@app.route('/jour2')
@cache.cached(timeout=3600)
def jour2():
date = {
"jour1" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 0),
"chiffre" : testChiffreJour(datetime.today().day, 0),
"mois" : testMoisNumero(datetime.today().day, 0)
},
"jour2" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 1),
"chiffre" : testChiffreJour(datetime.today().day, 1),
"mois" : testMoisNumero(datetime.today().day, 1)
},
"jour3" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 2),
"chiffre" : testChiffreJour(datetime.today().day, 2),
"mois" : testMoisNumero(datetime.today().day, 2)
},
"jour4" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 3),
"chiffre" : testChiffreJour(datetime.today().day, 3),
"mois" : testMoisNumero(datetime.today().day, 3)
},
"jour5" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 4),
"chiffre" : testChiffreJour(datetime.today().day, 4),
"mois" : testMoisNumero(datetime.today().day, 4)
},
"jour6" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 5),
"chiffre" : testChiffreJour(datetime.today().day, 5),
"mois" : testMoisNumero(datetime.today().day, 5)
},
"jour7" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 6),
"chiffre" : testChiffreJour(datetime.today().day, 6),
"mois" : testMoisNumero(datetime.today().day, 6)
}
}
films = []
cinemas = list(map(lambda cinema: format(cinema, 2), cinemas))
films = get_data(cinemas)
filmsClean = cleanFilms(films)
return render_template('jours/jour2.html', page_actuelle='jour2', films=filmsClean, date=date)
@app.route('/jour3')
@cache.cached(timeout=3600)
def jour3():
date = {
"jour1" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 0),
"chiffre" : testChiffreJour(datetime.today().day, 0),
"mois" : testMoisNumero(datetime.today().day, 0)
},
"jour2" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 1),
"chiffre" : testChiffreJour(datetime.today().day, 1),
"mois" : testMoisNumero(datetime.today().day, 1)
},
"jour3" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 2),
"chiffre" : testChiffreJour(datetime.today().day, 2),
"mois" : testMoisNumero(datetime.today().day, 2)
},
"jour4" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 3),
"chiffre" : testChiffreJour(datetime.today().day, 3),
"mois" : testMoisNumero(datetime.today().day, 3)
},
"jour5" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 4),
"chiffre" : testChiffreJour(datetime.today().day, 4),
"mois" : testMoisNumero(datetime.today().day, 4)
},
"jour6" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 5),
"chiffre" : testChiffreJour(datetime.today().day, 5),
"mois" : testMoisNumero(datetime.today().day, 5)
},
"jour7" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 6),
"chiffre" : testChiffreJour(datetime.today().day, 6),
"mois" : testMoisNumero(datetime.today().day, 6)
}
}
films = []
cinemas = list(map(lambda cinema: format(cinema, 3), cinemas))
films = get_data(cinemas)
filmsClean = cleanFilms(films)
return render_template('jours/jour3.html', page_actuelle='jour3', films=filmsClean, date=date)
@app.route('/jour4')
@cache.cached(timeout=3600)
def jour4():
date = {
"jour1" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 0),
"chiffre" : testChiffreJour(datetime.today().day, 0),
"mois" : testMoisNumero(datetime.today().day, 0)
},
"jour2" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 1),
"chiffre" : testChiffreJour(datetime.today().day, 1),
"mois" : testMoisNumero(datetime.today().day, 1)
},
"jour3" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 2),
"chiffre" : testChiffreJour(datetime.today().day, 2),
"mois" : testMoisNumero(datetime.today().day, 2)
},
"jour4" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 3),
"chiffre" : testChiffreJour(datetime.today().day, 3),
"mois" : testMoisNumero(datetime.today().day, 3)
},
"jour5" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 4),
"chiffre" : testChiffreJour(datetime.today().day, 4),
"mois" : testMoisNumero(datetime.today().day, 4)
},
"jour6" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 5),
"chiffre" : testChiffreJour(datetime.today().day, 5),
"mois" : testMoisNumero(datetime.today().day, 5)
},
"jour7" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 6),
"chiffre" : testChiffreJour(datetime.today().day, 6),
"mois" : testMoisNumero(datetime.today().day, 6)
}
}
films = []
cinemas = list(map(lambda cinema: format(cinema, 4), cinemas))
films = get_data(cinemas)
filmsClean = cleanFilms(films)
return render_template('jours/jour4.html', page_actuelle='jour4', films=filmsClean, date=date)
@app.route('/jour5')
@cache.cached(timeout=3600)
def jour5():
date = {
"jour1" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 0),
"chiffre" : testChiffreJour(datetime.today().day, 0),
"mois" : testMoisNumero(datetime.today().day, 0)
},
"jour2" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 1),
"chiffre" : testChiffreJour(datetime.today().day, 1),
"mois" : testMoisNumero(datetime.today().day, 1)
},
"jour3" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 2),
"chiffre" : testChiffreJour(datetime.today().day, 2),
"mois" : testMoisNumero(datetime.today().day, 2)
},
"jour4" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 3),
"chiffre" : testChiffreJour(datetime.today().day, 3),
"mois" : testMoisNumero(datetime.today().day, 3)
},
"jour5" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 4),
"chiffre" : testChiffreJour(datetime.today().day, 4),
"mois" : testMoisNumero(datetime.today().day, 4)
},
"jour6" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 5),
"chiffre" : testChiffreJour(datetime.today().day, 5),
"mois" : testMoisNumero(datetime.today().day, 5)
},
"jour7" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 6),
"chiffre" : testChiffreJour(datetime.today().day, 6),
"mois" : testMoisNumero(datetime.today().day, 6)
}
}
films = []
cinemas = list(map(lambda cinema: format(cinema, 5), cinemas))
films = get_data(cinemas)
filmsClean = cleanFilms(films)
return render_template('jours/jour5.html', page_actuelle='jour5', films=filmsClean, date=date)
@app.route('/jour6')
@cache.cached(timeout=3600)
def jour6():
date = {
"jour1" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 0),
"chiffre" : testChiffreJour(datetime.today().day, 0),
"mois" : testMoisNumero(datetime.today().day, 0)
},
"jour2" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 1),
"chiffre" : testChiffreJour(datetime.today().day, 1),
"mois" : testMoisNumero(datetime.today().day, 1)
},
"jour3" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 2),
"chiffre" : testChiffreJour(datetime.today().day, 2),
"mois" : testMoisNumero(datetime.today().day, 2)
},
"jour4" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 3),
"chiffre" : testChiffreJour(datetime.today().day, 3),
"mois" : testMoisNumero(datetime.today().day, 3)
},
"jour5" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 4),
"chiffre" : testChiffreJour(datetime.today().day, 4),
"mois" : testMoisNumero(datetime.today().day, 4)
},
"jour6" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 5),
"chiffre" : testChiffreJour(datetime.today().day, 5),
"mois" : testMoisNumero(datetime.today().day, 5)
},
"jour7" : {
"jour" : anglais_intoJourFrancais(datetime.today().strftime("%A"), 6),
"chiffre" : testChiffreJour(datetime.today().day, 6),
"mois" : testMoisNumero(datetime.today().day, 6)
}
}
films = []
cinemas = list(map(lambda cinema: format(cinema, 6), cinemas))
films = get_data(cinemas)
filmsClean = cleanFilms(films)
return render_template('jours/jour6.html', page_actuelle='jour6', films=filmsClean, date=date)
"""
@app.route('/process')
def process():
# Simule un traitement long
time.sleep(5)
return jsonify(status='success', message='Traitement terminé')
"""
if __name__ == '__main__':
app.run(debug=True)
=======
if __name__ == '__main__':
app.run()
>>>>>>> 142c74e5ab8db960a2486bc4c838a4833b807664
app.run()