Start from the beginning
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
package indexer
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type MusicSearchCriteria struct {
|
||||
Artist string
|
||||
Album *string
|
||||
Year *uint32
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
func (c *MusicSearchCriteria) CleanArtist() string {
|
||||
return cleanSearchTerm(c.Artist)
|
||||
}
|
||||
|
||||
func (c *MusicSearchCriteria) CleanAlbum() *string {
|
||||
if c.Album == nil {
|
||||
return nil
|
||||
}
|
||||
cleaned := cleanSearchTerm(*c.Album)
|
||||
return &cleaned
|
||||
}
|
||||
|
||||
var cleanRegex = regexp.MustCompile(`[^\w\s]`)
|
||||
|
||||
func cleanSearchTerm(s string) string {
|
||||
s = cleanRegex.ReplaceAllString(s, " ")
|
||||
fields := strings.Fields(s)
|
||||
return strings.Join(fields, " ")
|
||||
}
|
||||
|
||||
type SearchResult struct {
|
||||
GUID string `json:"guid"`
|
||||
Title string `json:"title"`
|
||||
DownloadURL string `json:"download_url"`
|
||||
InfoURL *string `json:"info_url,omitempty"`
|
||||
Size uint64 `json:"size"`
|
||||
PublishDate *string `json:"publish_date,omitempty"`
|
||||
Artist *string `json:"artist,omitempty"`
|
||||
Album *string `json:"album,omitempty"`
|
||||
Year *uint32 `json:"year,omitempty"`
|
||||
Label *string `json:"label,omitempty"`
|
||||
Seeders *int `json:"seeders,omitempty"`
|
||||
Leechers *int `json:"leechers,omitempty"`
|
||||
Grabs *int `json:"grabs,omitempty"`
|
||||
Infohash *string `json:"infohash,omitempty"`
|
||||
MagnetURL *string `json:"magnet_url,omitempty"`
|
||||
Indexer string `json:"indexer"`
|
||||
Categories []uint32 `json:"categories"`
|
||||
}
|
||||
Reference in New Issue
Block a user