Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusziade committed Sep 3, 2022
1 parent 24a25a4 commit 3a0c576
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions songlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import (
"github.com/atotto/clipboard"
)

// The LinksResponse model
type LinksResponse struct {
PageUrl string `json:"pageUrl"`
}

// Entrypoint of the app.
// Asks the user to paste and confirm a music service URL
// formats the input and passes it to the `LinksRequest` method
func main() {
fmt.Print("Enter search URL...\n")
reader := bufio.NewReader(os.Stdin)
Expand All @@ -28,6 +32,9 @@ func main() {
LinksRequest(input)
}

// Takes a music service URL as input.
// checks if the response is succesful, decodes the json,
// copies the generated song.link URL to the clipboard and prints it to interface
func LinksRequest(searchURL string) {
linksRes := LinksResponse{}

Expand All @@ -50,6 +57,7 @@ func LinksRequest(searchURL string) {
}
}

// Takes in a music service URL and builds the song.link API query
func buildURL(searchURL string) string {
url := url.URL{
Scheme: "https",
Expand Down

0 comments on commit 3a0c576

Please sign in to comment.