diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a589ee0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +.vscode/ +.venv +.DS_Store \ No newline at end of file diff --git a/apiDMTB.txt b/apiDMTB.txt deleted file mode 100644 index 28eeb08..0000000 --- a/apiDMTB.txt +++ /dev/null @@ -1,5 +0,0 @@ -Clé API -### - -Jeton d'accès en lecture à l'API : -### \ No newline at end of file diff --git a/app.py b/app.py index 3cda80f..78d2f4f 100644 --- a/app.py +++ b/app.py @@ -1,15 +1,111 @@ from flask import Flask, render_template, request -from datetime import datetime -from flask_caching import Cache -import asyncio +from datetime import datetime, timedelta # IMPORT DES MODULES -from modules.date import chiffre_intoMonth, anglais_intoJourFrancais, testChiffreJour, testMoisNumero -from modules.scraping import scrap_infoFilm, get_data, cleanFilms -from modules.urlGenerator import decalageDate +from modules.Classes import * + +cinemas = { + "C0071": "Écoles Cinéma Club", + "C2954": "MK2 Bibliothèque", + "C0050": "MK2 Beaubourg", + "W7504": "Épée de bois", + "C0076": "Cinéma du Panthéon", + "C0089": "Max Linder Panorama", + "C0013": "Luminor Hotel de Ville", + "C0072": "Le Grand Action", + "C0099": "MK2 Parnasse", + "C0073": "Le Champo", + "C0020": "Filmothèque du Quartier Latin", + "C0074": "Reflet Medicis", + "C0159": "UGC Ciné Cité Les Halles", + "C0026": "UGC Ciné Cité Bercy" +} + +theaters: list[Theater] = [] +for id, name in cinemas.items(): + theaters.append(Theater({ + "name": name, + "internalId": id, + "location": None + })) + +def getShowtimes(date): + showtimes:list[Showtime] = [] + + for theater in theaters: + showtimes.extend(theater.getShowtimes(date)) + + data = {} + + for showtime in showtimes: + movie = showtime.movie + theater = showtime.theater + + if showtime.movie.title not in data.keys(): + data[movie.title] = { + "title": movie.title, + "duree": movie.runtime, + "genres": ", ".join(movie.genres), + "casting": ", ".join(movie.cast), + "realisateur": movie.director, + "synopsis": movie.synopsis, + "affiche": movie.affiche, + "director": movie.director, + "wantToSee": movie.wantToSee, + "url": f"https://www.allocine.fr/film/fichefilm_gen_cfilm={movie.id}.html", + "seances": {} + } + + + if theater.name not in data[movie.title]["seances"].keys(): + data[movie.title]["seances"][theater.name] = [] + + data[movie.title]["seances"][theater.name].append(showtime.startsAt.strftime("%H:%M")) + + data = data.values() + + data = sorted(data, key=lambda x: x["wantToSee"], reverse=True) + + return data + +showtimes = [] +for i in range(0, 7): + day_showtimes = getShowtimes(datetime.today()+timedelta(days=i)) + showtimes.append(day_showtimes) + print(f"{len(day_showtimes)} séances récupéré {i+1}/7!") app = Flask(__name__) -cache = Cache(app, config={'CACHE_TYPE': 'simple'}) + +def translateMonth(num: int): + match num: + case 1: return "janv" + case 2: return "févr" + case 3: return "mars" + case 4: return "avr" + case 5: return "mai" + case 6: return "juin" + case 7: return "juil" + case 8: return "août" + case 9: return "sept" + case 10: return "oct" + case 11: return "nov" + case 12: return "déc" + case _: return "???" + +def translateDay(weekday: int): + match weekday: + case 0: return "lun" + case 1: return "mar" + case 2: return "mer" + case 3: return "jeu" + case 4: return "ven" + case 5: return "sam" + case 6: return "dim" + case _: return "???" + +@app.route('/health') +def health(): + return "OK" def format(cinema, nb): return ({ @@ -77,54 +173,31 @@ cinemas_data = [ ] @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) - } - } + delta = request.args.get("delta", default=0, type=int) +<<<<<<< HEAD cinemas = cinemas_data; +======= + if delta > 6: delta = 6 + if delta < 0: delta = 0 +>>>>>>> 142c74e5ab8db960a2486bc4c838a4833b807664 - films = get_data(cinemas) - filmsClean = cleanFilms(films) + dates = [] - return render_template('index.html', page_actuelle='home', films=filmsClean, date=date) + for i in range(0,7): + day = datetime.today()+timedelta(i) + dates.append({ + "jour": translateDay(day.weekday()), + "chiffre": day.day, + "mois": translateMonth(day.month), + "choisi": i==delta, + "index": i + }) + return render_template('index.html', page_actuelle='home', films=showtimes[delta], dates=dates) +<<<<<<< HEAD @app.route('/jour1') @cache.cached(timeout=3600) def jour1(): @@ -433,3 +506,7 @@ def process(): """ if __name__ == '__main__': app.run(debug=True) +======= +if __name__ == '__main__': + app.run() +>>>>>>> 142c74e5ab8db960a2486bc4c838a4833b807664 diff --git a/modules/Classes.py b/modules/Classes.py new file mode 100644 index 0000000..b85889d --- /dev/null +++ b/modules/Classes.py @@ -0,0 +1,129 @@ +from datetime import datetime +import requests + +class Movie: + def __init__(self, data) -> None: + self.data = data + self.title = data["title"] + self.id = data['internalId'] + self.runtime = data["runtime"] + self.synopsis = data["synopsis"] + self.genres = [genre['translate'] for genre in data["genres"]] + self.wantToSee = data['stats']["wantToSeeCount"] + try: + self.affiche = data["poster"]["url"] + except: + self.affiche = "/static/images/nocontent.png" + + self.cast = [] + + # Noms des acteurs + for actor in data["cast"]["edges"]: + if actor["node"]["actor"] == None: continue + + if actor["node"]["actor"]["lastName"] == None: + actor["node"]["actor"]["lastName"] = "" + + if actor["node"]["actor"]["firstName"] == None: + actor["node"]["actor"]["firstName"] = "" + + name = f'{actor["node"]["actor"]["firstName"]} {actor["node"]["actor"]["lastName"]}' + name = name.lstrip() + self.cast.append(name) + + # Nom du réalisateur + if len(data["credits"]) == 0: + self.director = "Inconnu" + else: + if data["credits"][0]["person"]["lastName"] == None: + data["credits"][0]["person"]["lastName"] = "" + + if data["credits"][0]["person"]["firstName"] == None: + data["credits"][0]["person"]["firstName"] = "" + + self.director = f'{data["credits"][0]["person"]["firstName"]} {data["credits"][0]["person"]["lastName"]}' + self.director = self.director.lstrip() + + def __repr__(self) -> str: + return f"<{self.__class__.__name__} name={self.title}>" + +class Showtime: + def __init__(self, data, theather, movie:Movie) -> None: + self.startsAt = datetime.fromisoformat(data['startsAt']) + self.diffusionVersion = data['diffusionVersion'] + self.services = data["service"] + self.theater:Theater = theather + self.movie = movie + + def __repr__(self) -> str: + return f"<{self.__class__.__name__} name={self.movie.title} startsAt={self.startsAt}>" + +class Theater: + def __init__(self, data) -> None: + self.name = data['name'] + self.id = data['internalId'] + self.location = data['location'] + + def __repr__(self) -> str: + return f"<{self.__class__.__name__} name={self.name}>" + + def getShowtimes(self, date: datetime, page: int = 1, showtimes: list = None) -> list[Showtime]: + if showtimes is None: + showtimes = [] + + datestr = date.strftime("%Y-%m-%d") + r = requests.get(f"https://www.allocine.fr/_/showtimes/theater-{self.id}/d-{datestr}/p-{page}/") + + if r.status_code != 200: + raise Exception(f"Error: {r.status_code} - {r.content}") + + try: + data = r.json() + except Exception as e: + raise Exception(f"Can't parse JSON: {str(e)} - {r.content}") + + if data["message"] == "no.showtime.error": + return [] + + if data["message"] == "next.showtime.on": + return [] + + if data.get('error'): + raise Exception(f"API Error: {data}") + + for movie in data['results']: + inst = Movie(movie["movie"]) + movie_showtimes = movie["showtimes"].get("dubbed", []) + \ + movie["showtimes"].get("original", []) + \ + movie["showtimes"].get("local", []) + + for showtime_data in movie_showtimes: + showtimes.append(Showtime(showtime_data, self, inst)) + + if int(data['pagination']['page']) < int(data['pagination']["totalPages"]): + return self.getShowtimes(date, page + 1, showtimes) + + return showtimes + + @staticmethod + def new(query:str): + r = requests.get(f"https://www.allocine.fr/_/localization_city/{query}") + + try: + data = r.json() + except: + return {"error": True, "message": "Can't parse JSON", "content": r.content} + + if len(data["values"]["theaters"]) == 0: + return {"error": True, "message": "Not found", "content": r.content} + + return Theater(data["values"]["theaters"][0]["node"]) + +if __name__ == "__main__": + cgr = Theater.new("CGR Brest Le Celtic") + print(f"{cgr.name} ({cgr.id})") + print(f"{cgr.location['zip']} {cgr.location['city']}") + + showtimes = cgr.getShowtimes(datetime.today()) + + print(showtimes[0]) \ No newline at end of file diff --git a/modules/__pycache__/date.cpython-312.pyc b/modules/__pycache__/date.cpython-312.pyc deleted file mode 100644 index 8c136f5..0000000 Binary files a/modules/__pycache__/date.cpython-312.pyc and /dev/null differ diff --git a/modules/__pycache__/firebase.cpython-312.pyc b/modules/__pycache__/firebase.cpython-312.pyc deleted file mode 100644 index c9386ce..0000000 Binary files a/modules/__pycache__/firebase.cpython-312.pyc and /dev/null differ diff --git a/modules/__pycache__/scraping.cpython-312.pyc b/modules/__pycache__/scraping.cpython-312.pyc deleted file mode 100644 index 2f8c626..0000000 Binary files a/modules/__pycache__/scraping.cpython-312.pyc and /dev/null differ diff --git a/modules/__pycache__/urlGenerator.cpython-312.pyc b/modules/__pycache__/urlGenerator.cpython-312.pyc deleted file mode 100644 index 8b2a052..0000000 Binary files a/modules/__pycache__/urlGenerator.cpython-312.pyc and /dev/null differ diff --git a/modules/date.py b/modules/date.py deleted file mode 100644 index 38d008b..0000000 --- a/modules/date.py +++ /dev/null @@ -1,200 +0,0 @@ -import time -from datetime import datetime - -# Converti les mois en chiffre en lettres -def chiffre_intoMonth(month): - match month: - case 1: - return 'janvier' - case 2: - return 'février' - case 3: - return 'mars' - case 4: - return 'avril' - case 5: - return 'mai' - case 6: - return 'juin' - case 7: - return 'juillet' - case 8: - return 'août' - case 9: - return 'septembre' - case 10: - return 'octobre' - case 11: - return 'novembre' - case 12: - return 'décembre' - case _: - return 'invalid month' - -# Calcule le décallage des jours et traduits en lettres -def anglais_intoJourFrancais(jour, decalage): - if decalage == 0: - match jour: - case "Monday": - return 'lun' - case 'Tuesday': - return 'mar' - case 'Wednesday': - return 'mer' - case 'Thursday': - return 'jeu' - case 'Friday': - return 'ven' - case 'Saturday': - return 'sam' - case 'Sunday': - return 'dim' - case _: - return 'invalid jour' - elif decalage == 1: - match jour: - case "Monday": - return 'mar' - case 'Tuesday': - return 'mer' - case 'Wednesday': - return 'jeu' - case 'Thursday': - return 'ven' - case 'Friday': - return 'sam' - case 'Saturday': - return 'dim' - case 'Sunday': - return 'lun' - case _: - return 'invalid jour' - elif decalage == 2: - match jour: - case "Monday": - return 'mer' - case 'Tuesday': - return 'jeu' - case 'Wednesday': - return 'ven' - case 'Thursday': - return 'sam' - case 'Friday': - return 'dim' - case 'Saturday': - return 'lun' - case 'Sunday': - return 'mar' - case _: - return 'invalid jour' - elif decalage == 3: - match jour: - case "Monday": - return 'jeu' - case 'Tuesday': - return 'ven' - case 'Wednesday': - return 'sam' - case 'Thursday': - return 'dim' - case 'Friday': - return 'lun' - case 'Saturday': - return 'mar' - case 'Sunday': - return 'mer' - case _: - return 'invalid jour' - elif decalage == 4: - match jour: - case "Monday": - return 'ven' - case 'Tuesday': - return 'sam' - case 'Wednesday': - return 'dim' - case 'Thursday': - return 'lun' - case 'Friday': - return 'mar' - case 'Saturday': - return 'mer' - case 'Sunday': - return 'jeu' - case _: - return 'invalid jour' - elif decalage == 5: - match jour: - case "Monday": - return 'sam' - case 'Tuesday': - return 'dim' - case 'Wednesday': - return 'lun' - case 'Thursday': - return 'mar' - case 'Friday': - return 'mer' - case 'Saturday': - return 'jeu' - case 'Sunday': - return 'ven' - case _: - return 'invalid jour' - elif decalage == 6: - match jour: - case "Monday": - return 'dim' - case 'Tuesday': - return 'lun' - case 'Wednesday': - return 'mar' - case 'Thursday': - return 'mer' - case 'Friday': - return 'jeu' - case 'Saturday': - return 'ven' - case 'Sunday': - return 'sam' - case _: - return 'invalid jour' - -def testChiffreJour(chiffre, decalage): - today = datetime.today() - month = today.month - - if month in [1, 3, 5, 7, 8, 10, 12]: - max_days = 31 - elif month == 2: - if (today.year % 4 == 0 and today.year % 100 != 0) or (today.year % 400 == 0): - max_days = 29 - else: - max_days = 28 - else: - max_days = 30 - - if chiffre + decalage > max_days: - return chiffre + decalage - max_days - else: - return chiffre + decalage - -def testMoisNumero(chiffre, decalage): - today = datetime.today() - month = today.month - - if month in [1, 3, 5, 7, 8, 10, 12]: - max_days = 31 - elif month == 2: - if (today.year % 4 == 0 and today.year % 100 != 0) or (today.year % 400 == 0): - max_days = 29 - else: - max_days = 28 - else: - max_days = 30 - - if chiffre + decalage > max_days: - next_month = month + 1 if month < 12 else 1 - return chiffre_intoMonth(next_month) - else: - return chiffre_intoMonth(month) \ No newline at end of file diff --git a/modules/firebase.py b/modules/firebase.py deleted file mode 100644 index 32e1e2a..0000000 --- a/modules/firebase.py +++ /dev/null @@ -1,74 +0,0 @@ -import firebase_admin -from firebase_admin import credentials, db -import urllib.parse - -cred = credentials.Certificate('static/firebase/firebase_grainParisArt.json') -firebase_admin.initialize_app(cred, { - 'databaseURL': '###' -}) - -ref = db.reference('/') - -film = { - 'titre': "L'I.A. du mal", - 'realisateur': 'Luca Guadagnino', - 'casting': [' Zendaya', "Josh O'Connor", 'Mike Faist'], - 'genres': ['Drame', 'Romance'], - 'duree': {'heure': 2, 'minute': 12}, - 'affiche': 'https://fr.web.img2.acsta.net/c_310_420/pictures/24/01/15/10/08/2202044.jpg', - 'synopsis': '\nDurant leurs études, Patrick et Art, tombent amoureux de Tashi. À la fois amis, amants et rivaux, ils voient tous les trois leurs chemins se recroiser des années plus tard. Leur passé et leur présent s’entrechoquent et des tensions jusque-là inavouées refont surface.\n', - 'horaires': [{'cinema': 'MK2 Parnasse', 'seances': ['20:45']}] -} - -def encode_node_name(name): - replacements = { - '.': '__dot__', - '$': '__dollar__', - '#': '__hash__', - '[': '__lbrack__', - ']': '__rbrack__', - '/': '__slash__', - '?': '__question__' - } - - for char, replacement in replacements.items(): - name = name.replace(char, replacement) - - return name - - -def enregistrementFilm(film): - cleaned_movie_name = encode_node_name(film['titre']) - movie_ref = ref.child(cleaned_movie_name) - movie_ref.set({ - 'titre': film['titre'], - 'realisateur': film['realisateur'], - 'casting': film['casting'], - 'genres': film['genres'], - 'duree': film['duree'], - 'affiche': film['affiche'], - 'synopsis': film['synopsis'] - }) - print(f"Node '{film['titre']}' created successfully with details!") - -def recupererDataFilm(nomFilm, realisateur): - cleaned_movie_name = encode_node_name(nomFilm) - print(cleaned_movie_name) - movie_ref = ref.child(cleaned_movie_name) - - # Lire les données du nœud - movie_data = movie_ref.get() - - if movie_data: - # Vérifier si le réalisateur correspond - if movie_data.get('realisateur') == realisateur: - return movie_data - else: - return 0 - else: - return 0 - -def supprimerTousLesFilms(): - root_ref = ref - root_ref.delete() - print("Tous les films ont été supprimés.") diff --git a/modules/scraping.py b/modules/scraping.py deleted file mode 100644 index bf10d48..0000000 --- a/modules/scraping.py +++ /dev/null @@ -1,153 +0,0 @@ -from bs4 import BeautifulSoup -import requests -import requests_cache -from datetime import timedelta -from modules.firebase import enregistrementFilm, recupererDataFilm - - -requests_cache.install_cache('film_cache', expire_after=timedelta(minutes=5)) - -# Récolte les données -def scrap_infoFilm(url, cinema): - films = [] - response = requests.get(url) - reponse_text = response.text - soupReponse = BeautifulSoup(reponse_text, 'html.parser') - - # films_list = soupReponse.find('div', class_="showtimes-list-holder").find_all('div', class_="card entity-card entity-card-list movie-card-theater cf hred") - films_list_container = soupReponse.find('div', class_="showtimes-list-holder") - if films_list_container: - films_list = films_list_container.find_all('div', class_="card entity-card entity-card-list movie-card-theater cf hred") - for film in films_list: - titre = film.find("div", class_="meta").find('h2', class_="meta-title").find("a").get_text() - realisateur_section = film.find("div", class_="meta-body-item meta-body-direction") - - if realisateur_section: - realisateur = realisateur_section.find('span', class_="dark-grey-link").get_text() - else: - realisateur = "Réalisateur non trouvé" - - dataFilm_firebase = recupererDataFilm(titre, realisateur) - if dataFilm_firebase == 0: - # Extraction de l'image - thumbnail_img = film.find('img', class_='thumbnail-img') - if thumbnail_img and not thumbnail_img['src'].startswith('data:image'): - img_url = thumbnail_img['src'] - else: - urlAffiche = "https://www.allocine.fr" + film.find("div", class_="meta").find('h2', class_="meta-title").find("a")['href'] - responseAffiche = requests.get(urlAffiche) - pageFilm = BeautifulSoup(responseAffiche.text, 'html.parser') - thumbnail_img = pageFilm.find('img', class_='thumbnail-img') - img_url = thumbnail_img['src'] if thumbnail_img and not thumbnail_img['src'].startswith('data:image') else 'Image de la vignette non trouvée' - - synopsis = film.find('div', class_="synopsis").find('div', class_="content-txt").get_text() if film.find('div', class_="synopsis") else "synopsis non trouvé" - acteur_container = film.find("div", class_="meta-body-item meta-body-actor") - acteurs = [acteur.get_text() for acteur in acteur_container.find_all("span", class_="dark-grey-link")] if acteur_container else ["acteurs non trouvés"] - - horaire_sections = film.find_all("div", class_="showtimes-hour-block") - horaires = [horaire_section.find('span', class_="showtimes-hour-item-value").get_text() for horaire_section in horaire_sections if horaire_section.find('span', class_="showtimes-hour-item-value")] or ["Horaire non trouvé"] - - genre_container = film.find("div", class_="meta-body-item meta-body-info") - genres = [span.get_text().strip() for span in genre_container.find_all("span") if 'class' in span.attrs and not span.attrs['class'][0].startswith('spacer') and 'nationality' not in span.attrs['class']] if genre_container else ["Genre non trouvé"] - if genres: genres.pop(0) - - # Récupération de la durée du film - url = "https://api.themoviedb.org/3/search/movie?query=" + titre - - headers = { - "accept": "application/json", - "Authorization": "###" - } - - response = requests.get(url, headers=headers) - - if response.status_code == 200: - data = response.json() - if data['results']: - film_id = data['results'][0]['id'] - url = "https://api.themoviedb.org/3/movie/" + str(film_id) - response = requests.get(url, headers=headers) - - data = response.json() - duree_film = data['runtime'] - - heure = duree_film // 60 - minute = duree_film % 60 - else: - heure = 0 - minute = 0 - else: - heure = 0 - minute = 0 - - film_data = { - "titre": titre, - "realisateur": realisateur, - "casting": acteurs, - "genres": genres, - "duree": {"heure": heure, "minute": minute}, - "affiche": img_url, - "synopsis": synopsis, - "horaires": [ - { - "cinema": cinema, - "seances": horaires - } - ] - } - enregistrementFilm(film_data) - print(f"{film_data['titre']} : enregistré dans la db") - else: - horaire_sections = film.find_all("div", class_="showtimes-hour-block") - horaires = [horaire_section.find('span', class_="showtimes-hour-item-value").get_text() for horaire_section in horaire_sections if horaire_section.find('span', class_="showtimes-hour-item-value")] or ["Horaire non trouvé"] - - film_data = { - "titre": dataFilm_firebase['titre'], - "realisateur": dataFilm_firebase['realisateur'], - "casting": dataFilm_firebase['casting'], - 'genres': ['Drame', 'Romance'], - "duree": dataFilm_firebase['duree'], - "affiche": dataFilm_firebase['affiche'], - "synopsis": dataFilm_firebase['synopsis'], - "horaires": [ - { - "cinema": cinema, - "seances": horaires - } - ] - } - print(f"{film_data['titre']} : récupéré dans la db") - - # Ajout du film s'il n'existe pas déjà - existing_film = next((f for f in films if f["titre"] == titre), None) - if existing_film: - existing_film["horaires"].append({ - "cinema": cinema, - "seances": horaires - }) - else: - films.append(film_data) - else: - print(f"L'élément 'showtimes-list-holder' n'a pas été trouvé pour l'URL {url}") - films_list = [] - return films - -def get_data(cinemas): - films = [] - for cinema in cinemas: - result = scrap_infoFilm(cinema["url"], cinema["salle"]) - films.extend(result) - return films - -def cleanFilms(films): - filmsClean = [] - for film in films: - existing_film = next((f for f in filmsClean if f["titre"] == film["titre"]), None) - if existing_film: - existing_film["horaires"].append({ - "cinema": film["horaires"][0]["cinema"], - "seances": film["horaires"][0]["seances"] - }) - else: - filmsClean.append(film) - return filmsClean \ No newline at end of file diff --git a/modules/urlGenerator.py b/modules/urlGenerator.py deleted file mode 100644 index b4eb3b0..0000000 --- a/modules/urlGenerator.py +++ /dev/null @@ -1,14 +0,0 @@ -import time -from datetime import datetime, timedelta -import datetime - -def decalageDate(baseURL, decalage): - future_date = datetime.datetime.today() + datetime.timedelta(days=decalage) - - formatted_date = future_date.strftime("%Y-%m-%d") - - url = baseURL + formatted_date - - print(url) - return (url) - diff --git a/requirements.txt b/requirements.txt index 6d93b7a..0eb56cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,52 +1,2 @@ -attrs==24.2.0 -beautifulsoup4==4.12.3 -blinker==1.8.2 -bs4==0.0.2 -CacheControl==0.14.0 -cachelib==0.9.0 -cachetools==5.4.0 -cattrs==23.2.3 -certifi==2024.7.4 -cffi==1.17.0 -charset-normalizer==3.3.2 -click==8.1.7 -cryptography==43.0.0 -firebase-admin==6.5.0 -Flask==3.0.3 -Flask-Caching==2.3.0 -google-api-core==2.19.1 -google-api-python-client==2.140.0 -google-auth==2.33.0 -google-auth-httplib2==0.2.0 -google-cloud-core==2.4.1 -google-cloud-firestore==2.17.1 -google-cloud-storage==2.18.2 -google-crc32c==1.5.0 -google-resumable-media==2.7.2 -googleapis-common-protos==1.63.2 -grpcio==1.65.4 -grpcio-status==1.62.3 -httplib2==0.22.0 -idna==3.7 -itsdangerous==2.2.0 -Jinja2==3.1.4 -MarkupSafe==2.1.5 -msgpack==1.0.8 -mysql-connector-python==9.0.0 -platformdirs==4.2.2 -proto-plus==1.24.0 -protobuf==4.25.4 -pyasn1==0.6.0 -pyasn1_modules==0.4.0 -pycparser==2.22 -PyJWT==2.9.0 -pyparsing==3.1.2 -requests==2.32.3 -requests-cache==1.2.1 -rsa==4.9 -six==1.16.0 -soupsieve==2.5 -uritemplate==4.1.1 -url-normalize==1.4.3 -urllib3==2.2.2 -Werkzeug==3.0.3 +Flask +requests \ No newline at end of file diff --git a/static/.DS_Store b/static/.DS_Store deleted file mode 100644 index 2a043aa..0000000 Binary files a/static/.DS_Store and /dev/null differ diff --git a/static/firebase/firebase_grainParisArt.json b/static/firebase/firebase_grainParisArt.json deleted file mode 100644 index e69de29..0000000 diff --git a/static/images/LaurenceAnyways.jpg b/static/images/LaurenceAnyways.jpg deleted file mode 100644 index 4aaf79e..0000000 Binary files a/static/images/LaurenceAnyways.jpg and /dev/null differ diff --git a/static/images/aftersun.jpeg b/static/images/aftersun.jpeg deleted file mode 100644 index f0ca262..0000000 Binary files a/static/images/aftersun.jpeg and /dev/null differ diff --git a/static/images/background.png b/static/images/background.png deleted file mode 100644 index 3e0a1b5..0000000 Binary files a/static/images/background.png and /dev/null differ diff --git a/static/images/julieEn12Chapitre.webp b/static/images/julieEn12Chapitre.webp deleted file mode 100644 index 43d0dd1..0000000 Binary files a/static/images/julieEn12Chapitre.webp and /dev/null differ diff --git a/static/images/nocontent.png b/static/images/nocontent.png new file mode 100644 index 0000000..66f6315 Binary files /dev/null and b/static/images/nocontent.png differ diff --git a/static/images/old.png b/static/images/old.png deleted file mode 100644 index 8e6e9ea..0000000 Binary files a/static/images/old.png and /dev/null differ diff --git a/static/js/infinite-scroll.js b/static/js/infinite-scroll.js deleted file mode 100644 index 6b6daab..0000000 --- a/static/js/infinite-scroll.js +++ /dev/null @@ -1,32 +0,0 @@ -var isLoading = false; -var page = 1; - -function fetchCinemaSessions() { - if (isLoading) return; - - isLoading = true; - var loadingContainer = document.getElementById('loading-container'); - loadingContainer.innerHTML = 'Loading...'; - - fetch('/?page=' + page) - .then(function(response) { - return response.text(); - }) - .then(function(html) { - var cinemaContainer = document.getElementById('cinema-container'); - cinemaContainer.insertAdjacentHTML('beforeend', html); - isLoading = false; - page += 1; - }) - .catch(function() { - isLoading = false; - }); -} - -window.addEventListener('scroll', function() { - if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 100 && !isLoading) { - fetchCinemaSessions(); - } -}); - -fetchCinemaSessions(); diff --git a/templates/base.html b/templates/base.html index d711ab3..72ea9bd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,6 +7,7 @@ + grainParisArt {% block head %} {% endblock %} diff --git a/templates/index.html b/templates/index.html index 506bb60..050ffb5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,54 +5,14 @@ {% endblock %} {% block body %} - +

🍿

- - - +
@@ -62,69 +22,39 @@

Emploi du temps

+ {% for date in dates %} + {% if date.choisi %}
-

{{date.jour1.jour}}

-

{{date.jour1.chiffre}}

-

{{date.jour1.mois}}

+

{{date.jour}}

+

{{date.chiffre}}

+

{{date.mois}}

- + {% else %} +
-

{{date.jour2.jour}}

-

{{date.jour2.chiffre}}

-

{{date.jour2.mois}}

-
-
- -
-

{{date.jour3.jour}}

-

{{date.jour3.chiffre}}

-

{{date.jour3.mois}}

-
-
- -
-

{{date.jour4.jour}}

-

{{date.jour4.chiffre}}

-

{{date.jour4.mois}}

-
-
- -
-

{{date.jour5.jour}}

-

{{date.jour5.chiffre}}

-

{{date.jour5.mois}}

-
-
- -
-

{{date.jour6.jour}}

-

{{date.jour6.chiffre}}

-

{{date.jour6.mois}}

-
-
- -
-

{{date.jour7.jour}}

-

{{date.jour7.chiffre}}

-

{{date.jour7.mois}}

+

{{date.jour}}

+

{{date.chiffre}}

+

{{date.mois}}

+ {% endif %} + {% endfor %}
{% for film in films %}
- +
-

