Skip to content

Commit

Permalink
Merge branch 'master' of github.com:emilioastarita/lyricfier2
Browse files Browse the repository at this point in the history
  • Loading branch information
emilioastarita committed Jul 13, 2019
2 parents d6cb4e2 + 6d68805 commit 9ead3ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion internal/lyricfier/detect_current_song.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions internal/lyricfier/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 5 additions & 1 deletion internal/lyricfier/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions internal/lyricfier/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
12 changes: 9 additions & 3 deletions lyricfier/lyricfier.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package main

import (
"flag"
"github.com/emilioastarita/lyricfier2/internal/lyricfier"
"github.com/pkg/browser"
)

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()
Expand All @@ -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)
}

0 comments on commit 9ead3ff

Please sign in to comment.