Async API Reference¶
CompuGlobal allows for both random and searchable screencaps, images and gifs embedded with default or custom captions for the following shows:
The Simpsons, Futurama, Rick and Morty, West Wing and 30 Rock.
Note
This library relies upon undocumented external APIs.
Contents¶
API Endpoints¶
- class compuglobal.aio.CompuGlobalAPI(url, title, timeout)
Represents an API Wrapper used for accessing the cghmc API endpoints.
- Parameters
url (str) – The url of the API.
title (str) – The title of the tv show/movie/skit that the url leads to.
timeout (float) – The timeout for websocket read.
- Variables
random_url (str) – Endpoint used for getting a random screencap.
caption_url (str) – Endpoint for getting caption info using episode and timestamp
e = episode & t = timestamp
.search_url (str) – Endpoint for getting screencaps using a search query
q = search query
.frames_url (str) – Endpoint for getting all valid frames before & after an episode and timestamp
episode/timestamp/before/after
.nearby_url (str) – Endpoint for getting all valid frames nearby an episode and timestamp
e = episode & t = timestamp
.episode_url (str) – Endpoint for getting episode info and subtitles from start to end for episode
episode/start/end
.
- coroutine get_screencap(episode=None, timestamp=None, frame=None)
Performs a GET request to the
api/caption?e={}&t={}
endpoint and gets a TV Show screencap using episodee={}
and timestampt={}
- Parameters
episode (str) – The episode key of the screencap.
timestamp (int) – The timestamp of the screencap.
frame (compuglobal.Frame) – The frame of the screencap.
- Returns
A Screencap objecct for the episode and timestamp.
- Return type
compuglobal.Screencap
- Raises
APIPageStatusError – Raises an exception if the status code of the request is not 200.
TypeError – Raises an exception if the constructor does not receive episode and timestamp, or compuglobal.Frame
Note
Used for getting the episode info and caption shown below each screencap.
- coroutine get_random_screencap()
Performs a GET request to the
api/random
endpoint and gets a random TV Show screencap.- Returns
A random screencap object.
- Return type
compuglobal.Screencap
- Raises
APIPageStatusError – Raises an exception if the status code of the request is not 200.
Note
Used for getting a random screencap when clicking the “RANDOM” button.
- coroutine search(search_text)
Performs a GET request to the
api/search?q=
endpoint and gets a list of search results using the search text as the search queryq={}
for the request.- Parameters
search_text (str) – The text/quote to search for.
- Returns
search_results – A list of search results containing the id, episode and timestamp for each result.
- Return type
list
- Raises
APIPageStatusError – Raises an exception if the status code of the request is not 200.
NoSearchResultsFound – Raises an exception if there are no search results found using search_text.
Note
Used for displaying all the search results and their screencaps.
- coroutine search_for_screencap(search_text)
Performs a GET request to the
api/search?q=
endpoint usingsearch()
to get a list of search results using search_text and gets a screencap using the episode and timestamp of the first search result.- Parameters
search_text (str) – The text/quote to search for.
- Returns
A screencap object of the first search result found using search_text.
- Return type
compuglobal.Screencap
- Raises
APIPageStatusError – Raises an exception if the status code of the request is not 200.
NoSearchResultsFound – Raises an exception if there are no search results found using search_text.
- coroutine get_frames(episode, timestamp, before, after)
Performs a GET request to the
api/frames/{episode}/{timestamp}/{before}/{after}
endpoint and gets a list of all valid frames before and after the timestamp of the episode.- Parameters
episode (str) – The episode key of the screencap.
timestamp (int) – The timestamp of the screencap.
before (int) – The number of milliseconds before the timestamp.
after (int) – The number of milliseconds after the timestamp.
- Returns
A list of valid frames before and after the timestamp of the episode, containing the id, episode and timestamp for each frame.
- Return type
list
- Raises
APIPageStatusError – Raises an exception if the status code of the request is not 200.
Note
Used for displaying the valid frames available for the gifmaker.
- coroutine generate_gif(gif_url)
Performs a GET request using gif_url and returns the direct url for the gif once it has been generated.
- Parameters
gif_url (str) – The url of the gif to generate.
- Returns
The direct url for the generated gif
- Return type
str
- Raises
APIPageStatusError – Raises an exception if the status code of the request is not 200.
Errors¶
- class compuglobal.aio.APIPageStatusError(page_status, url)¶
Raised when the status code for the API is not 200.
- Parameters
page_status (int) – The page status number for the error.
url (str) – The url page that encountered the error.
- class compuglobal.aio.NoSearchResultsFound¶
Raised when no search results are returned during a search query to the search endpoint of the API.
Supported APIs¶
Frinkiac¶
- class compuglobal.aio.Frinkiac(timeout=15)
An API Wrapper for accessing Frinkiac API endpoints (The Simpsons).
Morbotron¶
- class compuglobal.aio.Morbotron(timeout=15)
An API Wrapper for accessing Morbotron API endpoints (Futurama).
Master Of All Science¶
- class compuglobal.aio.MasterOfAllScience(timeout=15)
An API Wrapper for accessing MasterOfAllScience API endpoints (Rick and Morty).
Good God Lemon¶
- class compuglobal.aio.GoodGodLemon(timeout=15)
An API Wrapper for accessing GoodGodLemon API endpoints (30 Rock).
Capital Beat Us¶
- class compuglobal.aio.CapitalBeatUs(timeout=15)
An API Wrapper for accessing CapitalBeatUs API endpoints (West Wing).
FrinkiHams¶
- class compuglobal.aio.FrinkiHams(timeout=15)
An API Wrapper for accessing FriniHams API endpoints (The Simpsons - Steamed Hams Skit).