Compare commits

..

34 Commits

Author SHA1 Message Date
Cadey Ratio 5dbc8ec9e8 update dockerfile to nim 0.15.0 2016-09-30 18:58:19 -07:00
David Wildasin af16ab4579
Season 6, episodes 24-26 2016-09-10 20:58:33 -04:00
David Wildasin e6c637ea1e
Season 6 Episode 23 2016-09-03 14:18:58 -04:00
David Wildasin f6f09b643f
Add season 6 episodes 19-22 2016-08-27 12:20:59 -04:00
Cadey Ratio 0578315e7e update jester version 2016-08-06 09:53:28 -07:00
Cadey Ratio f360f39933 reply with IRC line commands 2016-08-05 14:29:47 -07:00
David Wildasin 723ad49e83
Add S6 episodes 16, 17, and 18 2016-08-05 14:14:22 -04:00
David Wildasin 7c7446a6d7
Fix season 3 episode numbering
Season 3 was numbered by production order, for some reason
2016-07-26 18:22:33 -04:00
Cadey Ratio e25592d5d7 fix drone 2016-07-25 11:41:50 -07:00
Cadey Ratio c27a7e6d5f build status 2016-07-25 11:40:23 -07:00
Cadey Ratio 4685252143 automatic redeploy 2016-07-25 11:40:22 -07:00
Cadey Ratio 7972261464 really use sh 2016-07-25 11:40:22 -07:00
Cadey Ratio f59ef1ff1f use sh 2016-07-25 11:40:22 -07:00
Cadey Ratio 6af4b84be6 drone actually tests the api 2016-07-25 11:40:22 -07:00
Cadey Ratio 7adcf97746 drone tests the api 2016-07-25 11:40:22 -07:00
Cadey Ratio ca8f498af4 Allow drone to push 2016-07-15 13:57:30 -07:00
Cadey Ratio 8ec3967a01 drone.yml 2016-07-15 13:54:36 -07:00
Cadey Ratio 884da8cc78 fix dockerfile
Closes #15
2016-07-15 12:42:17 -07:00
Cadey Ratio 36cd059810 use srcDir, remove old/irellevant code 2016-07-14 16:17:12 -07:00
Cadey Ratio 9cf4501c1b add docker-compose file 2016-07-14 16:04:49 -07:00
Cadey Ratio a020f0cede Unfuck the api
Closes #13
2016-07-14 15:59:25 -07:00
Cadey Ratio 832914c5ea Merge pull request #13 from dragonmaus/master
Adjust timestamps to account for Daylight Savings Time
2016-07-11 13:42:55 -07:00
David Wildasin bff074ea6a Adjust timestamps to account for Daylight Savings Time
Also, a couple of episodes were out of order
2016-07-11 16:31:34 -04:00
Cadey Ratio 62763a0864 Merge pull request #12 from dragonmaus/master
Add S6 episodes 13, 14, and 15
2016-07-11 13:16:27 -07:00
David Wildasin 8aa34cd692 Add S6 episodes 13, 14, and 15 2016-07-11 16:13:48 -04:00
Cadey Ratio 163578ce8c Actually use my custom dockerfile
Ref #11
2016-07-05 14:20:08 -07:00
Cadey Ratio a669ee2018 Nim 0.14 update 2016-07-02 21:53:36 -07:00
Cadey Ratio fac0d25655 Merge pull request #10 from Diftraku/master
Change S06E09 episode title
2016-05-22 15:45:18 -07:00
Toni Kaija fbb8b7a48d Change S06E09 episode title
The aired title is "The Saddle Row Review"
2016-05-23 01:43:33 +03:00
Cadey Ratio 9996db4179 Merge pull request #9 from PonyFrance/feature-newEP
Added S6 episodes 11 and 12
2016-05-16 14:51:56 -07:00
MKody 99738d11b1 Added S6 episodes 11 and 12 2016-05-14 16:30:51 +02:00
Cadey Ratio 29430a1814 Merge pull request #8 from PonyFrance/update-episodes-list
And more horse
2016-04-24 19:10:26 -07:00
MKody 51a1fae0d3 And more horse 2016-04-23 08:06:59 +00:00
Cadey Ratio 3a9314f8ca Revert "fix newest/last aired routes"
This reverts commit 8e92e1097e.
2016-04-22 06:17:42 -07:00
12 changed files with 98 additions and 76 deletions

21
.drone.yml Normal file
View File

@ -0,0 +1,21 @@
build:
image: xena/nim:0.14.2
commands:
- nimble refresh
- yes | nimble install
- cd client/nim
- sh ./test.sh
deploy:
git_push:
branch: master
remote: git@github.com:Xe/PonyAPI.git
ssh:
host: greedo.xeserv.us
user: xena
port: 22
commands:
- cd ~/code/ponyapi
- docker-compose build
- docker-compose up -d

