summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-12-22 17:15:30 +0100
committerdelthas <delthas@dille.cc>2022-12-22 17:15:52 +0100
commit3ec341833671fcc89cab062cdb714fc81cf8b441 (patch)
treec8eb8bf2a4c5196489151ee2771ef8206a3c411e
parentFix failing on addresses with a literal IP address without URLs (diff)
np: Bump libnp & be more verbose with errors
-rw-r--r--commands.go17
-rw-r--r--go.mod2
-rw-r--r--go.sum4
3 files changed, 13 insertions, 10 deletions
diff --git a/commands.go b/commands.go
index 6fb501f..2371878 100644
--- a/commands.go
+++ b/commands.go
@@ -360,7 +360,10 @@ func commandDoMe(app *App, args []string) (err error) {
}
func commandDoNP(app *App, args []string) (err error) {
- song := getSong()
+ song, err := getSong()
+ if err != nil {
+ return fmt.Errorf("failed detecting the song: %v", err)
+ }
if song == "" {
return fmt.Errorf("no song was detected")
}
@@ -809,18 +812,18 @@ func (app *App) handleInput(buffer, content string) error {
return cmd.Handle(app, args)
}
-func getSong() string {
- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
+func getSong() (string, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
defer cancel()
info, err := libnp.GetInfo(ctx)
if err != nil {
- return ""
+ return "", err
}
if info == nil {
- return ""
+ return "", nil
}
if info.Title == "" {
- return ""
+ return "", nil
}
var sb strings.Builder
@@ -837,5 +840,5 @@ func getSong() string {
fmt.Fprintf(&sb, " — %s", info.URL)
}
}
- return sb.String()
+ return sb.String(), nil
}
diff --git a/go.mod b/go.mod
index bc66719..2ce6a89 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.16
require (
git.sr.ht/~emersion/go-scfg v0.0.0-20201019143924-142a8aa629fc
- github.com/delthas/go-libnp v0.0.0-20221221144027-c473a063cc72
+ github.com/delthas/go-libnp v0.0.0-20221222161248-0e45ece1f878
github.com/delthas/go-localeinfo v0.0.0-20221116001557-686a1e185118
github.com/gdamore/tcell/v2 v2.5.4-0.20221017224006-ede1dd5ee680
github.com/mattn/go-runewidth v0.0.14
diff --git a/go.sum b/go.sum
index 2cda0c8..f087e56 100644
--- a/go.sum
+++ b/go.sum
@@ -2,8 +2,8 @@ git.sr.ht/~emersion/go-scfg v0.0.0-20201019143924-142a8aa629fc h1:51BD67xFX+bozd
git.sr.ht/~emersion/go-scfg v0.0.0-20201019143924-142a8aa629fc/go.mod h1:t+Ww6SR24yYnXzEWiNlOY0AFo5E9B73X++10lrSpp4U=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/delthas/go-libnp v0.0.0-20221221144027-c473a063cc72 h1:CSoQd6Kw/fqPiXIEA9xnzdvyz0ZkplYUNGMBMQ7EGmw=
-github.com/delthas/go-libnp v0.0.0-20221221144027-c473a063cc72/go.mod h1:aGVXnhWpDlt5U4SphG97o1gszctZKvBTXy320E8Buw4=
+github.com/delthas/go-libnp v0.0.0-20221222161248-0e45ece1f878 h1:v8W8eW7eb2bHFXBA80UKcoe0TvEu46NlTHSDRvgAbMU=
+github.com/delthas/go-libnp v0.0.0-20221222161248-0e45ece1f878/go.mod h1:aGVXnhWpDlt5U4SphG97o1gszctZKvBTXy320E8Buw4=
github.com/delthas/go-localeinfo v0.0.0-20221116001557-686a1e185118 h1:Xzf9ra1QRJXD62gwudjI2iBq7x9CusvHd83Dg2OnUmE=
github.com/delthas/go-localeinfo v0.0.0-20221116001557-686a1e185118/go.mod h1:sG54BxlyQgIskYURLrg7mvhoGBe0Qq12DNtYRALwNa4=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=