Skip to content

Commit

Permalink
refactor: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
izn committed Jun 9, 2024
1 parent 38166cd commit c8b63f3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
12 changes: 6 additions & 6 deletions genius.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main
package main

import (
"fmt"
"html"
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strings"
"html"
)

func FetchLyrics(track Track) (string, error) {
Expand Down Expand Up @@ -35,8 +35,8 @@ func buildGeniusURL(track Track) string {
artist := cleanString(track.Artist)
title := cleanString(track.Title)

artistSlug := strings.ReplaceAll(artist, " ", "-")
titleSlug := strings.ReplaceAll(title, " ", "-")
artistSlug := strings.ReplaceAll(artist, " ", "-")
titleSlug := strings.ReplaceAll(title, " ", "-")

artistEncoded := url.PathEscape(artistSlug)
titleEncoded := url.PathEscape(titleSlug)
Expand All @@ -55,9 +55,9 @@ func extractLyrics(rawHtml string) (string, error) {
}

lyrics := matches[1]
lyrics = html.UnescapeString(lyrics)
lyrics = html.UnescapeString(lyrics)
lyrics = strings.ReplaceAll(lyrics, "<br/>", "\n")
lyrics = removeHTMLTags(lyrics)
lyrics = removeHTMLTags(lyrics)

return lyrics, nil
}
12 changes: 6 additions & 6 deletions spotify.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main
package main

import (
"errors"
"os/exec"
"strings"
"errors"
)

// Darwin-only
// Darwin-only
func CurrentSpotifyTrack() (Track, error) {
script := `
tell application "Spotify"
Expand All @@ -28,9 +28,9 @@ func CurrentSpotifyTrack() (Track, error) {

parts := strings.Split(string(output), "\t")

if len(parts) < 2 {
return Track{}, errors.New("Is Spotify running?")
}
if len(parts) < 2 {
return Track{}, errors.New("Is Spotify running?")
}

return Track{
Artist: parts[0],
Expand Down
7 changes: 3 additions & 4 deletions track.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main
package main

type Track struct {
Artist string
Title string
Artist string
Title string
}

2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package main

import (
"regexp"
Expand Down

0 comments on commit c8b63f3

Please sign in to comment.