mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
Include other external media links to m3u for VLC
VLC itself decide what format it can play.
This commit is contained in:
@@ -98,10 +98,14 @@ 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"
|
||||||
subs := findSubs(tor.FileStats, f)
|
fileNamesakes := findFileNamesakes(tor.FileStats, f) //find external media with same name (audio/subtiles tracks)
|
||||||
if subs != nil {
|
if fileNamesakes != nil {
|
||||||
sname := filepath.Base(subs.Path)
|
m3u+= "#EXTVLCOPT:input-slave=" //include VLC option for external media
|
||||||
m3u += "#EXTVLCOPT:input-slave=" + host + "/stream/" + url.PathEscape(sname) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(subs.Id) + "&play\n"
|
for _, namesake := range fileNamesakes { //include play-links to external media, with # splitter
|
||||||
|
sname := filepath.Base(namesake.Path)
|
||||||
|
m3u += host + "/stream/" + url.PathEscape(sname) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(namesake.Id) + "&play#"
|
||||||
|
}
|
||||||
|
m3u += "\n"
|
||||||
}
|
}
|
||||||
name := filepath.Base(f.Path)
|
name := filepath.Base(f.Path)
|
||||||
m3u += host + "/stream/" + url.PathEscape(name) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(f.Id) + "&play\n"
|
m3u += host + "/stream/" + url.PathEscape(name) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(f.Id) + "&play\n"
|
||||||
@@ -111,19 +115,18 @@ func getM3uList(tor *state.TorrentStatus, host string, fromLast bool) string {
|
|||||||
return m3u
|
return m3u
|
||||||
}
|
}
|
||||||
|
|
||||||
func findSubs(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
|
||||||
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
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
fname := strings.ToLower(filepath.Base(f.Path))
|
if strings.Contains(f.Path, name) { //external tracks always include name of videofile
|
||||||
if fname == strings.ToLower(name+".srt") {
|
if (f != file) { //exclude itself
|
||||||
return f
|
namesakes = append(namesakes, f)
|
||||||
}
|
|
||||||
if fname == strings.ToLower(name+".ass") {
|
|
||||||
return f
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
}
|
||||||
|
return namesakes
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchLastPlayed(tor *state.TorrentStatus) int {
|
func searchLastPlayed(tor *state.TorrentStatus) int {
|
||||||
|
|||||||
Reference in New Issue
Block a user