diff --git a/internal/m3uplus/main.go b/internal/m3uplus/main.go index 712e539..62bf77a 100644 --- a/internal/m3uplus/main.go +++ b/internal/m3uplus/main.go @@ -96,7 +96,7 @@ func decodeLine(playlist *Playlist, line string, lineNumber int) error { playlist.Tracks = append(playlist.Tracks, track) - case strings.HasPrefix(line, "http"): + case strings.HasPrefix(line, "http") || strings.HasPrefix(line, "udp"): playlist.Tracks[len(playlist.Tracks)-1].URI = line } diff --git a/internal/providers/custom.go b/internal/providers/custom.go index 721ddc9..6e0b824 100644 --- a/internal/providers/custom.go +++ b/internal/providers/custom.go @@ -1,9 +1,13 @@ package providers import ( + "fmt" + "net" + "net/url" "strconv" "strings" + log "github.com/sirupsen/logrus" m3u "github.com/tellytv/telly/internal/m3uplus" "github.com/tellytv/telly/internal/xmltv" ) @@ -63,6 +67,19 @@ func (i *customProvider) ParseTrack(track m3u.Track, channelMap map[string]xmltv OnDemand: false, } + // If Udpxy is set in the provider configuration and StreamURL is a multicast stream, + // rewrite the URL to point to the Udpxy instance. + if i.BaseConfig.Udpxy != "" { + trackURI, err := url.Parse(pChannel.StreamURL) + if err != nil { + return nil, err + } + if IP := net.ParseIP(trackURI.Hostname()); IP != nil && IP.IsMulticast() { + pChannel.StreamURL = fmt.Sprintf("http://%s/udp/%s/", i.BaseConfig.Udpxy, trackURI.Host) + log.Debugf("Multicast stream detected and udpxy is configured, track URL rewritten from %s to %s", track.URI, pChannel.StreamURL) + } + } + epgVal := track.Tags["tvg-id"] if i.BaseConfig.EPGMatchKey != "" { epgVal = track.Tags[i.BaseConfig.EPGMatchKey] diff --git a/internal/providers/main.go b/internal/providers/main.go index 41c199b..7d5893c 100644 --- a/internal/providers/main.go +++ b/internal/providers/main.go @@ -23,6 +23,8 @@ type Configuration struct { M3U string `json:"-"` EPG string `json:"-"` + Udpxy string `json:"udpxy"` + VideoOnDemand bool `json:"-"` Filter string