mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
gofumpt
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"server/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -100,10 +100,10 @@ func getM3uList(tor *state.TorrentStatus, host string, fromLast bool) string {
|
||||
fn = f.Path
|
||||
}
|
||||
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 {
|
||||
m3u += "#EXTVLCOPT:input-slave=" //include VLC option for external media
|
||||
for _, namesake := range fileNamesakes { //include play-links to external media, with # splitter
|
||||
m3u += "#EXTVLCOPT:input-slave=" // include VLC option for external media
|
||||
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#"
|
||||
}
|
||||
@@ -118,12 +118,12 @@ func getM3uList(tor *state.TorrentStatus, host string, fromLast bool) string {
|
||||
}
|
||||
|
||||
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)))
|
||||
var namesakes []*state.TorrentFileStat
|
||||
for _, f := range files {
|
||||
if strings.Contains(f.Path, name) { //external tracks always include name of videofile
|
||||
if f != file { //exclude itself
|
||||
if strings.Contains(f.Path, name) { // external tracks always include name of videofile
|
||||
if f != file { // exclude itself
|
||||
namesakes = append(namesakes, f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"server/rutor"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -211,5 +211,4 @@ func streamNoAuth(c *gin.Context) {
|
||||
}
|
||||
c.Header("WWW-Authenticate", "Basic realm=Authorization Required")
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (ipl *IPList) Lookup(ip net.IP) (r Range, ok bool) {
|
||||
// Return the range the given IP is in. Returns nil if no range is found.
|
||||
func (ipl *IPList) lookup(ip net.IP) (Range, bool) {
|
||||
var rng Range
|
||||
var ok = false
|
||||
ok := false
|
||||
for _, r := range ipl.ranges {
|
||||
ok = bytes.Compare(r.First, ip) <= 0 && bytes.Compare(ip, r.Last) <= 0
|
||||
if ok {
|
||||
|
||||
@@ -2,9 +2,10 @@ package web
|
||||
|
||||
import (
|
||||
"net"
|
||||
"server/rutor"
|
||||
"sort"
|
||||
|
||||
"server/rutor"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-contrib/location"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -42,11 +43,11 @@ func Start(port string) {
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
//corsCfg := cors.DefaultConfig()
|
||||
//corsCfg.AllowAllOrigins = true
|
||||
//corsCfg.AllowHeaders = []string{"*"}
|
||||
//corsCfg.AllowMethods = []string{"*"}
|
||||
//corsCfg.AllowPrivateNetwork = true
|
||||
// corsCfg := cors.DefaultConfig()
|
||||
// corsCfg.AllowAllOrigins = true
|
||||
// corsCfg.AllowHeaders = []string{"*"}
|
||||
// corsCfg.AllowMethods = []string{"*"}
|
||||
// corsCfg.AllowPrivateNetwork = true
|
||||
corsCfg := cors.DefaultConfig()
|
||||
corsCfg.AllowAllOrigins = true
|
||||
corsCfg.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "X-Requested-With", "Accept", "Authorization"}
|
||||
|
||||
Reference in New Issue
Block a user