Merge pull request #2 from wneel/patch-1

feat: create date offset function to dynamically update cinema URLs
This commit is contained in:
Solène 2025-01-24 13:47:14 +01:00 committed by GitHub
commit 2abc4b168d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

445
app.py
View file

@ -11,48 +11,13 @@ from modules.urlGenerator import decalageDate
app = Flask(__name__) app = Flask(__name__)
cache = Cache(app, config={'CACHE_TYPE': 'simple'}) cache = Cache(app, config={'CACHE_TYPE': 'simple'})
@app.route('/') def format(cinema, nb):
@cache.cached(timeout=3600) return ({
def home(): "salle": cinema["salle"],
date = { "url": decalageDate(cinema["url"], nb)
"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)
}
}
cinemas = [ cinemas_data = [
{ {
"salle" : "Écoles Cinéma Club", "salle" : "Écoles Cinéma Club",
"url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0071.html" "url" : "https://www.allocine.fr/seance/salle_gen_csalle=C0071.html"
@ -111,6 +76,49 @@ def home():
} }
] ]
@app.route('/')
@cache.cached(timeout=3600)
def home():
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)
}
}
cinemas = cinemas_data;
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)
@ -160,64 +168,7 @@ def jour1():
films = [] films = []
cinemas = [ cinemas = list(map(lambda cinema: format(cinema, 1), cinemas))
{
"salle" : "Écoles Cinéma Club",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0071.html#shwt_date=", 1)
},
{
"salle" : "MK2 Bibliothèque",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C2954.html#shwt_date=l",1)
},
{
"salle" : "MK2 Beaubourg",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0050.html#shwt_date=",1)
},
{
"salle" : "Épée de bois",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=W7504.html#shwt_date=",1)
},
{
"salle" : "Cinéma du Panthéon",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0076.html#shwt_date=",1)
},
{
"salle" : "Max Linder Panorama",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0089.html#shwt_date=",1)
},
{
"salle" : "Luminor Hotel de Ville",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0013.html#shwt_date=",1)
},
{
"salle" : "Le Grand Action",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0072.html#shwt_date=",1)
},
{
"salle" : "MK2 Parnasse",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0099.html#shwt_date=",1)
},
{
"salle" : "Le Champo",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0073.html#shwt_date=",1)
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0020.html#shwt_date=",1)
},
{
"salle" : "Reflet Medicis",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0074.html#shwt_date=",1)
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0159.html#shwt_date=",1)
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0026.html#shwt_date=",1)
}
]
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)
@ -267,64 +218,7 @@ def jour2():
films = [] films = []
cinemas = [ cinemas = list(map(lambda cinema: format(cinema, 2), cinemas))
{
"salle" : "Écoles Cinéma Club",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0071.html#shwt_date=", 2)
},
{
"salle" : "MK2 Bibliothèque",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C2954.html#shwt_date=l",2)
},
{
"salle" : "MK2 Beaubourg",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0050.html#shwt_date=",2)
},
{
"salle" : "Épée de bois",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=W7504.html#shwt_date=",2)
},
{
"salle" : "Cinéma du Panthéon",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0076.html#shwt_date=",2)
},
{
"salle" : "Max Linder Panorama",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0089.html#shwt_date=",2)
},
{
"salle" : "Luminor Hotel de Ville",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0013.html#shwt_date=",2)
},
{
"salle" : "Le Grand Action",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0072.html#shwt_date=",2)
},
{
"salle" : "MK2 Parnasse",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0099.html#shwt_date=",2)
},
{
"salle" : "Le Champo",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0073.html#shwt_date=",2)
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0020.html#shwt_date=",2)
},
{
"salle" : "Reflet Medicis",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0074.html#shwt_date=",2)
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0159.html#shwt_date=",2)
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0026.html#shwt_date=",2)
}
]
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)
@ -374,64 +268,7 @@ def jour3():
films = [] films = []
cinemas = [ cinemas = list(map(lambda cinema: format(cinema, 3), cinemas))
{
"salle" : "Écoles Cinéma Club",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0071.html#shwt_date=", 3)
},
{
"salle" : "MK2 Bibliothèque",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C2954.html#shwt_date=l",3)
},
{
"salle" : "MK2 Beaubourg",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0050.html#shwt_date=",3)
},
{
"salle" : "Épée de bois",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=W7504.html#shwt_date=",3)
},
{
"salle" : "Cinéma du Panthéon",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0076.html#shwt_date=",3)
},
{
"salle" : "Max Linder Panorama",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0089.html#shwt_date=",3)
},
{
"salle" : "Luminor Hotel de Ville",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0013.html#shwt_date=",3)
},
{
"salle" : "Le Grand Action",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0072.html#shwt_date=",3)
},
{
"salle" : "MK2 Parnasse",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0099.html#shwt_date=",3)
},
{
"salle" : "Le Champo",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0073.html#shwt_date=",3)
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0020.html#shwt_date=",3)
},
{
"salle" : "Reflet Medicis",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0074.html#shwt_date=",3)
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0159.html#shwt_date=",3)
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0026.html#shwt_date=",3)
}
]
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)
@ -481,64 +318,7 @@ def jour4():
films = [] films = []
cinemas = [ cinemas = list(map(lambda cinema: format(cinema, 4), cinemas))
{
"salle" : "Écoles Cinéma Club",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0071.html#shwt_date=", 4)
},
{
"salle" : "MK2 Bibliothèque",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C2954.html#shwt_date=l",4)
},
{
"salle" : "MK2 Beaubourg",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0050.html#shwt_date=",4)
},
{
"salle" : "Épée de bois",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=W7504.html#shwt_date=",4)
},
{
"salle" : "Cinéma du Panthéon",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0076.html#shwt_date=",4)
},
{
"salle" : "Max Linder Panorama",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0089.html#shwt_date=",4)
},
{
"salle" : "Luminor Hotel de Ville",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0013.html#shwt_date=",4)
},
{
"salle" : "Le Grand Action",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0072.html#shwt_date=",4)
},
{
"salle" : "MK2 Parnasse",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0099.html#shwt_date=",4)
},
{
"salle" : "Le Champo",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0073.html#shwt_date=",4)
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0020.html#shwt_date=",4)
},
{
"salle" : "Reflet Medicis",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0074.html#shwt_date=",4)
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0159.html#shwt_date=",4)
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0026.html#shwt_date=",4)
}
]
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)
@ -588,65 +368,7 @@ def jour5():
films = [] films = []
cinemas = [ cinemas = list(map(lambda cinema: format(cinema, 5), cinemas))
{
"salle" : "Écoles Cinéma Club",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0071.html#shwt_date=",5)
},
{
"salle" : "MK2 Bibliothèque",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C2954.html#shwt_date=l",5)
},
{
"salle" : "MK2 Beaubourg",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0050.html#shwt_date=",5)
},
{
"salle" : "Épée de bois",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=W7504.html#shwt_date=",5)
},
{
"salle" : "Cinéma du Panthéon",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0076.html#shwt_date=",5)
},
{
"salle" : "Max Linder Panorama",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0089.html#shwt_date=",5)
},
{
"salle" : "Luminor Hotel de Ville",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0013.html#shwt_date=",5)
},
{
"salle" : "Le Grand Action",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0072.html#shwt_date=",5)
},
{
"salle" : "MK2 Parnasse",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0099.html#shwt_date=",5)
},
{
"salle" : "Le Champo",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0073.html#shwt_date=",5)
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0020.html#shwt_date=",5)
},
{
"salle" : "Reflet Medicis",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0074.html#shwt_date=",5)
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0159.html#shwt_date=",5)
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0026.html#shwt_date=",5)
}
]
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)
@ -695,64 +417,7 @@ def jour6():
films = [] films = []
cinemas = [ cinemas = list(map(lambda cinema: format(cinema, 6), cinemas))
{
"salle" : "Écoles Cinéma Club",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0071.html#shwt_date=", 6)
},
{
"salle" : "MK2 Bibliothèque",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C2954.html#shwt_date=l",6)
},
{
"salle" : "MK2 Beaubourg",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0050.html#shwt_date=",6)
},
{
"salle" : "Épée de bois",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=W7504.html#shwt_date=",6)
},
{
"salle" : "Cinéma du Panthéon",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0076.html#shwt_date=",6)
},
{
"salle" : "Max Linder Panorama",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0089.html#shwt_date=",6)
},
{
"salle" : "Luminor Hotel de Ville",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0013.html#shwt_date=",6)
},
{
"salle" : "Le Grand Action",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0072.html#shwt_date=",6)
},
{
"salle" : "MK2 Parnasse",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0099.html#shwt_date=",6)
},
{
"salle" : "Le Champo",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0073.html#shwt_date=",6)
},
{
"salle" : "Filmothèque du Quartier Latin",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0020.html#shwt_date=",6)
},
{
"salle" : "Reflet Medicis",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0074.html#shwt_date=",6)
},
{
"salle" : "UGC Ciné Cité Les Halles",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0159.html#shwt_date=",6)
},
{
"salle" : "UGC Ciné Cité Bercy",
"url" : decalageDate("https://www.allocine.fr/seance/salle_gen_csalle=C0026.html#shwt_date=",6)
}
]
films = get_data(cinemas) films = get_data(cinemas)
filmsClean = cleanFilms(films) filmsClean = cleanFilms(films)