Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c2ff027223
|
|||
|
13723a2dc5
|
|||
|
2412b570be
|
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
const VERSION = "1.0.0"
|
||||
const VERSION = "1.0.1"
|
||||
|
||||
// Arguments описывает аргументы командной строки
|
||||
type Arguments struct {
|
||||
|
||||
@@ -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 {
|
||||
@@ -175,9 +181,6 @@ func CheckPlaylists(lists []playlist.Playlist) (int, int) {
|
||||
}
|
||||
}
|
||||
|
||||
return onlineCount, offlineCount
|
||||
}
|
||||
|
||||
// CheckChannels проверяет каналы и возвращает их же с результатами проверки
|
||||
func CheckChannels(pls playlist.Playlist) playlist.Playlist {
|
||||
type errorData struct {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -144,6 +146,7 @@ func (pls *Playlist) ReadFromFs() error {
|
||||
// Parse разбирает плейлист
|
||||
func (pls *Playlist) Parse() Playlist {
|
||||
isChannel := false
|
||||
pls.Attributes = make(map[string]string)
|
||||
pls.Channels = make(map[string]Channel)
|
||||
pls.Groups = make(map[string]Group)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user