mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
add subs to m3u
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anacrolix/missinggo/httptoo"
|
"github.com/anacrolix/missinggo/httptoo"
|
||||||
@@ -93,6 +94,11 @@ 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)
|
||||||
|
if subs != nil {
|
||||||
|
sname := filepath.Base(subs.Path)
|
||||||
|
m3u += "#EXTVLCOPT:sub-file=" + host + "/stream/" + url.PathEscape(sname) + "?link=" + tor.Hash + "&index=" + fmt.Sprint(f.Id) + "&play\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"
|
||||||
}
|
}
|
||||||
@@ -101,6 +107,20 @@ func getM3uList(tor *state.TorrentStatus, host string, fromLast bool) string {
|
|||||||
return m3u
|
return m3u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findSubs(files []*state.TorrentFileStat, file *state.TorrentFileStat) *state.TorrentFileStat {
|
||||||
|
name := strings.TrimSuffix(file.Path, filepath.Ext(file.Path))
|
||||||
|
|
||||||
|
for _, f := range files {
|
||||||
|
if f.Path == name+".srt" {
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
if f.Path == name+".ass" {
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func searchLastPlayed(tor *state.TorrentStatus) int {
|
func searchLastPlayed(tor *state.TorrentStatus) int {
|
||||||
viewed := sets.ListViewed(tor.Hash)
|
viewed := sets.ListViewed(tor.Hash)
|
||||||
if len(viewed) == 0 {
|
if len(viewed) == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user