Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #171 from nf/master
Browse files Browse the repository at this point in the history
Support audio files
  • Loading branch information
Seklfreak authored Jul 12, 2020
2 parents c21174c + 2a981dc commit 08cd579
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,9 @@ func downloadFromUrl(dUrl string, filename string, path string, channelId string
}

contentTypeParts := strings.Split(contentType, "/")
if contentTypeParts[0] != "image" && contentTypeParts[0] != "video" {
fmt.Println("No image or video found at", dUrl)
if t := contentTypeParts[0]; t != "image" && t != "video" && t != "audio" &&
!(t == "application" && isAudioFile(filename)) {
fmt.Println("No image, video, or audio found at", dUrl)
return true
}

Expand Down Expand Up @@ -1079,6 +1080,15 @@ func downloadFromUrl(dUrl string, filename string, path string, channelId string
return true
}

func isAudioFile(f string) bool {
switch strings.ToLower(path.Ext(f)) {
case ".mp3", ".wav", ".aif":
return true
default:
return false
}
}

type DownloadedImage struct {
Url string
Time time.Time
Expand Down

0 comments on commit 08cd579

Please sign in to comment.