mirror of https://github.com/itsmrval/somycal
bug fix
parent
9d185f71c3
commit
85082a7bd9
9
app.py
9
app.py
|
|
@ -1,5 +1,5 @@
|
|||
from flask import Flask, redirect, url_for, session, render_template, Response, request
|
||||
from flask_oauthlib.client import OAuth
|
||||
from flask_oauthlib.client import OAuth, OAuthRemoteApp
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from datetime import datetime, timedelta
|
||||
from icalendar import Calendar, Event
|
||||
|
|
@ -9,7 +9,7 @@ load_dotenv()
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.config['SECRET_KEY'] = 'fjlksjfnklsdfnsdklfnsdkjfnsdjkfnds'
|
||||
app.config['SECRET_KEY'] = os.getenv('SESSION_SECRET')
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.db'
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
db = SQLAlchemy(app)
|
||||
|
|
@ -145,7 +145,6 @@ def generate_ical(events):
|
|||
cal = Calendar()
|
||||
for event_data in events:
|
||||
event = Event()
|
||||
print("event: ", event)
|
||||
event.add('summary', f"{event_data['hometeamTricode']} vs {event_data['awayteamTricode']} 🏀")
|
||||
event.add('location', f"🏟 {event_data['arenaName']}, {event_data['arenaCity']}")
|
||||
event.add("description", f"🎖️Scores: \n{event_data['hometeamName']} {event_data['hometeamScore']} - {event_data['awayteamScore']} {event_data['awayteamName']}")
|
||||
|
|
@ -237,7 +236,7 @@ def login():
|
|||
|
||||
@app.route('/login/google')
|
||||
def google_redirect():
|
||||
return google.authorize(callback=url_for('authorized', _external=True))
|
||||
return google.authorize(callback=url_for('authorized', _external=True, _scheme='https'))
|
||||
|
||||
@app.route('/logout')
|
||||
def logout():
|
||||
|
|
@ -263,4 +262,4 @@ if __name__ == '__main__':
|
|||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
app.run(debug=True, port=5050)
|
||||
app.run(debug=True, port=8000, host='127.0.0.1')
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
GOOGLE_KEY=""
|
||||
GOOGLE_SECRET=""
|
||||
SESSION_SECRET=""
|
||||
62
index.py
62
index.py
|
|
@ -1,62 +0,0 @@
|
|||
import requests
|
||||
import json
|
||||
|
||||
# URL du JSON
|
||||
url = "https://cdn.nba.com/static/json/staticData/scheduleLeagueV2.json"
|
||||
|
||||
# Obtenir le contenu JSON de l'URL
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
|
||||
# Liste des matchs avec les informations demandées
|
||||
matches_info = []
|
||||
|
||||
for game_date in data['leagueSchedule']['gameDates']:
|
||||
for game in game_date['games']:
|
||||
match_info = {
|
||||
'gameDateTimeUTC': game['gameDateTimeUTC'],
|
||||
'weekNumber': game['weekNumber'],
|
||||
'arenaName': game['arenaName'],
|
||||
'seriesText': game['seriesText'],
|
||||
'hometeamName': game['homeTeam']['teamName'],
|
||||
'awayteamName': game['awayTeam']['teamName'],
|
||||
}
|
||||
matches_info.append(match_info)
|
||||
|
||||
|
||||
teams_dict = {
|
||||
1: "Lakers",
|
||||
2: "Heat",
|
||||
3: "Warriors",
|
||||
4: "Celtics",
|
||||
5: "Spurs",
|
||||
6: "Knicks",
|
||||
7: "Pistons",
|
||||
8: "Magic",
|
||||
9: "Suns",
|
||||
10: "Pacers",
|
||||
11: "Jazz",
|
||||
12: "Trail Blazers",
|
||||
13: "Raptors",
|
||||
14: "Mavericks",
|
||||
15: "Bucks",
|
||||
16: "Thunder",
|
||||
17: "Bulls",
|
||||
18: "Pelicans",
|
||||
19: "Rockets",
|
||||
20: "Kings",
|
||||
21: "Clippers",
|
||||
22: "Cavaliers",
|
||||
23: "Hawks",
|
||||
24: "Grizzlies",
|
||||
25: "Nuggets",
|
||||
26: "Hornets",
|
||||
27: "76ers",
|
||||
28: "Wizards",
|
||||
29: "Timberwolves",
|
||||
30: "Nets"
|
||||
}
|
||||
|
||||
for i in matches_info:
|
||||
if (i['hometeamName'] == teams_dict[1] or i['awayteamName'] == teams_dict[1]):
|
||||
print(i['hometeamName'] + " vs " + i['awayteamName'] + " " + i['gameDateTimeUTC'])
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
</a>
|
||||
<div class="navbar-nav header-links ml-auto">
|
||||
<a class="nav-item nav-link" href="#">Accueil</a>
|
||||
<a class="nav-item nav-link" href="{{ url_for('generate_ical_feed', user_id=userId) }}" target="_blank">S'abonner au calendrier</a>
|
||||
<a class="nav-item nav-link" href="webcal://somycal.com/calendar/{{userId}}.ics" target="_blank">S'abonner au calendrier</a>
|
||||
<a class="nav-item nav-link" href="/logout">Déconnexion</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
|||
Loading…
Reference in New Issue