diff --git a/internal/lyricfier/detect_current_song.go b/internal/lyricfier/detect_current_song.go index c507814..253b276 100644 --- a/internal/lyricfier/detect_current_song.go +++ b/internal/lyricfier/detect_current_song.go @@ -10,7 +10,6 @@ type DetectCurrentSong struct { func (h *DetectCurrentSong) Init() { h.platform = runtime.GOOS - println(h.platform) h.Changes = make(chan string) h.Conn = Spotify{} h.Conn.Init() diff --git a/internal/lyricfier/general.go b/internal/lyricfier/general.go index 536cb18..50f7134 100644 --- a/internal/lyricfier/general.go +++ b/internal/lyricfier/general.go @@ -42,13 +42,14 @@ func (h *Main) Init() { h.Detector = DetectCurrentSong{} h.searchLock = false h.AppData.SpotifyRunning = false - h.AppData.Address = "localhost:2387" + h.Detector.Init() h.NewSongChannel = make(chan *Song) h.LyricSearchChannel = make(chan *SearchResult) h.server = &Server{} } -func (h *Main) StartServer() { +func (h *Main) StartServer(bindAddress string) { + h.AppData.Address = bindAddress h.server.Init(h.AppData) } diff --git a/internal/lyricfier/server.go b/internal/lyricfier/server.go index 9bf58d6..fa95f3a 100644 --- a/internal/lyricfier/server.go +++ b/internal/lyricfier/server.go @@ -30,7 +30,11 @@ func (h *Server) Init(appData *AppData) { templates: template.Must(template.ParseGlob("views/*.html")), } h.routes(h.hub) - h.e.Logger.Fatal(h.e.Start(appData.Address)) + s := &http.Server{ + Addr: appData.Address, + } + h.e.HideBanner = true + h.e.Logger.Fatal(h.e.StartServer(s)) } func (h *Server) routes(hub *Hub) { diff --git a/internal/lyricfier/ws.go b/internal/lyricfier/ws.go index 218bfcf..8660c5b 100644 --- a/internal/lyricfier/ws.go +++ b/internal/lyricfier/ws.go @@ -20,8 +20,6 @@ const ( // Send pings to peer with this period. Must be less than pongWait. pingPeriod = (pongWait * 9) / 10 - // Maximum message size allowed from peer. - maxMessageSize = 512 ) var ( diff --git a/lyricfier/lyricfier.go b/lyricfier/lyricfier.go index 682928f..4ac2862 100644 --- a/lyricfier/lyricfier.go +++ b/lyricfier/lyricfier.go @@ -1,6 +1,7 @@ package main import ( + "flag" "github.com/emilioastarita/lyricfier2/internal/lyricfier" "github.com/pkg/browser" ) @@ -8,6 +9,12 @@ import ( var lyricfierMain *lyricfier.Main func main() { + + address := flag.String("address", "localhost", "Bind address") + port := flag.String("port", "2387", "Bind port") + + flag.Parse() + lyricfierMain = &lyricfier.Main{} lyricfierMain.Init() lyricfierMain.Lookup() @@ -25,9 +32,8 @@ func main() { }() go func() { - address := lyricfierMain.AppData.Address - browser.OpenURL("http://" + address) + browser.OpenURL("http://" + *address + ":" + *port) }() - lyricfierMain.StartServer() + lyricfierMain.StartServer(*address + ":" + *port) }