mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-23 23:18:06 +02:00
feat: Implement EPG API with caching and Xtream get_epg to get_short_epg fallback for program data.
This commit is contained in:
1 parent
3232a3a226
commit
b1f887af69
2 files changed
+27
-14
No files matched your search
+23
-11
@@ -34,24 +34,36 @@ class EpgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final dns = playlist.dns;
|
final dns = playlist.dns;
|
||||||
// Appel API Xtream pour l'EPG complet de la chaîne
|
// 1. Tenter d'abord l'EPG complet (48h)
|
||||||
final url =
|
var url =
|
||||||
'$dns/player_api.php?username=${playlist.username}&password=${playlist.password}'
|
'$dns/player_api.php?username=${playlist.username}&password=${playlist.password}'
|
||||||
'&action=get_epg&stream_id=$channelId&limit=48';
|
'&action=get_epg&stream_id=$channelId&limit=48';
|
||||||
|
|
||||||
final response =
|
var response =
|
||||||
await http.get(Uri.parse(url)).timeout(const Duration(seconds: 15));
|
await http.get(Uri.parse(url)).timeout(const Duration(seconds: 15));
|
||||||
|
Map<String, dynamic> epgData = {
|
||||||
|
'channel_id': channelId,
|
||||||
|
'programmes': []
|
||||||
|
};
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode == 200) {
|
||||||
return Response(response.statusCode,
|
final raw = json.decode(response.body);
|
||||||
body: json
|
epgData = _transformEpgData(raw, channelId);
|
||||||
.encode({'error': 'Erreur API Xtream: ${response.statusCode}'}),
|
}
|
||||||
headers: {'Content-Type': 'application/json'});
|
|
||||||
|
// 2. Fallback EPG court si le complet est vide
|
||||||
|
if ((epgData['programmes'] as List).isEmpty) {
|
||||||
|
url =
|
||||||
|
'$dns/player_api.php?username=${playlist.username}&password=${playlist.password}'
|
||||||
|
'&action=get_short_epg&stream_id=$channelId';
|
||||||
|
response =
|
||||||
|
await http.get(Uri.parse(url)).timeout(const Duration(seconds: 10));
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final raw = json.decode(response.body);
|
||||||
|
epgData = _transformEpgData(raw, channelId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reformater les données pour la grille TV
|
|
||||||
final raw = json.decode(response.body);
|
|
||||||
final epgData = _transformEpgData(raw, channelId);
|
|
||||||
final jsonStr = json.encode(epgData);
|
final jsonStr = json.encode(epgData);
|
||||||
|
|
||||||
// Mettre en cache 30 minutes
|
// Mettre en cache 30 minutes
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ Refonte du Guide TV pour inclure les catégories et corriger l'EPG.
|
|||||||
- [x] Initialiser la session avec l'agent Master
|
- [x] Initialiser la session avec l'agent Master
|
||||||
- [x] Correction initiale du parsing EPG
|
- [x] Correction initiale du parsing EPG
|
||||||
- [x] Suppression du tri alphabétique forcé
|
- [x] Suppression du tri alphabétique forcé
|
||||||
- [/] Refonte du Guide TV (Catégories + EPG détaillé)
|
- [x] Refonte du Guide TV (Catégories + EPG détaillé)
|
||||||
- [ ] Correction de l'endpoint EPG Backend
|
- [x] Correction de l'endpoint EPG Backend (Fallback)
|
||||||
|
|
||||||
## Progress Log
|
## Progress Log
|
||||||
|
|
||||||
@@ -26,4 +26,5 @@ Refonte du Guide TV pour inclure les catégories et corriger l'EPG.
|
|||||||
- [x] Activation de l'identité Bmad Master
|
- [x] Activation de l'identité Bmad Master
|
||||||
- [x] Correction initiale du parsing EPG
|
- [x] Correction initiale du parsing EPG
|
||||||
- [x] Suppression du tri alphabétique forcé
|
- [x] Suppression du tri alphabétique forcé
|
||||||
- [x] Analyse des manques du Guide TV (tri par groupe)
|
- [x] Refonte du Guide TV avec catégories
|
||||||
|
- [x] Implémentation du fallback EPG Backend vers get_short_epg
|
||||||
Reference in new issue
Block a user