]> git.lizzy.rs Git - go-anidb.git/blob - titles.go
anidb: Implement GroupByName
[go-anidb.git] / titles.go
1 package anidb
2
3 import (
4         "github.com/Kovensky/go-anidb/titles"
5 )
6
7 // Searches for the given anime name, case sensitive.
8 //
9 // Returns the match with the smallest AID.
10 func SearchAnime(name string) AID {
11         rs := SearchAnimeAll(name).ResultsByAID()
12         if len(rs) == 0 {
13                 return 0
14         }
15         return AID(rs[0].AID)
16 }
17
18 // Searches for all anime that match the given anime name, case sensitive.
19 func SearchAnimeAll(name string) titles.ResultSet {
20         return titlesDB.FuzzySearch(name)
21 }
22
23 // Searches for the given anime name, case folding.
24 //
25 // Returns the match with the smallest AID.
26 func SearchAnimeFold(name string) AID {
27         rs := SearchAnimeFoldAll(name).ResultsByAID()
28         if len(rs) == 0 {
29                 return 0
30         }
31         return AID(rs[0].AID)
32 }
33
34 // Searches for all anime that match the given anime name, case folding.
35 func SearchAnimeFoldAll(name string) titles.ResultSet {
36         return titlesDB.FuzzySearchFold(name)
37 }