parent
24ef6f4c69
commit
b5d36da2b6
|
@ -64,6 +64,11 @@ objects as defined above.
|
||||||
|
|
||||||
Returns the episode of My Little Pony: Friendship is Magic that will air next.
|
Returns the episode of My Little Pony: Friendship is Magic that will air next.
|
||||||
|
|
||||||
|
### `/last_aired`
|
||||||
|
|
||||||
|
Returns the episode of My Little Pony: Friendship is Magic that most recently
|
||||||
|
aired.
|
||||||
|
|
||||||
### `/season/<number>`
|
### `/season/<number>`
|
||||||
|
|
||||||
Returns all information about episodes in the given season number or a `404`
|
Returns all information about episodes in the given season number or a `404`
|
||||||
|
|
14
ponyapi.nim
14
ponyapi.nim
|
@ -85,6 +85,20 @@ routes:
|
||||||
get "/random":
|
get "/random":
|
||||||
resp Http200, myHeaders, pretty(%%episodes.randomChoice(), 4)
|
resp Http200, myHeaders, pretty(%%episodes.randomChoice(), 4)
|
||||||
|
|
||||||
|
get "/last_aired":
|
||||||
|
var
|
||||||
|
now = getTime()
|
||||||
|
ep: Episode
|
||||||
|
|
||||||
|
for epid, episode in pairs[Episode](episodes):
|
||||||
|
var then = times.fromSeconds(episode.air_date)
|
||||||
|
|
||||||
|
if now < then:
|
||||||
|
ep = episodes[epid-1]
|
||||||
|
break
|
||||||
|
|
||||||
|
resp Http200, myHeaders, pretty(%%ep, 4)
|
||||||
|
|
||||||
get "/season/@snumber":
|
get "/season/@snumber":
|
||||||
var
|
var
|
||||||
season: int = @"snumber".parseInt
|
season: int = @"snumber".parseInt
|
||||||
|
|
Loading…
Reference in New Issue