Add "last episode that aired" function
Keep in mind that this API has no use limits, so making multiple API calls is fine. Closes #1
This commit is contained in:
parent
61c4d3f663
commit
5cd385a4bd
|
@ -1,4 +1,5 @@
|
||||||
import requests
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# PonyAPI module for Python programs
|
# PonyAPI module for Python programs
|
||||||
|
@ -20,6 +21,7 @@ Available methods:
|
||||||
|
|
||||||
all_episodes() -> return all information on all episodes
|
all_episodes() -> return all information on all episodes
|
||||||
newest() -> return information on the newest episode
|
newest() -> return information on the newest episode
|
||||||
|
last_aired() -> returns the episode that most recently aired
|
||||||
random() -> return a random episode
|
random() -> return a random episode
|
||||||
get_season(snum) -> return all episodes in season snum
|
get_season(snum) -> return all episodes in season snum
|
||||||
get_episode(snum, enum) -> return info on season snum episode enum
|
get_episode(snum, enum) -> return info on season snum episode enum
|
||||||
|
@ -82,3 +84,12 @@ def search(query):
|
||||||
raise Exception("Not found or server error")
|
raise Exception("Not found or server error")
|
||||||
|
|
||||||
return r.json()["episodes"]
|
return r.json()["episodes"]
|
||||||
|
|
||||||
|
# last_aired :: IO Episode
|
||||||
|
# TODO: Does not know how to wrap around seasons, fix this
|
||||||
|
def last_aired():
|
||||||
|
new = newest()
|
||||||
|
|
||||||
|
if new[u"air_date"] > int(time.time()):
|
||||||
|
return get_episode(new[u"season"], (new[u"episode"]-1))
|
||||||
|
return new
|
||||||
|
|
Loading…
Reference in New Issue