View File

@ -1,17 +1,15 @@
FROM coopernurse/docker-nim FROM xena/nim:0.15.0
RUN apk update && apk add bash
EXPOSE 5000 EXPOSE 5000
RUN adduser -D -g '' r RUN adduser -D -g '' r
RUN chmod a+x /opt/Nim/bin/nim
ADD . /app ADD . /app
WORKDIR /app WORKDIR /app
RUN nimble update &&\ RUN nimble update &&\
yes | nimble build &&\
yes | nimble install &&\ yes | nimble install &&\
nim c -d:release --deadCodeElim:on ponyapi cp ~/.nimble/bin/ponyapi /usr/bin/ponyapi
USER r USER r
CMD ./ponyapi CMD /usr/bin/ponyapi

View File

@ -1,6 +1,8 @@
PonyAPI PonyAPI
======= =======
[![Build Status](http://drone.greedo.xeserv.us/api/badges/xena/PonyAPI/status.svg)](http://drone.greedo.xeserv.us/xena/PonyAPI)
A simple API for episodes of My Little Pony: Friendship is Magic to be run A simple API for episodes of My Little Pony: Friendship is Magic to be run
inside a container. inside a container.

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e

8
docker-compose.yml Normal file
View File

@ -0,0 +1,8 @@
version: "2"
services:
ponyapi:
build: .
ports:
- "6452:5000"
restart: always

View File

@ -1,7 +1,7 @@
FIM 1286735400 1 1 Friendship is Magic Part 1 FIM 1286731800 1 1 Friendship is Magic Part 1
FIM 1287772200 1 2 Friendship is Magic Part 2 FIM 1287768600 1 2 Friendship is Magic Part 2
FIM 1288377000 1 3 The Ticket Master FIM 1288373400 1 3 The Ticket Master
FIM 1288981800 1 4 Applebuck Season FIM 1288978200 1 4 Applebuck Season
FIM 1289586600 1 5 Griffon the Brush Off FIM 1289586600 1 5 Griffon the Brush Off
FIM 1290191400 1 6 Boast Busters FIM 1290191400 1 6 Boast Busters
FIM 1290796200 1 7 Dragonshy FIM 1290796200 1 7 Dragonshy
@ -17,13 +17,13 @@ FIM 1298053800 1 16 Sonic Rainboom
FIM 1298658600 1 17 Stare Master FIM 1298658600 1 17 Stare Master
FIM 1299263400 1 18 The Show Stoppers FIM 1299263400 1 18 The Show Stoppers
FIM 1299868200 1 19 A Dog and Pony Show FIM 1299868200 1 19 A Dog and Pony Show
FIM 1300473000 1 20 Green Isn't Your Color FIM 1300469400 1 20 Green Isn't Your Color
FIM 1301077800 1 21 Over a Barrel FIM 1301074200 1 21 Over a Barrel
FIM 1302287400 1 22 A Bird in the Hoof FIM 1302283800 1 22 A Bird in the Hoof
FIM 1302892200 1 23 The Cutie Mark Chronicles FIM 1302888600 1 23 The Cutie Mark Chronicles
FIM 1303497000 1 24 Owl's Well That Ends Well FIM 1303493400 1 24 Owl's Well That Ends Well
FIM 1304101800 1 25 Party of One FIM 1304098200 1 25 Party of One
FIM 1304706600 1 26 The Best Night Ever FIM 1304703000 1 26 The Best Night Ever
FIM 1316264400 2 1 The Return of Harmony Part 1 FIM 1316264400 2 1 The Return of Harmony Part 1
FIM 1316869200 2 2 The Return of Harmony Part 2 FIM 1316869200 2 2 The Return of Harmony Part 2
FIM 1318683600 2 3 Lesson Zero FIM 1318683600 2 3 Lesson Zero
@ -57,10 +57,10 @@ FIM 1353771000 3 4 One Bad Apple
FIM 1354375800 3 5 Magic Duel FIM 1354375800 3 5 Magic Duel
FIM 1354980600 3 6 Sleepless in Ponyville FIM 1354980600 3 6 Sleepless in Ponyville
FIM 1355585400 3 7 Wonderbolt Academy FIM 1355585400 3 7 Wonderbolt Academy
FIM 1356190200 3 9 Apple Family Reunion FIM 1356190200 3 8 Apple Family Reunion
FIM 1356795000 3 10 Spike at Your Service FIM 1356795000 3 9 Spike at Your Service
FIM 1358609400 3 11 Keep Calm and Flutter On FIM 1358609400 3 10 Keep Calm and Flutter On
FIM 1359214200 3 8 Just for Sidekicks FIM 1359214200 3 11 Just for Sidekicks
FIM 1360423800 3 12 Games Ponies Play FIM 1360423800 3 12 Games Ponies Play
FIM 1361028600 3 13 Magical Mystery Cure FIM 1361028600 3 13 Magical Mystery Cure
FIM 1385218800 4 1 Princess Twilight Sparkle - Part 1 FIM 1385218800 4 1 Princess Twilight Sparkle - Part 1
@ -71,8 +71,8 @@ FIM 1387035000 4 5 Flight to the Finish
FIM 1387639800 4 6 Power Ponies FIM 1387639800 4 6 Power Ponies
FIM 1388244600 4 7 Bats! FIM 1388244600 4 7 Bats!
FIM 1388849400 4 8 Rarity Takes Manehattan FIM 1388849400 4 8 Rarity Takes Manehattan
FIM 1390059000 4 10 Rainbow Falls
FIM 1389454200 4 9 Pinkie Apple Pie FIM 1389454200 4 9 Pinkie Apple Pie
FIM 1390059000 4 10 Rainbow Falls
FIM 1390663800 4 11 Three's a Crowd FIM 1390663800 4 11 Three's a Crowd
FIM 1391268600 4 12 Pinkie Pride FIM 1391268600 4 12 Pinkie Pride
FIM 1391873400 4 13 Simple Ways FIM 1391873400 4 13 Simple Ways
@ -89,9 +89,9 @@ FIM 1398522600 4 23 Inspiration Manifestation
FIM 1399127400 4 24 Equestria Games FIM 1399127400 4 24 Equestria Games
FIM 1399730400 4 25 Twilight's Kingdom - Part 1 FIM 1399730400 4 25 Twilight's Kingdom - Part 1
FIM 1399732200 4 26 Twilight's Kingdom - Part 2 FIM 1399732200 4 26 Twilight's Kingdom - Part 2
FIM 1428768000 5 3 Castle Sweet Castle
FIM 1428159600 5 1 The Cutie Map Part 1 FIM 1428159600 5 1 The Cutie Map Part 1
FIM 1428161400 5 2 The Cutie Map Part 2 FIM 1428161400 5 2 The Cutie Map Part 2
FIM 1428766200 5 3 Castle Sweet Castle
FIM 1429371000 5 4 Bloom and Gloom FIM 1429371000 5 4 Bloom and Gloom
FIM 1429975800 5 5 Tanks for the Memories FIM 1429975800 5 5 Tanks for the Memories
FIM 1430580600 5 6 Appleoosa's Most Wanted FIM 1430580600 5 6 Appleoosa's Most Wanted
@ -121,6 +121,26 @@ FIM 1459611000 6 3 The Gift of the Maud Pie
FIM 1460215800 6 4 On Your Marks FIM 1460215800 6 4 On Your Marks
FIM 1460820600 6 5 Gauntlet of Fire FIM 1460820600 6 5 Gauntlet of Fire
FIM 1462030200 6 6 No Second Prances FIM 1462030200 6 6 No Second Prances
FIM 1462635000 6 7 Newbie Dash
FIM 1463239800 6 8 A Hearth's Warming Tail
FIM 1463844600 6 9 The Saddle Row Review
FIM 1464449400 6 10 Applejack's "Day" Off
FIM 1465054200 6 11 Flutter Brutter
FIM 1465659000 6 12 Spice Up Your Life
FIM 1469892600 6 13 Stranger Than Fan Fiction
FIM 1470497400 6 14 The Cart Before the Ponies
FIM 1471102200 6 15 28 Pranks Later
FIM 1471707000 6 16 The Times They Are a Changeling
FIM 1472311800 6 17 Dungeons & Discords
FIM 1472916600 6 18 Buckball Season
FIM 1473521400 6 19 The Fault in Our Cutie Marks
FIM 1474126200 6 20 Viva Las Pegasus
FIM 1474731000 6 21 Every Little Thing She Does
FIM 1475335800 6 22 P.P.O.V. (Pony Point of View)
FIM 1475940600 6 23 Where the Apple Lies
FIM 1476545400 6 24 Top Bolt
FIM 1477148400 6 25 To Where and Back Again: Part 1
FIM 1477150200 6 26 To Where and Back Again: Part 2
FIM 1371340800 99 1 Equestria Girls FIM 1371340800 99 1 Equestria Girls
FIM 1411862400 99 2 Equestria Girls - Rainbow Rocks FIM 1411862400 99 2 Equestria Girls - Rainbow Rocks
FIM 1443321000 99 3 Equestria Girls - Friendship Games FIM 1443321000 99 3 Equestria Girls - Friendship Games

View File

@ -1,11 +1,8 @@
# Package version = "0.1.0"
author = "Christine Dodrill <xena@yolo-swag.com>"
version = "0.2.0"
author = "Cadey Dodrill"
description = "PonyAPI server https://github.com/Xe/PonyAPI" description = "PonyAPI server https://github.com/Xe/PonyAPI"
license = "MIT" license = "MIT"
srcDir = "src"
bin = @["ponyapi"] bin = @["ponyapi"]
# Dependencies requires "nim >= 0.10.0", "jester#head", "random"
requires "nim >= 0.13.0", "jester#head", "random#head", "sam#head", "jsmn#head"

View File

@ -1,7 +0,0 @@
ponyapi.apps.xeserv.us {
log syslog
proxy / http://127.0.0.1:6452 {
proxy_header Host {host}
}
}

View File

@ -1,13 +0,0 @@
[Unit]
Description=PonyAPI Server listening on port 6452
Requires=docker.service
Restart=always
[Service]
ExecStartPre=-/usr/bin/docker pull xena/ponyapi
ExecStartPre=-/usr/bin/docker rm -f ponyapi
ExecStart=/usr/bin/docker run -p 6452:5000 --name ponyapi xena/ponyapi
ExecStop=/usr/bin/docker rm -f ponyapi
[Install]
WantedBy=network.target

View File

@ -1,6 +1,7 @@
import asyncdispatch import asyncdispatch
import episode import episode
import future import future
import httpcore
import jester import jester
import json import json
import os import os
@ -58,16 +59,9 @@ template httpReply(code, body: expr): expr =
## Make things a lot simpler for replies, etc. ## Make things a lot simpler for replies, etc.
if request.headers.getOrDefault("X-API-Options") == "bare" or @"options" == "bare": if request.headers.getOrDefault("X-API-Options") == "bare" or @"options" == "bare":
# New "bare" reply format, easier to scrape, etc. # New "bare" reply format, easier to scrape, etc.
resp code, myHeaders, pretty(%body, 4) resp code, pretty(%body, 4), "application/json"
else: else:
resp code, myHeaders, pretty(%%body, 4) resp code, pretty(%%body, 4), "application/json"
let myHeaders = {
"Content-Type": "application/json",
"X-Powered-By": "Nim and Jester",
"X-Git-Hash": getEnv("GIT_REV"),
"X-Server-Epoch": $ getTime().toSeconds().int,
}
settings: settings:
port = 5000.Port port = 5000.Port
@ -102,17 +96,19 @@ routes:
get "/random": get "/random":
stats.newest.success.inc stats.newest.success.inc
httpReply Http200, episodes.randomChoice() httpReply Http200, episodes[epochTime().int mod len(episodes)]
get "/last_aired": get "/last_aired":
var var
#now = getTime() now = getTime()
ep: Episode ep: Episode
for epid, episode in pairs[Episode](episodes): for epid, episode in pairs[Episode](episodes):
# XXX HACK PLEASE FIX var then = times.fromSeconds(episode.air_date)
if episode.season == 5 and episode.episode == 26:
ep = episode if now < then:
ep = episodes[epid-1]
break
stats.lastAired.success.inc stats.lastAired.success.inc
httpReply Http200, ep httpReply Http200, ep
@ -143,7 +139,7 @@ routes:
if @"format" == "irccmd": if @"format" == "irccmd":
let let
irccmd = "/cs episode del $1 $2\n/cs episode add $1 $2 $3 $4" % [$ep.season, $ep.episode, $ep.air_date, ep.name] irccmd = "/cs episode del $1 $2\n/cs episode add $1 $2 $3 $4" % [$ep.season, $ep.episode, $ep.air_date, ep.name]
echo irccmd halt Http200, irccmd
if ep.air_date == 0: if ep.air_date == 0:
stats.episodeLookup.fails.inc stats.episodeLookup.fails.inc
@ -158,7 +154,7 @@ routes:
if query == "": if query == "":
stats.search.fails.inc stats.search.fails.inc
halt Http406, myHeaders, pretty(%%"Need to specify a query", 4) halt Http406, pretty(%%"Need to specify a query", 4)
var var
eps: seq[Episode] = eps: seq[Episode] =
@ -172,7 +168,7 @@ routes:
httpReply Http200, eps httpReply Http200, eps
get "/_stats": get "/_stats":
resp Http200, myHeaders, pretty(%* resp Http200, pretty(%*
[ [
stats.all, stats.all,
stats.newest, stats.newest,