]> git.lizzy.rs Git - go-anidb.git/blob - titles.go
Modernize
[go-anidb.git] / titles.go
1 package anidb
2
3 import (
4         "github.com/EliasFleckenstein03/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         if name == "" {
21                 return nil
22         }
23         return titlesDB.FuzzySearch(name)
24 }
25
26 // Searches for the given anime name, case folding.
27 //
28 // Returns the match with the smallest AID.
29 func SearchAnimeFold(name string) AID {
30         rs := SearchAnimeFoldAll(name).ResultsByAID()
31         if len(rs) == 0 {
32                 return 0
33         }
34         return AID(rs[0].AID)
35 }
36
37 // Searches for all anime that match the given anime name, case folding.
38 func SearchAnimeFoldAll(name string) titles.ResultSet {
39         if name == "" {
40                 return nil
41         }
42         return titlesDB.FuzzySearchFold(name)
43 }