From c515b51a1a84ce224aecce32102b85d7a7d74628 Mon Sep 17 00:00:00 2001 From: MathiasDPX Date: Wed, 9 Oct 2024 19:15:56 +0200 Subject: [PATCH] Rebrand for Brest --- .env.example | 1 + .gitignore | 8 ++++- app.py | 59 ++++++++++++++--------------------- requirements.txt | 3 +- static/images/favicon.png | Bin 2390 -> 2368 bytes static/images/point.png | Bin 0 -> 1474 bytes static/js/infinite-scroll.js | 32 ------------------- templates/base.html | 18 ++++++----- templates/index.html | 51 +++++++++++------------------- 9 files changed, 63 insertions(+), 109 deletions(-) create mode 100644 .env.example create mode 100644 static/images/point.png delete mode 100644 static/js/infinite-scroll.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1d3e84b --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +JAWG_API_KEY="Votre clé d'API jawg.io" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4bfa70f..f7a54c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ -__pycache__/ +.env + +# IDE .vscode/ +.idea + +# Python +__pycache__/ .venv \ No newline at end of file diff --git a/app.py b/app.py index 80761cd..38221ba 100644 --- a/app.py +++ b/app.py @@ -1,36 +1,19 @@ from flask import Flask, render_template, request -from datetime import datetime, timedelta +from datetime import timedelta +from dotenv import load_dotenv +from os import getenv -# IMPORT DES MODULES +load_dotenv() + +# IMPORT DES MODULES 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 = [Theater(data["node"]) for data in + requests.get("https://www.allocine.fr/_/localization_city/Brest").json()["values"]["theaters"]] -theaters: list[Theater] = [] -for id, name in cinemas.items(): - theaters.append(Theater({ - "name": name, - "internalId": id, - "location": None - })) def getShowtimes(date): - showtimes:list[Showtime] = [] + showtimes: list[Showtime] = [] for theater in theaters: showtimes.extend(theater.getShowtimes(date)) @@ -56,7 +39,6 @@ def getShowtimes(date): "seances": {} } - if theater.name not in data[movie.title]["seances"].keys(): data[movie.title]["seances"][theater.name] = [] @@ -68,13 +50,13 @@ def getShowtimes(date): return data + showtimes = [] for i in range(0, 7): - day_showtimes = getShowtimes(datetime.today()+timedelta(days=i)) + 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!") + print(f"{len(day_showtimes)} séances récupéré {i + 1}/7!") -app = Flask(__name__) def translateMonth(num: int): match num: @@ -92,6 +74,7 @@ def translateMonth(num: int): case 12: return "déc" case _: return "???" + def translateDay(weekday: int): match weekday: case 0: return "lun" @@ -103,6 +86,9 @@ def translateDay(weekday: int): case 6: return "dim" case _: return "???" + +app = Flask(__name__) + @app.route('/') def home(): delta = request.args.get("delta", default=0, type=int) @@ -112,17 +98,20 @@ def home(): dates = [] - for i in range(0,7): - day = datetime.today()+timedelta(i) + 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, + "choisi": i == delta, "index": i }) - return render_template('index.html', page_actuelle='home', films=showtimes[delta], dates=dates) + return render_template('index.html', + films=showtimes[delta], + dates=dates, + JAWG_API_KEY=getenv("JAWG_API_KEY")) if __name__ == '__main__': - app.run() + app.run() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 0eb56cd..a704573 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Flask -requests \ No newline at end of file +requests +python-dotenv \ No newline at end of file diff --git a/static/images/favicon.png b/static/images/favicon.png index 2f0fde32c0b08b416099599b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1?otSwIwvmg|&%lU)xB7Enjv$O*kt!3M zDmzq<_L(SCWj%yRmaga&y2FU)6EG&Z&W7iMN2lFMmi7=fU4G+9mDc|}?fTSO8-@ej zO_%q;Bp{Ed7^W=Be zE~X_jBO~s+NR)hMOJ=MAuWL~5qA5qk2V1HiOX&EdH&uU$z>>XCYnY-W0cu!My$Fa%{PDsR>(FNawmd~T?kh{p? cKZ+2q0ZQ14u0C3IGXMYp07*qoM6N<$f{5p-JOBUy literal 0 HcmV?d00001 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 72ea9bd..7940ecc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,27 +4,31 @@ - - + + - grainParisArt + CinéBrest {% block head %} {% endblock %}
-

GrainParisArt

+

CinéBrest

Quand ça va pas, y aura toujours le cinéma

{% block body %} {% endblock %} - + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 050ffb5..8c56086 100644 --- a/templates/index.html +++ b/templates/index.html @@ -86,47 +86,32 @@ - -