{{film.titre}}

+

{{film.title}}

-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

+

Réalisateur : {{film.director}}

+

Casting : {{ film.casting }}

+

Genre : {{ film.genres }}

+

Durée : {{film.duree}}

@@ -136,13 +66,13 @@

- {% for horaire in film.horaires %} + {% for cinename, seances in film.seances.items() %}
-

{{horaire.cinema}}

+

{{cinename}}

- {% for seance in horaire.seances %} + {% for seance in seances %}

{{seance}}

diff --git a/templates/jours/jour1.html b/templates/jours/jour1.html deleted file mode 100644 index d31e6f9..0000000 --- a/templates/jours/jour1.html +++ /dev/null @@ -1,199 +0,0 @@ -{% extends 'base.html' %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-

🍿

-
-
- - - - - -
- -
- - {% for film in films %} -
- -
-
-
-

{{film.titre}}

-
-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

-
-
-

- {{film.synopsis}} -

-
-
-
-
- -
- {% for horaire in film.horaires %} -
-
-

{{horaire.cinema}}

-
-
- {% for seance in horaire.seances %} -
-

{{seance}}

-
- {% endfor %} -
-
-
- {% endfor %} -
- {% endfor %} - -
- - - - - - - -{% endblock %} \ No newline at end of file diff --git a/templates/jours/jour2.html b/templates/jours/jour2.html deleted file mode 100644 index 736cf92..0000000 --- a/templates/jours/jour2.html +++ /dev/null @@ -1,198 +0,0 @@ -{% extends 'base.html' %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-

🍿

-
-
- - - - - -
- -
- - {% for film in films %} -
- -
-
-
-

{{film.titre}}

-
-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

-
-
-

- {{film.synopsis}} -

-
-
-
-
- -
- {% for horaire in film.horaires %} -
-
-

{{horaire.cinema}}

-
-
- {% for seance in horaire.seances %} -
-

{{seance}}

-
- {% endfor %} -
-
-
- {% endfor %} -
- {% endfor %} -
- - - - - - - -{% endblock %} \ No newline at end of file diff --git a/templates/jours/jour3.html b/templates/jours/jour3.html deleted file mode 100644 index 5690804..0000000 --- a/templates/jours/jour3.html +++ /dev/null @@ -1,196 +0,0 @@ -{% extends 'base.html' %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-

🍿

-
-
- - - - - -
- -
- - {% for film in films %} -
- -
-
-
-

{{film.titre}}

-
-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

-
-
-

- {{film.synopsis}} -

-
-
-
-
- -
- {% for horaire in film.horaires %} -
-
-

{{horaire.cinema}}

-
-
- {% for seance in horaire.seances %} -
-

{{seance}}

-
- {% endfor %} -
-
-
- {% endfor %} -
- {% endfor %} -
- - - - - -{% endblock %} \ No newline at end of file diff --git a/templates/jours/jour4.html b/templates/jours/jour4.html deleted file mode 100644 index d69951d..0000000 --- a/templates/jours/jour4.html +++ /dev/null @@ -1,196 +0,0 @@ -{% extends 'base.html' %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-

🍿

-
-
- - - - - -
- -
- - {% for film in films %} -
- -
-
-
-

{{film.titre}}

-
-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

-
-
-

- {{film.synopsis}} -

-
-
-
-
- -
- {% for horaire in film.horaires %} -
-
-

{{horaire.cinema}}

-
-
- {% for seance in horaire.seances %} -
-

{{seance}}

-
- {% endfor %} -
-
-
- {% endfor %} -
- {% endfor %} -
- - - - - -{% endblock %} \ No newline at end of file diff --git a/templates/jours/jour5.html b/templates/jours/jour5.html deleted file mode 100644 index 7b3e92a..0000000 --- a/templates/jours/jour5.html +++ /dev/null @@ -1,197 +0,0 @@ -{% extends 'base.html' %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-

🍿

-
-
- - - - - -
- -
- - {% for film in films %} -
- -
-
-
-

{{film.titre}}

-
-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

-
-
-

- {{film.synopsis}} -

-
-
-
-
- -
- {% for horaire in film.horaires %} -
-
-

{{horaire.cinema}}

-
-
- {% for seance in horaire.seances %} -
-

{{seance}}

-
- {% endfor %} -
-
-
- {% endfor %} -
- {% endfor %} -
- - - - - - -{% endblock %} \ No newline at end of file diff --git a/templates/jours/jour6.html b/templates/jours/jour6.html deleted file mode 100644 index 04b0767..0000000 --- a/templates/jours/jour6.html +++ /dev/null @@ -1,197 +0,0 @@ -{% extends 'base.html' %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-

🍿

-
-
- - - - - -
- -
- - {% for film in films %} -
- -
-
-
-

{{film.titre}}

-
-

Réalisateur : {{film.realisateur}}

-

Casting : {% for acteur in film.casting %}{{acteur}}, {% endfor %}

-

Genre : {% for genre in film.genres %}{{genre}}, {% endfor %}

-

Durée : {{film.duree.heure}}h{{film.duree.minute}}

-
-
-

- {{film.synopsis}} -

-
-
-
-
- -
- {% for horaire in film.horaires %} -
-
-

{{horaire.cinema}}

-
-
- {% for seance in horaire.seances %} -
-

{{seance}}

-
- {% endfor %} -
-
-
- {% endfor %} -
- {% endfor %} -
- - - - - - -{% endblock %} \ No newline at end of file