Исправлено кэширование оффлайн плейлистов

This commit is contained in:
2025-05-10 11:54:55 +08:00
parent 303ccdd02b
commit 2412b570be
2 changed files with 21 additions and 16 deletions

View File

@@ -146,6 +146,7 @@ func CheckPlaylists(lists []playlist.Playlist) (int, int) {
if err != nil {
log.Printf("Cannot read playlist [%s]: %s\n", pls.Url, err)
offlineCount++
cachePlaylist(pls)
continue
}
@@ -156,9 +157,14 @@ func CheckPlaylists(lists []playlist.Playlist) (int, int) {
log.Printf("Parsed, checking channels (%d)...\n", len(pls.Channels))
pls = CheckChannels(pls)
lists[idx] = pls
cachePlaylist(pls)
}
return onlineCount, offlineCount
}
func cachePlaylist(pls playlist.Playlist) {
if app.Config.Cache.IsActive {
jsonBytes, err := json.Marshal(pls)
if err != nil {
@@ -173,9 +179,6 @@ func CheckPlaylists(lists []playlist.Playlist) (int, int) {
log.Println("Cached sucessfully")
}
}
return onlineCount, offlineCount
}
// CheckChannels проверяет каналы и возвращает их же с результатами проверки

View File

@@ -123,6 +123,7 @@ func parseName(line string) string {
func (pls *Playlist) Download() error {
content, err := utils.Fetch(pls.Url)
if err != nil {
pls.Content = err.Error()
return err
}
@@ -134,6 +135,7 @@ func (pls *Playlist) Download() error {
func (pls *Playlist) ReadFromFs() error {
content, err := os.ReadFile(pls.Url)
if err != nil {
pls.Content = err.Error()
return err
}