Changed titles JSON
This commit is contained in:
parent
fccee39031
commit
cace579c44
57
server.go
57
server.go
|
@ -72,20 +72,20 @@ func (t JSONTime) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
type albumEntry struct {
|
||||
Id int `json:"pageid"`
|
||||
Type string `json:"type"`
|
||||
MainTitle string `json:"pagetitle"`
|
||||
Titles []string `json:"titles"`
|
||||
Image string `json:"image,omitempty"`
|
||||
CatalogNumbers []string `json:"catalognumbers,omitempty"`
|
||||
Genre []string `json:"genre,omitempty"`
|
||||
TrackCount int `json:"trackcount,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
ReleaseDate JSONTime `json:"releasedate,omitempty"`
|
||||
ReleaseEvent string `json:"releaseevent,omitempty"`
|
||||
Links []string `json:"links,omitempty"`
|
||||
Artists []artistEntry `json:"artists,omitempty"`
|
||||
Discs []discEntry `json:"discs,omitempty"`
|
||||
Id int `json:"pageid"`
|
||||
Type string `json:"type"`
|
||||
MainTitle string `json:"pagetitle"`
|
||||
Titles map[string]string `json:"titles"`
|
||||
Image string `json:"image,omitempty"`
|
||||
CatalogNumbers []string `json:"catalognumbers,omitempty"`
|
||||
Genre []string `json:"genre,omitempty"`
|
||||
TrackCount int `json:"trackcount,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
ReleaseDate JSONTime `json:"releasedate,omitempty"`
|
||||
ReleaseEvent string `json:"releaseevent,omitempty"`
|
||||
Links []string `json:"links,omitempty"`
|
||||
Artists []artistEntry `json:"artists,omitempty"`
|
||||
Discs []discEntry `json:"discs,omitempty"`
|
||||
}
|
||||
type discEntry struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
|
@ -94,13 +94,13 @@ type discEntry struct {
|
|||
Tracks []trackEntry `json:"tracks"`
|
||||
}
|
||||
type trackEntry struct {
|
||||
Duration int `json:"duration,omitempty"`
|
||||
MainTitle string `json:"title,omitempty"`
|
||||
Titles []string `json:"titles,omitempty"`
|
||||
Artists []artistEntry `json:"artists,omitempty"`
|
||||
Lyrics string `json:"lyrics,omitempty"`
|
||||
Links []string `json:"links,omitempty"`
|
||||
Original []string `json:"original,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
MainTitle string `json:"title,omitempty"`
|
||||
Titles map[string]string `json:"titles,omitempty"`
|
||||
Artists []artistEntry `json:"artists,omitempty"`
|
||||
Lyrics string `json:"lyrics,omitempty"`
|
||||
Links []string `json:"links,omitempty"`
|
||||
Original []string `json:"original,omitempty"`
|
||||
}
|
||||
type artistEntry struct {
|
||||
Position string `json:"position"`
|
||||
|
@ -354,19 +354,19 @@ func processIndexDirectory(filePath, indexPath, kind string, wg *sync.WaitGroup)
|
|||
|
||||
if val, ok = tpl.Parameters["titleen"]; ok {
|
||||
if stringVal = getStringValue(val, opts); len(stringVal) > 0 {
|
||||
entry.Titles = append(entry.Titles, stringVal[0])
|
||||
entry.Titles["english"] = stringVal[0]
|
||||
}
|
||||
}
|
||||
|
||||
if val, ok = tpl.Parameters["titlejp"]; ok {
|
||||
if stringVal = getStringValue(val, opts); len(stringVal) > 0 {
|
||||
entry.Titles = append(entry.Titles, stringVal[0])
|
||||
entry.Titles["japanese"] = stringVal[0]
|
||||
}
|
||||
}
|
||||
|
||||
if val, ok = tpl.Parameters["titlejprom"]; ok {
|
||||
if stringVal = getStringValue(val, opts); len(stringVal) > 0 {
|
||||
entry.Titles = append(entry.Titles, stringVal[0])
|
||||
entry.Titles["romaji"] = stringVal[0]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,11 +474,13 @@ func processIndexDirectory(filePath, indexPath, kind string, wg *sync.WaitGroup)
|
|||
if sliceVal, ok := listVal.Entries[0].([]interface{}); ok && len(sliceVal) > 0 {
|
||||
|
||||
if trackTpl, ok := sliceVal[0].(*wikitext_parser.Template); ok && strings.ToUpper(trackTpl.Name) == "TRACK" && len(trackTpl.Parameters) >= 3 {
|
||||
track := trackEntry{}
|
||||
track := trackEntry{
|
||||
Titles: make(map[string]string),
|
||||
}
|
||||
|
||||
if mainTitleValue := getStringValue(trackTpl.Parameters["1"], opts); len(mainTitleValue) > 0 {
|
||||
track.MainTitle = strings.Join(mainTitleValue, "")
|
||||
track.Titles = append(track.Titles, track.MainTitle)
|
||||
track.Titles["original"] = track.MainTitle
|
||||
}
|
||||
if durations := getStringValue(trackTpl.Parameters["2"], opts); len(durations) > 0 {
|
||||
split := strings.Split(durations[0], ":")
|
||||
|
@ -512,7 +514,7 @@ func processIndexDirectory(filePath, indexPath, kind string, wg *sync.WaitGroup)
|
|||
keyValue := strings.Split(strings.Join(getStringValue(descVal, opts), " "), ":")
|
||||
if len(keyValue) > 0 {
|
||||
if i == 0 && len(keyValue[0]) > 2 && keyValue[0][0:2] == "''" {
|
||||
track.Titles = append(track.Titles, strings.Trim(strings.Join(keyValue, " "), "'' "))
|
||||
track.Titles["english"] = strings.Trim(strings.Join(keyValue, " "), "'' ")
|
||||
continue
|
||||
}
|
||||
keyEntry := strings.ToLower(keyValue[0])
|
||||
|
@ -619,6 +621,7 @@ func processIndexDirectory(filePath, indexPath, kind string, wg *sync.WaitGroup)
|
|||
Id: v.PageId,
|
||||
MainTitle: v.Title,
|
||||
Type: kind,
|
||||
Titles: make(map[string]string),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue