Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,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));
Expand Down Expand Up @@ -304,7 +304,7 @@ private function processPlaylist(int $playlistId, PluginExecutionContext $contex
$matched++;
$batchMatched[$displayName] = $logoUrl;

if (! $isDryRun) {
if (! $isDryRun && ($channel->logo ?? '') !== $logoUrl) {
Channel::where('id', $channel->id)->update(['logo' => $logoUrl]);
}
} else {
Expand Down Expand Up @@ -584,11 +584,11 @@ private function compactIndexMatch(array $slugs, string $countryCode, string $co
* @param array<string, mixed> $cache
* @return array<string, true>
*/
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];
}

Expand Down Expand Up @@ -680,7 +680,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;
Expand Down Expand Up @@ -841,8 +842,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)
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "tv-logos",
"name": "TV Logos",
"version": "1.0.6",
"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.",
Expand Down
Loading