formatting

This commit is contained in:
YouROK
2021-04-06 10:43:18 +03:00
parent 323c81eca1
commit f1e6bc5982

View File

@@ -98,12 +98,12 @@ func getM3uList(tor *state.TorrentStatus, host string, fromLast bool) string {
fn = f.Path fn = f.Path
} }
m3u += "#EXTINF:0," + fn + "\n" m3u += "#EXTINF:0," + fn + "\n"
fileNamesakes := findFileNamesakes(tor.FileStats, f) //find external media with same name (audio/subtiles tracks) fileNamesakes := findFileNamesakes(tor.FileStats, f) //find external media with same name (audio/subtiles tracks)
if fileNamesakes != nil { if fileNamesakes != nil {
m3u+= "#EXTVLCOPT:input-slave=" //include VLC option for external media m3u += "#EXTVLCOPT:input-slave=" //include VLC option for external media
for _, namesake := range fileNamesakes { //include play-links to external media, with # splitter for _, namesake := range fileNamesakes { //include play-links to external media, with # splitter
sname := filepath.Base(namesake.Path) sname := filepath.Base(namesake.Path)
m3u += host + "/stream/" + url.PathEscape(sname) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(namesake.Id) + "&play#" m3u += host + "/stream/" + url.PathEscape(sname) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(namesake.Id) + "&play#"
} }
m3u += "\n" m3u += "\n"
} }
@@ -116,17 +116,17 @@ func getM3uList(tor *state.TorrentStatus, host string, fromLast bool) string {
} }
func findFileNamesakes(files []*state.TorrentFileStat, file *state.TorrentFileStat) []*state.TorrentFileStat { func findFileNamesakes(files []*state.TorrentFileStat, file *state.TorrentFileStat) []*state.TorrentFileStat {
//find files with the same name in torrent //find files with the same name in torrent
name := filepath.Base(strings.TrimSuffix(file.Path, filepath.Ext(file.Path))) name := filepath.Base(strings.TrimSuffix(file.Path, filepath.Ext(file.Path)))
var namesakes []*state.TorrentFileStat var namesakes []*state.TorrentFileStat
for _, f := range files { for _, f := range files {
if strings.Contains(f.Path, name) { //external tracks always include name of videofile if strings.Contains(f.Path, name) { //external tracks always include name of videofile
if (f != file) { //exclude itself if f != file { //exclude itself
namesakes = append(namesakes, f) namesakes = append(namesakes, f)
} }
} }
} }
return namesakes return namesakes
} }
func searchLastPlayed(tor *state.TorrentStatus) int { func searchLastPlayed(tor *state.TorrentStatus) int {