From aa218d94b0e512fa1de2bbbae1708cd6465bf727 Mon Sep 17 00:00:00 2001 From: Serph91P Date: Thu, 16 Apr 2026 15:40:26 +0200 Subject: [PATCH] fix: SAT.1 slug destruction, stale index on ignore-cache, skip redundant DB updates - Prevent transport-term regex from stripping 'sat' in 'SAT.1' (negative lookahead for dot+digit) in both slugify() and normalizeChannelName() - Pass ignore_cache flag to fetchCountryIndex so fresh lookups actually re-fetch the GitHub API index - Skip Channel::update when logo URL is already identical to avoid unnecessary model events - Bump version to 1.0.7 --- Plugin.php | 14 ++++++++------ plugin.json | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Plugin.php b/Plugin.php index b5ff378..efa796c 100644 --- a/Plugin.php +++ b/Plugin.php @@ -224,7 +224,7 @@ private function processPlaylist(int $playlistId, PluginExecutionContext $contex $cache = $this->loadCache($cacheTtlDays); $cacheChanged = false; - $index = $this->fetchCountryIndex($countryCode, $countryFolder, $cache, $cacheChanged); + $index = $this->fetchCountryIndex($countryCode, $countryFolder, $cache, $cacheChanged, $ignoreCache); if ($index !== []) { $context->info(sprintf('Loaded index of %d known logos for %s.', count($index), $countryFolder)); @@ -294,7 +294,7 @@ private function processPlaylist(int $playlistId, PluginExecutionContext $contex if ($logoUrl !== null) { $matched++; - if (! $isDryRun) { + if (! $isDryRun && ($channel->logo ?? '') !== $logoUrl) { Channel::where('id', $channel->id)->update(['logo' => $logoUrl]); } } else { @@ -547,11 +547,11 @@ private function compactIndexMatch(array $slugs, string $countryCode, string $co * @param array $cache * @return array */ - private function fetchCountryIndex(string $countryCode, string $countryFolder, array &$cache, bool &$cacheChanged): array + private function fetchCountryIndex(string $countryCode, string $countryFolder, array &$cache, bool &$cacheChanged, bool $ignoreCache = false): array { $cacheKey = "index:{$countryCode}"; - if (array_key_exists($cacheKey, $cache) && is_array($cache[$cacheKey])) { + if (! $ignoreCache && array_key_exists($cacheKey, $cache) && is_array($cache[$cacheKey])) { return $cache[$cacheKey]; } @@ -643,7 +643,8 @@ private function slugify(string $name, bool $stripQualityTags = true): string } // Strip common IPTV transport / source terms (always, regardless of quality tag stripping) - $name = preg_replace('/\b(cable|sat(?:ellite)?|terrestrial|dvb[tcsh]?|iptv|ott|fta|stream|linear)\b/iu', '', $name) ?? $name; + // Use negative lookahead so "sat" inside "SAT.1" is not stripped (sat followed by dot+digit). + $name = preg_replace('/\b(cable|sat(?:ellite)?(?![.\s]*\d)|terrestrial|dvb[tcsh]?|iptv|ott|fta|stream|linear)\b/iu', '', $name) ?? $name; // Remove content inside any bracket type $name = preg_replace('/[\(\[\{][^\)\]\}]*[\)\]\}]/', '', $name) ?? $name; @@ -803,8 +804,9 @@ private function normalizeChannelName(string $name, array $config): string } // 3. Strip common IPTV transport / source terms that are never part of a channel name + // Use negative lookahead so "Sat" inside "SAT.1" is not stripped (Sat followed by dot/space+digit). if ($config['strip_provider_info']) { - $name = (string) preg_replace('/\b(Cable|Sat|Satellite|Terrestrial|DVB[TCSH]?|IPTV|OTT|FTA|Stream|Linear)\b/iu', '', $name); + $name = (string) preg_replace('/\b(Cable|Sat(?:ellite)?(?![.\s]*\d)|Terrestrial|DVB[TCSH]?|IPTV|OTT|FTA|Stream|Linear)\b/iu', '', $name); } // 4. Strip user-configured provider terms (one term per line in settings) diff --git a/plugin.json b/plugin.json index 431d958..0e95178 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "id": "tv-logos", "name": "TV Logos", - "version": "1.0.5", + "version": "1.0.7", "api_version": "1.0.0", "repository": "m3ue/tv-logos-plugin", "description": "Automatically enriches channel logos from the open-source tv-logo/tv-logos repository via the jsDelivr CDN.",