updatedAt = date('d.m.Y h:i', filemtime($filepath)); // сохраняем порядок foreach (array_keys($ini) as $code) { $data = redis()->get($code); if ($data === false) { $raw = $ini[$code]; $data = [ 'code' => $code, 'name' => $raw['name'], 'description' => $raw['desc'], 'url' => $raw['pls'], 'source' => $raw['src'], 'content' => null, 'isOnline' => null, 'attributes' => [], 'groups' => [], 'channels' => [], 'onlineCount' => 0, 'offlineCount' => 0, 'checkedAt' => null, ]; } else if (!isset($data['attributes'])) { $data['attributes'] = []; } $data['hasTvg'] = !empty($data['asttributes']['url-tvg']); $data['hasCatchup'] = str_contains($data['content'] ?? '', 'catchup'); $data['tags'] = []; foreach ($data['channels'] ?? [] as $channel) { $data['tags'] = array_merge($data['tags'], $channel['tags']); } $data['tags'] = array_values(array_unique($data['tags'])); sort($data['tags']); $this->playlists[$code] = $data; } return $this->playlists; } /** * Возвращает плейлисты * * @return array[] * @throws Exception */ public function getPlaylists(): array { return $this->playlists ??= $this->load(); } /** * Возвращает дату обновления ini-файла * * @return string */ public function updatedAt(): string { return $this->updatedAt; } /** * Возвращает плейлист по его коду * * @param string $code Код плейлиста * @return array|null * @throws PlaylistNotFoundException * @throws Exception */ public function getPlaylist(string $code): ?array { if (empty($this->playlists)) { $this->load(); } return $this->playlists[$code] ?? throw new PlaylistNotFoundException($code); } }