Skip to content

Commit

Permalink
feat: print an 'image-not-found' instad of nothing when no image is set
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jan 27, 2019
1 parent 153ddd1 commit 30268a2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/soundcloud/soundcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ func fromSoundcloudTracks(input []*gosoundcloud.Track) *Tracks {
return tracks
}

func artworkURL(input string) string {
if input == "" {
return "/img/img-not-found-400.png"
}
return strings.Replace(input, "-large", "-t500x500", -1)
}

func fromSoundcloudPlaylist(input *gosoundcloud.Playlist) *Playlist {
return &Playlist{
ID: input.Id,
Expand All @@ -121,7 +128,7 @@ func fromSoundcloudPlaylist(input *gosoundcloud.Playlist) *Playlist {
Sharing: input.Sharing,
EmbeddableBy: input.EmbeddableBy,
PurchaseUrl: input.PurchaseUrl,
ArtworkUrl: input.ArtworkUrl,
ArtworkUrl: artworkURL(input.ArtworkUrl),
Description: input.Description,
Duration: input.Duration,
Genre: input.Genre,
Expand Down Expand Up @@ -154,7 +161,7 @@ func fromSoundcloudTrack(input *gosoundcloud.Track) *Track {
Sharing: input.Sharing,
EmbeddableBy: input.EmbeddableBy,
PurchaseUrl: input.PurchaseUrl,
ArtworkUrl: input.ArtworkUrl,
ArtworkUrl: artworkURL(input.ArtworkUrl),
Description: input.Description,
Duration: input.Duration,
Genre: input.Genre,
Expand Down

0 comments on commit 30268a2

Please sign in to comment.