This commit is contained in:
parent
1acd1c0cab
commit
7cd5e80468
23 changed files with 988 additions and 5 deletions
26
cache.go
26
cache.go
|
@ -62,6 +62,18 @@ type ForumSearchResult struct {
|
|||
ThumbnailSrc string `json:"thumbnailSrc,omitempty"`
|
||||
}
|
||||
|
||||
type MusicResult struct {
|
||||
URL string
|
||||
Title string
|
||||
Artist string
|
||||
Description string
|
||||
PublishedDate string
|
||||
Thumbnail string
|
||||
// AudioURL string
|
||||
Source string
|
||||
Duration string
|
||||
}
|
||||
|
||||
// GeocodeCachedItem represents a geocoding result stored in the cache.
|
||||
type GeocodeCachedItem struct {
|
||||
Latitude string
|
||||
|
@ -284,15 +296,23 @@ func convertToSearchResults(results interface{}) []SearchResult {
|
|||
genericResults[i] = r
|
||||
}
|
||||
return genericResults
|
||||
case []MusicResult:
|
||||
genericResults := make([]SearchResult, len(res))
|
||||
for i, r := range res {
|
||||
genericResults[i] = r
|
||||
}
|
||||
return genericResults
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertToSpecificResults(results []SearchResult) ([]TextSearchResult, []TorrentResult, []ImageSearchResult, []ForumSearchResult) {
|
||||
func convertToSpecificResults(results []SearchResult) ([]TextSearchResult, []TorrentResult, []ImageSearchResult, []ForumSearchResult, []MusicResult) {
|
||||
var textResults []TextSearchResult
|
||||
var torrentResults []TorrentResult
|
||||
var imageResults []ImageSearchResult
|
||||
var forumResults []ForumSearchResult
|
||||
var musicResults []MusicResult
|
||||
|
||||
for _, r := range results {
|
||||
switch res := r.(type) {
|
||||
case TextSearchResult:
|
||||
|
@ -303,7 +323,9 @@ func convertToSpecificResults(results []SearchResult) ([]TextSearchResult, []Tor
|
|||
imageResults = append(imageResults, res)
|
||||
case ForumSearchResult:
|
||||
forumResults = append(forumResults, res)
|
||||
case MusicResult:
|
||||
musicResults = append(musicResults, res)
|
||||
}
|
||||
}
|
||||
return textResults, torrentResults, imageResults, forumResults
|
||||
return textResults, torrentResults, imageResults, forumResults, musicResults
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue