This commit is contained in:
YouROK
2021-09-08 12:20:18 +03:00
parent 42434c2f46
commit 52d7b7a10b

View File

@@ -2,9 +2,9 @@ package api
import (
"fmt"
"strings"
"net/url"
"path/filepath"
"strings"
sets "server/settings"
"server/torr"
@@ -150,13 +150,13 @@ func msxPlaylist(c *gin.Context) {
host := utils.GetScheme(c) + "://" + c.Request.Host
status := tor.Status()
viewed := sets.ListViewed(hash)
list := []msxItem{}
var list []msxItem
for _, f := range status.FileStats {
mime := utils.GetMimeType(f.Path)
action := mime[0 : len(mime)-2]
if (action == "*") {
if action == "*" {
continue
}
name := filepath.Base(f.Path)
@@ -165,16 +165,16 @@ func msxPlaylist(c *gin.Context) {
PlayerLabel: strings.TrimSuffix(name, filepath.Ext(name)),
Action: action + ":" + host + "/stream/" + url.PathEscape(name) + "?link=" + hash + "&index=" + fmt.Sprint(f.Id) + "&play",
}
if (isViewed(viewed, f.Id)) {
if isViewed(viewed, f.Id) {
item.Tag = " "
}
if (action == "audio") {
if action == "audio" {
item.Icon = "msx-white-soft:music-note"
}
list = append(list, item)
}
if (len(list) == 0) {
if len(list) == 0 {
c.JSON(200, msxData{
Action: "error:No supported content found",
})
@@ -206,7 +206,7 @@ func msxPlaylist(c *gin.Context) {
func isViewed(viewed []*sets.Viewed, id int) bool {
for _, v := range viewed {
if (v.FileIndex == id) {
if v.FileIndex == id {
return true
}
}