fix failing tests / remove obsolente ones
add basic structure of episode page
This commit is contained in:
@ -1,15 +1,43 @@
|
||||
package api
|
||||
|
||||
import "openmediacenter/apiGo/database"
|
||||
import (
|
||||
"fmt"
|
||||
"openmediacenter/apiGo/database"
|
||||
)
|
||||
|
||||
func AddTvshowHandlers() {
|
||||
var dT struct {
|
||||
TagId int
|
||||
Force bool
|
||||
}
|
||||
AddHandler("getTVShows", TVShowNode, &dT, func() []byte {
|
||||
AddHandler("getTVShows", TVShowNode, nil, func() []byte {
|
||||
query := "SELECT id, name FROM tvshow"
|
||||
rows := database.Query(query)
|
||||
return jsonify(readTVshowsFromResultset(rows))
|
||||
})
|
||||
|
||||
var ge struct {
|
||||
ShowID uint32
|
||||
}
|
||||
AddHandler("getEpisodes", TVShowNode, &ge, func() []byte {
|
||||
query := fmt.Sprintf("SELECT id, name, season, episode FROM tvshow_episodes WHERE tvshow_id=%d", ge.ShowID)
|
||||
rows := database.Query(query)
|
||||
|
||||
type Episode struct {
|
||||
ID uint32
|
||||
Name string
|
||||
Season uint8
|
||||
Episode uint8
|
||||
}
|
||||
|
||||
episodes := []Episode{}
|
||||
for rows.Next() {
|
||||
var ep Episode
|
||||
err := rows.Scan(&ep.ID, &ep.Name, &ep.Season, &ep.Episode)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
episodes = append(episodes, ep)
|
||||
}
|
||||
|
||||
return jsonify(episodes)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user