Снижен размер чанка до 512Б при проверке канала
This commit is contained in:
@@ -166,7 +166,10 @@ func CheckPlaylists(lists []playlist.Playlist) (int, int) {
|
||||
}
|
||||
|
||||
func cachePlaylist(pls playlist.Playlist) {
|
||||
if app.Config.Cache.IsActive {
|
||||
if !app.Config.Cache.IsActive {
|
||||
return
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(pls)
|
||||
if err != nil {
|
||||
log.Printf("Error while saving playlist to cache: %s", err)
|
||||
@@ -180,7 +183,6 @@ func cachePlaylist(pls playlist.Playlist) {
|
||||
|
||||
log.Println("Cached sucessfully")
|
||||
}
|
||||
}
|
||||
|
||||
// CheckChannels проверяет каналы и возвращает их же с результатами проверки
|
||||
func CheckChannels(pls playlist.Playlist) playlist.Playlist {
|
||||
@@ -223,9 +225,8 @@ func CheckChannels(pls playlist.Playlist) playlist.Playlist {
|
||||
return
|
||||
}
|
||||
|
||||
//TODO user-agent
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 WINK/1.31.1 (AndroidTV/9) HlsWinkPlayer")
|
||||
req.Header.Add("Range", "bytes=0-1023") // 1 Kb, but sometimes servers ignore it
|
||||
req.Header.Set("Range", "bytes=0-511") // 512 B, but sometimes servers ignore it
|
||||
resp, err := httpClient.Do(req)
|
||||
tvChannel.CheckedAt = time.Now().Unix()
|
||||
if err != nil {
|
||||
@@ -237,7 +238,7 @@ func CheckChannels(pls playlist.Playlist) playlist.Playlist {
|
||||
tvChannel.Status = resp.StatusCode
|
||||
tvChannel.IsOnline = tvChannel.Status < http.StatusBadRequest
|
||||
tvChannel.ContentType = resp.Header.Get("Content-Type")
|
||||
chunk := io.LimitReader(resp.Body, 1024) // just for sure
|
||||
chunk := io.LimitReader(resp.Body, 512) // just for sure
|
||||
bodyBytes, _ := io.ReadAll(chunk)
|
||||
bodyString := string(bodyBytes)
|
||||
_ = resp.Body.Close()
|
||||
|
||||
Reference in New Issue
Block a user