Skip to content

Commit 9ce03ca

Browse files
committed
ajout de plus de programme dans l'affichage de l'EPG
1 parent c07fb6e commit 9ce03ca

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

main.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from PyQt6 import QtWidgets
88
from PyQt6.QtGui import QPixmap, QColor, QPalette, QIcon, QPainter
99
from PyQt6.QtCore import Qt, QObject, QSize, QEvent, pyqtSignal, QPropertyAnimation, QEasingCurve, QTimer, QThread
10-
from PyQt6.QtWidgets import QMessageBox, QDialog, QLineEdit, QPushButton, QCheckBox, QTableWidgetItem, QApplication, QMainWindow, QStackedWidget, QVBoxLayout, QScrollArea, QWidget, QGridLayout, QToolButton, QSplitter, QHBoxLayout, QLabel
10+
from PyQt6.QtWidgets import QTableWidget, QMessageBox, QDialog, QLineEdit, QPushButton, QCheckBox, QTableWidgetItem, QApplication, QMainWindow, QStackedWidget, QVBoxLayout, QScrollArea, QWidget, QGridLayout, QToolButton, QSplitter, QHBoxLayout, QLabel
1111
import vlc
1212
from io import BytesIO
1313
from functools import lru_cache
@@ -158,12 +158,24 @@ def load_channel_info(self):
158158
return {}
159159

160160
def load_epg_data(self):
161-
url = f"http://mafreebox.freebox.fr/api/v8/tv/epg/by_time/{int(time.time())}"
161+
now = int(time.time())
162+
two_hours = 2 * 60 * 60
163+
twenty_four_hours = 24 * 60 * 60
164+
all_data = {}
162165
try:
163-
response = requests.get(url, timeout=60)
164-
response.raise_for_status()
165-
data = response.json()
166-
return data['result']
166+
for timestamp in range(now - two_hours, now + twenty_four_hours, 3600): # Ajout de pas d'une heure
167+
url = f"http://mafreebox.freebox.fr/api/v8/tv/epg/by_time/{timestamp}"
168+
response = requests.get(url, timeout=60)
169+
response.raise_for_status()
170+
data = response.json()
171+
if 'result' in data:
172+
for uuid, value in data['result'].items():
173+
if uuid in all_data:
174+
# Ici, dépend de la structure des données, par exemple, ajouter à une liste ou mettre à jour un sous-dictionnaire
175+
all_data[uuid].update(value) # Si c'est un dictionnaire
176+
else:
177+
all_data[uuid] = value
178+
return all_data
167179
except requests.RequestException as e:
168180
logger.error(f"Failed to load EPG data: {e}", exc_info=True)
169181
return {}
@@ -185,7 +197,6 @@ def enrich_epg_data(self, epg_data, channel_info):
185197
enriched_data[uuid_ordered] = enriched_programs
186198
else:
187199
logger.error(f"Missing program data for UUID: {uuid_ordered}")
188-
189200
return enriched_data
190201

191202
def emit_sorted_data(self, channel_info, epg_data):
@@ -998,7 +1009,6 @@ def add_epg_display_widget(self):
9981009
self.epg_table = EPGTable(self)
9991010
self.data_thread = DataLoadThread(self.ordered_uuids)
10001011
self.data_thread.data_loaded.connect(self.epg_table.populate_table_with_ordered_info)
1001-
# self.data_thread.channels_loaded.connect(self.epg_table.on_channels_loaded)
10021012
self.data_thread.start()
10031013

10041014
if not self.is_widget_in_layout(self.info_widget_area.layout(), self.epg_table):

0 commit comments

Comments
 (0)