mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-20 21:48:06 +02:00
Guide TV : décoder la table des chaînes en UTF-8
Sans charset annoncé, Response.body pouvait décoder le JSON du panneau en latin-1 et abîmer les noms accentués ou décorés (« Chérie », « ◉ »), donc leur correspondance avec le guide XMLTV. Le test simule désormais des octets UTF-8 sans charset, comme le panneau réel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abe7d522c1
commit
584068b45b
2 files changed
+9
-4
No files matched your search
@@ -350,7 +350,10 @@ class EpgApi {
|
|||||||
if (response != null && response.statusCode == 200) {
|
if (response != null && response.statusCode == 200) {
|
||||||
// Décodage dans un isolate : 7 Mo de JSON sur la boucle principale la
|
// Décodage dans un isolate : 7 Mo de JSON sur la boucle principale la
|
||||||
// gelaient, et le relais turbo.ts cessait d'émettre pendant ce temps.
|
// gelaient, et le relais turbo.ts cessait d'émettre pendant ce temps.
|
||||||
final body = response.body;
|
// UTF-8 explicite : sans charset annoncé, `response.body` peut décoder
|
||||||
|
// en latin-1 et abîmer les noms (« Chérie », « ◉ »), donc leur
|
||||||
|
// correspondance avec le guide.
|
||||||
|
final body = utf8.decode(response.bodyBytes, allowMalformed: true);
|
||||||
try {
|
try {
|
||||||
(epgIds, names) = await Isolate.run(() => _parseChannelTable(body));
|
(epgIds, names) = await Isolate.run(() => _parseChannelTable(body));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -249,11 +249,13 @@ void main() {
|
|||||||
if (url.path.endsWith('/xmltv.php')) return http.Response('<tv></tv>', 200);
|
if (url.path.endsWith('/xmltv.php')) return http.Response('<tv></tv>', 200);
|
||||||
final action = url.queryParameters['action'] ?? '';
|
final action = url.queryParameters['action'] ?? '';
|
||||||
if (action == 'get_live_streams') {
|
if (action == 'get_live_streams') {
|
||||||
return http.Response(
|
// Octets UTF-8 et JSON sans charset annoncé, comme le panneau réel.
|
||||||
jsonEncode([
|
return http.Response.bytes(
|
||||||
|
utf8.encode(jsonEncode([
|
||||||
{'stream_id': 1, 'name': 'FR - TF1 FHD ◉', 'epg_channel_id': ''},
|
{'stream_id': 1, 'name': 'FR - TF1 FHD ◉', 'epg_channel_id': ''},
|
||||||
]),
|
])),
|
||||||
200,
|
200,
|
||||||
|
headers: {'content-type': 'application/json'},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
throw http.ClientException('Connection closed', url);
|
throw http.ClientException('Connection closed', url);
|
||||||
|
|||||||
Reference in new issue
Block a user