This repository has been archived by the owner on Jun 3, 2019. It is now read-only.
/
Mapping.go
84 lines (80 loc) · 2.33 KB
/
Mapping.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package arn
// Register a list of supported services.
func init() {
DataLists["mapping-services"] = []*Option{
{"anidb/anime", "anidb/anime"},
{"anilist/anime", "anilist/anime"},
{"anilist/character", "anilist/character"},
{"anilist/studio", "anilist/studio"},
{"ann/company", "ann/company"},
{"imdb/anime", "imdb/anime"},
{"kitsu/anime", "kitsu/anime"},
{"kitsu/character", "kitsu/character"},
{"myanimelist/anime", "myanimelist/anime"},
{"myanimelist/character", "myanimelist/character"},
{"myanimelist/producer", "myanimelist/producer"},
{"shoboi/anime", "shoboi/anime"},
{"thetvdb/anime", "thetvdb/anime"},
{"trakt/anime", "trakt/anime"},
{"trakt/season", "trakt/season"},
}
}
// Mapping ...
type Mapping struct {
Service string `json:"service" editable:"true" datalist:"mapping-services"`
ServiceID string `json:"serviceId" editable:"true"`
}
// Name ...
func (mapping *Mapping) Name() string {
switch mapping.Service {
case "anidb/anime":
return "AniDB"
case "anilist/anime":
return "AniList"
case "imdb/anime":
return "IMDb"
case "kitsu/anime":
return "Kitsu"
case "myanimelist/anime":
return "MAL"
case "shoboi/anime":
return "Shoboi"
case "thetvdb/anime":
return "TVDB"
case "trakt/anime":
return "Trakt"
case "trakt/season":
return "Trakt"
default:
return mapping.Service
}
}
// Link ...
func (mapping *Mapping) Link() string {
switch mapping.Service {
case "kitsu/anime":
return "https://kitsu.io/anime/" + mapping.ServiceID
case "shoboi/anime":
return "http://cal.syoboi.jp/tid/" + mapping.ServiceID
case "anilist/anime":
return "https://anilist.co/anime/" + mapping.ServiceID
case "anilist/character":
return "https://anilist.co/character/" + mapping.ServiceID
case "anilist/studio":
return "https://anilist.co/studio/" + mapping.ServiceID
case "imdb/anime":
return "https://www.imdb.com/title/" + mapping.ServiceID
case "myanimelist/anime":
return "https://myanimelist.net/anime/" + mapping.ServiceID
case "thetvdb/anime":
return "https://thetvdb.com/?tab=series&id=" + mapping.ServiceID
case "anidb/anime":
return "https://anidb.net/perl-bin/animedb.pl?show=anime&aid=" + mapping.ServiceID
case "trakt/anime":
return "https://trakt.tv/shows/" + mapping.ServiceID
case "trakt/season":
return "https://trakt.tv/seasons/" + mapping.ServiceID
default:
return ""
}
}