Исправлено кэширование оффлайн плейлистов
This commit is contained in:
@@ -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 проверяет каналы и возвращает их же с результатами проверки
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user