Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multicast streams through udpxy in the custom provider #238

Merged
merged 2 commits into from
May 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/m3uplus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
17 changes: 17 additions & 0 deletions internal/providers/custom.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions internal/providers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Configuration struct {
M3U string `json:"-"`
EPG string `json:"-"`

Udpxy string `json:"udpxy"`

VideoOnDemand bool `json:"-"`

Filter string
Expand Down