From 721eb67c2fe690520e0df75c26e5d41ea9a2543c Mon Sep 17 00:00:00 2001 From: Johnnybegood90 Date: Sun, 15 Mar 2026 02:22:21 +0100 Subject: [PATCH] Improvment: Getting Magazine export even better. --- export.php | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/export.php b/export.php index e86618c..b2f808f 100644 --- a/export.php +++ b/export.php @@ -128,6 +128,24 @@ function export_programme_weight(array $programme): int { return $weight; } +function export_programme_duration(array $programme): int { + return max(1, (int) round(($programme['stop']->getTimestamp() - $programme['start']->getTimestamp()) / 60)); +} + +function export_programme_is_series(array $programme): bool { + return !empty($programme['subtitle']); +} + +function export_take_entries(array $entries, callable $filter, int $limit = 4): array { + $picked = []; + foreach ($entries as $entry) { + if (!$filter($entry)) continue; + $picked[] = $entry; + if (count($picked) >= $limit) break; + } + return $picked; +} + function export_build_magazine(array $channels): array { $all = []; foreach ($channels as $channel) { @@ -148,6 +166,10 @@ function export_build_magazine(array $channels): array { }); $highlights = array_slice($all, 0, 5); + $series = export_take_entries($all, static fn($entry) => export_programme_is_series($entry['programme']), 4); + $movies = export_take_entries($all, static fn($entry) => !export_programme_is_series($entry['programme']) && export_programme_duration($entry['programme']) >= 80, 4); + $late_picks = export_take_entries($all, static fn($entry) => (int) $entry['programme']['start']->format('H') >= 21, 4); + $by_channel = []; foreach ($channels as $channel) { $by_channel[] = [ @@ -157,7 +179,30 @@ function export_build_magazine(array $channels): array { ]; } - return ['highlights' => $highlights, 'channels' => $by_channel]; + $cards = [ + [ + 'title' => 'A ne pas manquer', + 'kicker' => 'Selection de la redaction', + 'items' => array_slice($highlights, 0, 4), + ], + [ + 'title' => 'Series en diffusion', + 'kicker' => 'Nouvelle serie diffusee', + 'items' => $series ?: array_slice($highlights, 0, 4), + ], + [ + 'title' => 'Grands formats', + 'kicker' => 'Films et longs formats', + 'items' => $movies ?: array_slice($highlights, 0, 4), + ], + [ + 'title' => 'Nouveautes du soir', + 'kicker' => 'Prime time', + 'items' => $late_picks ?: array_slice($highlights, 0, 4), + ], + ]; + + return ['highlights' => $highlights, 'channels' => $by_channel, 'cards' => $cards]; } $sources = array_values($config['epg_sources'] ?? []); @@ -241,7 +286,7 @@ $magazine = export_build_magazine($visible_channels); .mag-title{font-family:'IM Fell English',serif;font-size:34px;line-height:1.02;margin-bottom:10px} .mag-meta{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--ink-soft);letter-spacing:.04em;margin-bottom:10px} .mag-desc{font-size:14px;line-height:1.45;color:var(--ink-soft)} -.mag-side-list,.mag-channels{display:grid;gap:14px} +.mag-side-list,.mag-channels,.mag-cards{display:grid;gap:14px} .mag-mini-title{font-size:18px;font-weight:700;line-height:1.08} .mag-mini{padding-top:12px;border-top:1px dashed var(--line)} .mag-mini:first-child{padding-top:0;border-top:none} @@ -254,6 +299,8 @@ $magazine = export_build_magazine($visible_channels); .mag-item:first-child{padding-top:0;border-top:none} .mag-time{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--accent-2)} .mag-item-title{font-size:15px;font-weight:700;line-height:1.08} +.mag-card{background:rgba(255,255,255,.35);border:1px solid var(--line);padding:14px} +.mag-cards{grid-template-columns:repeat(2,minmax(0,1fr))} .timeline-wrap{display:grid;gap:14px} .timeline-row{display:grid;grid-template-columns:180px 1fr;gap:14px;align-items:stretch} .timeline-channel{border-top:2px solid var(--accent-2);padding-top:8px} @@ -265,7 +312,7 @@ $magazine = export_build_magazine($visible_channels); .mini-title{font-size:13px;font-weight:700;line-height:1.05} .mini-meta{font-family:'Share Tech Mono',monospace;font-size:10px;color:var(--ink-soft);margin-top:3px} @media print{body{background:#fff}.page{padding:0}.toolbar{display:none}.sheet{box-shadow:none;border:none;width:auto;margin:0}.sheet-wrap{overflow:visible}.cards-grid{grid-template-columns:1fr 1fr}} -@media (max-width:1200px){.sheet{width:100%}.cards-grid,.mag-channels,.mag-hero{grid-template-columns:1fr}.timeline-row{grid-template-columns:1fr}.timeline-grid{overflow:auto}} +@media (max-width:1200px){.sheet{width:100%}.cards-grid,.mag-channels,.mag-hero,.mag-cards{grid-template-columns:1fr}.timeline-row{grid-template-columns:1fr}.timeline-grid{overflow:auto}} @@ -448,6 +495,24 @@ $items = array_values(array_filter($channel['programmes'], static fn($p) => $p[' + + + +
Magazine cards
+
+ +
+
+
+ +
+
+
· format('H:i') . ' - ' . $p['stop']->format('H:i')) ?>
+
+
+
+ +