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.CompuGlobalAPI(url, title)

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.

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.

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 episode e={} and timestamp t={} or a frame

Parameters
  • episode (str, optional) – The episode key of the screencap.

  • timestamp (int, optional) – 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.

Note

Used for getting the episode info and caption shown below each screencap.

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.

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 query q={} 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.

search_for_screencap(search_text)

Performs a GET request to the api/search?q= endpoint using search() 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.

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.

get_nearby_frames(episode, timestamp)

Performs a GET request to the api/nearby?e={}&t={} endpoint and gets a list of seven nearby using the episode key e={} and timestamp t={} the episode.

Parameters
  • episode (str) – The episode key of the screencap.

  • timestamp (int) – The timestamp of the screencap.

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 seven frames in the “More from this scene:” frame selection screen with arrows.

view_episode(episode, start, end)

Performs a GET request to the api/episode/{episode}/{start}/{end} endpoint and returns the json response containing episode information.

Parameters
  • episode (str) – The episode key of the screencap.

  • start (int) – The starting timestamp for the episode information.

  • end (int) – The ending timestamp for the episode information.

Returns

The json response containing the episode information and subtitles for the timestamps.

Return type

dict

Note

Used for displaying the rest of an episode when using the “View Episode” button next to each screencap.

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.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.NoSearchResultsFound

Raised when no search results are returned during a search query to the search endpoint of the API.

Supported APIs

Frinkiac

class compuglobal.Frinkiac

An API Wrapper for accessing Frinkiac API endpoints (The Simpsons).

Morbotron

class compuglobal.Morbotron

An API Wrapper for accessing Morbotron API endpoints (Futurama).

Master Of All Science

class compuglobal.MasterOfAllScience

An API Wrapper for accessing MasterOfAllScience API endpoints (Rick and Morty).

Good God Lemon

class compuglobal.GoodGodLemon

An API Wrapper for accessing GoodGodLemon API endpoints (30 Rock).

Capital Beat Us

class compuglobal.CapitalBeatUs

An API Wrapper for accessing CapitalBeatUs API endpoints (West Wing).

FrinkiHams

class compuglobal.FrinkiHams

An API Wrapper for accessing FriniHams API endpoints (The Simpsons - Steamed Hams Skit).