Skip to content

Commit

Permalink
telly v0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tombowditch committed Apr 11, 2018
1 parent ab01567 commit 59987b0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package main

import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"github.com/namsral/flag"
"github.com/tombowditch/telly-m3u-parser"
"io"
"net/http"
"net/url"
"os"
"regexp"
"strconv"
"strings"
"encoding/base64"
"net/url"
)

var deviceXml string
Expand Down Expand Up @@ -130,7 +130,7 @@ func buildChannels(usedTracks []m3u.Track) []LineupItem {

// base64 url
fullTrackUri := track.URI
if ! *directMode {
if !*directMode {
trackUri := base64.StdEncoding.EncodeToString([]byte(track.URI))
fullTrackUri = fmt.Sprintf("http://%s", *listenAddress) + "/stream/" + trackUri
}
Expand All @@ -153,17 +153,17 @@ func base64StreamHandler(w http.ResponseWriter, r *http.Request, base64StreamUrl
decodedStreamURI, err := base64.StdEncoding.DecodeString(base64StreamUrl)

if err != nil {
log("error", "Invalid base64: " + base64StreamUrl + ": " + err.Error())
log("error", "Invalid base64: "+base64StreamUrl+": "+err.Error())
w.WriteHeader(400)
return
}

log("debug", "Redirecting to: " + string(decodedStreamURI))
log("debug", "Redirecting to: "+string(decodedStreamURI))
http.Redirect(w, r, string(decodedStreamURI), 301)
}

func main() {
tellyVersion := "v0.4.5"
tellyVersion := "v0.5"
log("info", "booting telly "+tellyVersion)
usedTracks := make([]m3u.Track, 0)

Expand Down Expand Up @@ -333,7 +333,7 @@ func main() {
h.HandleFunc("/stream/", func(w http.ResponseWriter, r *http.Request) {
u, _ := url.Parse(r.RequestURI)
uriPart := strings.Replace(u.Path, "/stream/", "", 1)
log("debug", "Parsing URI " + r.RequestURI + " to " + uriPart)
log("debug", "Parsing URI "+r.RequestURI+" to "+uriPart)
base64StreamHandler(w, r, uriPart)
})

Expand Down

0 comments on commit 59987b0

Please sign in to comment.