Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compuglobal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__title__ = "compuglobal"
__author__ = "MitchellAW"
__license__ = "MIT"
__version__ = "0.4.2"
__version__ = "0.5.0"

__all__ = [
"APIPageStatusError",
Expand Down
40 changes: 20 additions & 20 deletions compuglobal/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class AsyncCompuGlobalAPI:
----------
session : aiohttp.ClientSession
The client session to use for all API calls
default_format : OverlayFormat | None, optional
default_format : OverlayFormat | None
The default overlay format to use for all overlays/subtitles
max_retries : int, optional
max_retries : int
The maximum number of retries for all API requests

Attributes
Expand Down Expand Up @@ -96,9 +96,9 @@ async def get_screencap(

Parameters
----------
episode : str | None, optional
episode : str | None
An episode key
timestamp : int | None, optional
timestamp : int | None
A timestamp of the screencap

Returns
Expand All @@ -125,9 +125,9 @@ async def search(
----------
search_text : str
The search text to query
season_minimum : int | None, optional
season_minimum : int | None
The minimum season allowed in the search results
season_maximum : int | None, optional
season_maximum : int | None
The maximum season allowed in the search results

Returns
Expand Down Expand Up @@ -172,9 +172,9 @@ async def search_for_screencap(
----------
search_text : str
The search text to query
season_minimum : int | None, optional
season_minimum : int | None
The minimum season allowed in the search
season_maximum : int | None, optional
season_maximum : int | None
The maximum season allowed in the search

Returns
Expand All @@ -196,9 +196,9 @@ async def get_random_screencap(

Parameters
----------
season_minimum : int | None, optional
season_minimum : int | None
Minimum season number allowed in random result
season_maximum : int | None, optional
season_maximum : int | None
Maximum season number allowed in random result

Returns
Expand Down Expand Up @@ -336,9 +336,9 @@ async def get_comic_panel_url(
----------
screencap : Screencap
The screencap to use in the comic panel
subtitles : list[Subtitle] | None, optional
subtitles : list[Subtitle] | None
A list of subtitles to overlay in the comic panel
overlay_format : OverlayFormat | None, optional
overlay_format : OverlayFormat | None
The formatting to use in the comic panel overlay (subtitle)

Returns
Expand Down Expand Up @@ -366,9 +366,9 @@ async def get_comic_strip_url(
----------
screencap : Screencap
The screencap to use in the comic strip
subtitles : list[Subtitle] | None, optional
subtitles : list[Subtitle] | None
The subtitles to overlay in the comic strip
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The formatting to use in the comic strip overlays (subtitleS). See :meth:`OverlayFormat.normalise` for
full details on how formats are resolved.

Expand Down Expand Up @@ -396,9 +396,9 @@ async def get_comic_maker_url(
----------
screencap : Screencap
The screencap to make the comic with
subtitles : list[Subtitle] | None, optional
subtitles : list[Subtitle] | None
The subtitles to override in the comic maker, by default None
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The subtitle/overlay formatting to override in the comic maker, by default None

Returns
Expand Down Expand Up @@ -430,9 +430,9 @@ async def get_gif_url(
----------
screencap : Screencap
The screencap to use for the gif
subtitles : list[Subtitle] | None, optional
subtitles : list[Subtitle] | None
The subtitles to overlay in the gif
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The formatting to use in the gif overlays (subtitles). See :meth:`OverlayFormat.normalise` for
full details on how formats are resolved.

Expand Down Expand Up @@ -470,9 +470,9 @@ async def get_gif_maker_url(
----------
screencap : Screencap
The screencap to make the comic with
subtitles : list[Subtitle] | None, optional
subtitles : list[Subtitle] | None
The subtitles to override in the comic maker, by default None
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The subtitle/overlay formatting to override in the comic maker, by default None

Returns
Expand Down
4 changes: 2 additions & 2 deletions compuglobal/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CompuGlobalAPIClient:
The base URL of the API (e.g. https://frinkiac.com)
session : ClientSession
The client session to use for all API requests
max_retries : int, optional
max_retries : int
The maximum number of retries for each request before raising an :class:`APIPageStatusError`

"""
Expand All @@ -39,7 +39,7 @@ async def get(self, url: str, params: dict[str, Any] | None = None) -> dict[str,
----------
url : str
The url to use in the request
params : dict[str, Any] | None, optional
params : dict[str, Any] | None
The query params to use in the request

Returns
Expand Down
24 changes: 12 additions & 12 deletions compuglobal/api/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class PreparedRequest:
----------
url: str
The url of the request
method: RequestMethod, optional
method: RequestMethod
The HTTP RequestMethod for the request (GET/POST/PUT)
params: dict[str, Any] | None, optional
params: dict[str, Any] | None
The query parameters to use in the request
body: dict[str, Any] | list[Any] | None, optional
body: dict[str, Any] | list[Any] | None
The JSON request body to post

"""
Expand All @@ -61,13 +61,13 @@ class Endpoint:
----------
path : str
The url path containing any path parameter names
method : RequestMethod, optional
method : RequestMethod
The HTTP RequestMethod for the request (GET/POST/PUT)
required_query_params : frozenset[str], optional
required_query_params : frozenset[str]
The required query parameters to use in the request
optional_query_params : frozenset[str], optional
optional_query_params : frozenset[str]
Optional query params that can be used in the request
body_model : type[BaseModel] | None, optional
body_model : type[BaseModel] | None
The pydantic model for the json body

"""
Expand Down Expand Up @@ -120,9 +120,9 @@ def build_encoded_url(
----------
base_url : str
The base url of the API
query : dict[str, Any] | None, optional
query : dict[str, Any] | None
The query params to use in the url
path_params : dict[str, Any] | None, optional
path_params : dict[str, Any] | None
The path params to use in the url

Returns
Expand Down Expand Up @@ -154,11 +154,11 @@ def build_request(
----------
base_url : str
The base url of the API
query : dict[str, Any] | None, optional
query : dict[str, Any] | None
The query params to use in the params of the request
path_params : dict[str, Any] | None, optional
path_params : dict[str, Any] | None
The path params to use in the path of the request
body : BaseModel | None, optional
body : BaseModel | None
The json body model to use in the request

Returns
Expand Down
10 changes: 5 additions & 5 deletions compuglobal/models/comic.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def from_subtitles(
----------
subtitles : list[Subtitle]
A list of subtitles
overlay_format : OverlayFormat | None, optional
overlay_format : OverlayFormat | None
The format to use in the overlay

Returns
Expand Down Expand Up @@ -171,7 +171,7 @@ def from_screencap(
----------
screencap : Screencap
Screencap to use for the comic panel
overlay_format : OverlayFormat | None, optional
overlay_format : OverlayFormat | None
The format to use in the comic panel overlay.

Returns
Expand Down Expand Up @@ -208,7 +208,7 @@ class ComicStrip(BaseCompuGlobalModel, frozen=False):
----------
panels : list[ComicPanel]
The list of ComicPanels to use in the comic strip
layout : ComicLayout | None, optional
layout : ComicLayout | None
The layout to use when displaying the panels

"""
Expand All @@ -233,7 +233,7 @@ def from_screencap(
----------
screencap : Screencap
The screencap to use for the comic strip
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The format(s) to use in the overlays. See :meth:`OverlayFormat.normalise` for
full details on how formats are resolved.

Expand Down Expand Up @@ -266,7 +266,7 @@ def build_comic_overlays(
----------
subtitles : list[Subtitle]
The subtitles to use for the overlays
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The format(s) to use in the overlays. See :meth:`OverlayFormat.normalise` for
full details on how formats are resolved.

Expand Down
6 changes: 6 additions & 0 deletions compuglobal/models/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class EpisodeMetadata(BaseCompuGlobalModel):
The original air date of the episode (yyyy-mm-dd)
wiki_link : str
The wikipedia link for the episode
video_width : int
The width of the video in pixels
video_height : int
The height of the video in pixels

"""

Expand All @@ -42,6 +46,8 @@ class EpisodeMetadata(BaseCompuGlobalModel):
writer: str = Field(alias="Writer")
original_air_date: str = Field(alias="OriginalAirDate")
wiki_link: str = Field(alias="WikiLink")
video_width: int = Field(alias="VideoWidth", ge=0, default=480)
video_height: int = Field(alias="VideoHeight", ge=0, default=360)


class EpisodeSummary(BaseCompuGlobalModel):
Expand Down
2 changes: 1 addition & 1 deletion compuglobal/models/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class FontColor(BaseCompuGlobalModel):
The amount of green in the color (0-255)
blue : int
The amount of blue in the color (0-255)
alpha : int, optional
alpha : int
The amount of alpha transparency in the color (0-255)

"""
Expand Down
6 changes: 6 additions & 0 deletions compuglobal/models/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ class Frame(BaseCompuGlobalModel):
The episode key (S01E01)
timestamp : int
The timestamp of the frame
video_width : int
The width of the video in pixels
video_height : int
The height of the video in pixels

"""

id: int = Field(alias="Id")
key: str = Field(alias="Episode")
timestamp: int = Field(alias="Timestamp", ge=0)
video_width: int = Field(alias="VideoWidth", ge=0, default=480)
video_height: int = Field(alias="VideoHeight", ge=0, default=360)

@property
def timecode(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions compuglobal/models/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OverlayFormat(BaseCompuGlobalModel):
text_alignment: FontAlignment = Field(default=FontAlignment.ALIGN_CENTER)
all_caps: bool = Field(default=True)

def __str__(self) -> str: # noqa: D105
def __str__(self) -> str: # ruff: ignore[undocumented-magic-method]
return str(self.model_dump(exclude_defaults=True))

@property
Expand Down Expand Up @@ -72,7 +72,7 @@ def normalise(

Parameters
----------
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The format(s) to use in the overlays:

- If ``None``, default formatting is applied to all overlays
Expand Down
6 changes: 6 additions & 0 deletions compuglobal/models/screencap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ class ScreencapMoment(BaseCompuGlobalModel):
The content of the subtitle
title : str
The title of the episode in the snapshot
video_width : int
The width of the video in pixels
video_height : int
The height of the video in pixels

"""

episode: str = Field(alias="Episode")
timestamp: int = Field(alias="Timestamp", ge=0)
content: str = Field(alias="Content")
title: str = Field(alias="Title")
video_width: int = Field(alias="VideoWidth", ge=0, default=480)
video_height: int = Field(alias="VideoHeight", ge=0, default=360)

@property
def key(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions compuglobal/models/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def from_screencap(
----------
screencap : Screencap
The screencap to use for the Stream
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The format(s) to use in the overlays. See :meth:`OverlayFormat.normalise` for
full details on how formats are resolved.

Expand Down Expand Up @@ -183,7 +183,7 @@ def build_stream_overlays(
----------
screencap : Screencap
The screencap to use for the overlays
overlay_format : OverlayFormat | list[OverlayFormat] | None, optional
overlay_format : OverlayFormat | list[OverlayFormat] | None
The format(s) to use in the overlays. See :meth:`OverlayFormat.normalise` for
full details on how formats are resolved.

Expand Down
9 changes: 7 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
Changelog
=========

Upcoming Changes
----------------

0.5.0
-----

Breaking Changes
~~~~~~~~~~~~~~~~
- Add the new video height and width attributes to :class:`Episode`, :class:`Frame`, and :class:`ScreencapMoment`

Miscellaneous
~~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ line-length = 120
[tool.ruff.lint]
preview = true
select = ["ALL"]
ignore = ["CPY001", "D107", "D203", "D213"]
ignore = ["missing-copyright-notice", "undocumented-public-init", "incorrect-blank-line-before-class", "multi-line-summary-second-line"]

[tool.ruff.lint.per-file-ignores]
"examples/*" = ["INP001", "T201", "ANN201", "D103"]
"docs/*" = ["A001", "INP001", "D100"]
"tests/*" = ["S101", "D103", "PLR2004", "S311"]
"examples/*" = ["implicit-namespace-package", "print", "missing-return-type-undocumented-public-function", "undocumented-public-function"]
"docs/*" = ["builtin-variable-shadowing", "implicit-namespace-package", "undocumented-public-module"]
"tests/*" = ["assert", "undocumented-public-function", "magic-value-comparison", "suspicious-non-cryptographic-random-usage"]

[tool.pyrefly]
project-includes = [
Expand Down
Loading