Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
track: Adapt URL func to new URI param
Browse files Browse the repository at this point in the history
  • Loading branch information
n10v committed Mar 14, 2019
1 parent 8c37898 commit 7a450e5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions track/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Track struct {
JID int `json:"id"`
JTitle string `json:"title"`
JURL string `json:"stream_url"`
JURI string `json:"uri"`
JAuthor struct {
AvatarURL string `json:"avatar_url"`
Username string `json:"username"`
Expand Down Expand Up @@ -108,8 +109,18 @@ func (t *Track) Title() string {
}

func (t Track) URL() string {
u, err := url.Parse(t.JURL)
if err != nil {
var streamURL string

if t.JURL != "" {
streamURL = t.JURL
} else if t.JURI != "" {
streamURL = t.JURI + "/stream"
} else {
return ""
}

u, err := url.Parse(streamURL)
if err != nil || u.String() == "" {
return ""
}

Expand Down

0 comments on commit 7a450e5

Please sign in to comment.