Compare commits

...

2 Commits

Author SHA1 Message Date
87bc382747 Resolve linter issues 2022-11-27 14:33:56 +05:00
fc684125cc Remove hardcoded host name 2022-11-27 14:31:06 +05:00
3 changed files with 18 additions and 7 deletions

View File

@ -48,9 +48,7 @@ func handlePlayer(w http.ResponseWriter, r *http.Request) {
var data []J
for _, track := range tracks {
host := "music.nxshock.me"
u, _ := url.Parse(fmt.Sprintf("https://%s/stream", host))
u, _ := url.Parse("stream")
q := make(url.Values)
q.Add("url", track.Url)
u.RawQuery = q.Encode()
@ -88,7 +86,7 @@ func handleGetM3u(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "audio/x-mpegurl")
w.Header().Set("Accept-Ranges", "none")
w.Write(b)
_, _ = w.Write(b)
}
func handleStream(w http.ResponseWriter, r *http.Request) {

View File

@ -3,6 +3,7 @@ package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@ -40,7 +41,13 @@ func UpdateGenres() error {
func updateGenreList() ([]Genre, error) {
url := "https://promodj.com/music"
doc, err := goquery.NewDocument(url)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
doc, err := goquery.NewDocumentFromReader(resp.Body)
if err != nil {
return nil, err
}
@ -54,7 +61,13 @@ func updateGenreList() ([]Genre, error) {
}
func parsePage(url string, resultsChan chan TrackInfo) {
doc, err := goquery.NewDocument(url)
resp, err := http.Get(url)
if err != nil {
return
}
defer resp.Body.Close()
doc, err := goquery.NewDocumentFromReader(resp.Body)
if err != nil {
return
}

View File

@ -57,7 +57,7 @@ func encode(url string, w io.Writer) error {
buf := buffer.New(int64(config.BufferSize) * 1024 * 1024)
_, err = nio.Copy(w, out, buf)
if err != nil {
cmd.Process.Kill()
_ = cmd.Process.Kill()
}
return nil