CLI¶
Command-line interface for gopro-api. Run gopro-api --help to see all subcommands.
Built with Typer; the Typer application is exposed as gopro_api.cli.app for embedding or testing.
Entry point¶
gopro_api.cli.main(argv: Optional[list[str]] = None) -> None
¶
CLI entrypoint: parse argv and run the selected command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argv
|
Optional[list[str]]
|
Argument list (defaults to process arguments when |
None
|
Application¶
gopro_api.cli.app
¶
Typer application instance, root callback, and CLI entrypoint.
main(argv: Optional[list[str]] = None) -> None
¶
CLI entrypoint: parse argv and run the selected command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argv
|
Optional[list[str]]
|
Argument list (defaults to process arguments when |
None
|
Commands¶
gopro_api.cli.search_command(ctx: typer.Context, *, start: str = typer.Option(..., '--start', help='Range start: YYYY-MM-DD or ISO datetime'), end: str = typer.Option(..., '--end', help='Range end: YYYY-MM-DD or ISO datetime (API treats range as in query string)'), page: int = typer.Option(1, '--page', help='Page number (default: 1)'), per_page: int = typer.Option(30, '--per-page', help='Page size (default: 30)'), all_pages: bool = typer.Option(False, '--all-pages', help='Keep requesting pages until a page returns no media'), tsv: bool = typer.Option(False, '--tsv', help='Print tab-separated values (header row + metadata line) for scripting'), json_out: bool = typer.Option(False, '--json', help='Print full API JSON (with --all-pages: list of page payloads)')) -> None
¶
Run search against the cloud API and print results.
Source code in gopro_api/cli/search.py
gopro_api.cli.info_command(ctx: typer.Context, media_id: str = typer.Argument(..., help='Media id from search'), tsv: bool = typer.Option(False, '--tsv', help='Print tab-separated values for scripting'), json_out: bool = typer.Option(False, '--json', help='Print full API JSON')) -> None
¶
Fetch and display download metadata for media_id.
Source code in gopro_api/cli/info.py
gopro_api.cli.pull_command(ctx: typer.Context, media_id: str = typer.Argument(..., help='Media id from search'), destination: str = typer.Argument(..., help='Path to save the file'), height: Optional[int] = typer.Option(None, '--height', metavar='PX', help='For video: pick the variation whose height is closest to PX (default: tallest)'), width: Optional[int] = typer.Option(None, '--width', metavar='PX', help='For video: pick the variation whose width is closest to PX (default: tallest)'), tsv: bool = typer.Option(False, '--tsv', help='Print tab-separated summary instead of the Rich table')) -> None
¶
Download all resolved files for media_id into destination.
Source code in gopro_api/cli/pull.py
gopro_api.cli.auth_command(ctx: typer.Context, tsv: bool = typer.Option(False, '--tsv', help='Print tab-separated values for scripting'), json_out: bool = typer.Option(False, '--json', help='Print structured JSON')) -> None
¶
Check whether the GoPro access token is configured and accepted by the API.
Source code in gopro_api/cli/auth.py
Printers¶
gopro_api.cli.search.SearchPrinter(console: Console | None = None)
¶
Handles all search output formatting: Rich table, TSV, and JSON key renaming.
Initialize with an optional Rich console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
console
|
Console | None
|
Console used for Rich output; a default soft-wrap console is
created when |
None
|
Source code in gopro_api/cli/search.py
page_meta_line(page: GoProMediaSearchResponse) -> str
¶
Format the pagination metadata comment line for a search page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
GoProMediaSearchResponse
|
Search response containing pagination details. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A |
str
|
and total pages. |
Source code in gopro_api/cli/search.py
emit_embedded_errors(page: GoProMediaSearchResponse) -> None
¶
Print any embedded API errors to stderr as yellow comment lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
GoProMediaSearchResponse
|
Search response whose |
required |
Source code in gopro_api/cli/search.py
cells_plain(item: GoProMediaSearchItem) -> list[str]
¶
Build raw string cells for TSV output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
GoProMediaSearchItem
|
A single media item from the search response. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Ordered list of strings for each field in |
list[str]
|
missing values are represented as empty strings. |
Source code in gopro_api/cli/search.py
cells_rich(item: GoProMediaSearchItem) -> list[str]
¶
Build human-formatted cells for Rich table output.
File sizes are formatted with decimal SI units; all other values are stringified as-is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
GoProMediaSearchItem
|
A single media item from the search response. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Ordered list of display strings for each field in |
Source code in gopro_api/cli/search.py
make_table() -> Table
¶
Build an empty Rich Table with the default search columns.
Returns:
| Type | Description |
|---|---|
Table
|
A |
Table
|
ready to receive rows via |
Source code in gopro_api/cli/search.py
print_table(table: Table) -> None
¶
Print a Rich table to the console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Fully populated Rich table to render. |
required |
print_tsv_page(page: GoProMediaSearchResponse, *, header: bool = True) -> None
¶
Print a TSV-formatted search page to stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
GoProMediaSearchResponse
|
Search response page to render. |
required |
header
|
bool
|
When |
True
|
Source code in gopro_api/cli/search.py
print_rich_page(page: GoProMediaSearchResponse) -> None
¶
Print a single Rich-formatted search page with metadata and a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
GoProMediaSearchResponse
|
Search response page to render. |
required |
Source code in gopro_api/cli/search.py
append_rich_rows(table: Table, page: GoProMediaSearchResponse) -> None
¶
Append a page's media rows to an existing Rich table.
Used in --all-pages mode to accumulate rows across pages before a
single final render.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Rich table to append rows to. |
required |
page
|
GoProMediaSearchResponse
|
Search response page whose media items are appended. |
required |
Source code in gopro_api/cli/search.py
rename_payload(payload: dict) -> dict
¶
Apply display-name aliases to a raw API JSON payload.
Renames keys inside _embedded.media items according to
_FIELD_LABELS so that JSON output uses the same names as the table
headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict
|
Raw API payload dict (typically from |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The same |
Source code in gopro_api/cli/search.py
gopro_api.cli.info.InfoPrinter(console: Console | None = None)
¶
Handles Rich table and TSV rendering for the info command.
Initialize with an optional Rich console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
console
|
Console | None
|
Console used for Rich output; a default soft-wrap console is
created when |
None
|
Source code in gopro_api/cli/info.py
variation_cells(idx: int, v: GoProMediaDownloadVariation) -> list[str]
¶
Build row cells for a video variation entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Zero-based row index shown in the |
required |
v
|
GoProMediaDownloadVariation
|
Variation object from the download metadata. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Ordered list of strings matching |
Source code in gopro_api/cli/info.py
file_cells(idx: int, f: GoProMediaDownloadFile) -> list[str]
¶
Build row cells for a multi-lens file entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Zero-based row index shown in the |
required |
f
|
GoProMediaDownloadFile
|
File object from the download metadata. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Ordered list of strings matching |
Source code in gopro_api/cli/info.py
sidecar_cells(idx: int, s: GoProMediaDownloadSidecarFile) -> list[str]
¶
Build row cells for a sidecar file entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Zero-based row index shown in the |
required |
s
|
GoProMediaDownloadSidecarFile
|
Sidecar file object from the download metadata. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Ordered list of strings matching |
Source code in gopro_api/cli/info.py
print_rich(meta: GoProMediaDownloadResponse) -> None
¶
Print a Rich table of variations or files, plus sidecars when present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
GoProMediaDownloadResponse
|
Download metadata response from the GoPro API. |
required |
Source code in gopro_api/cli/info.py
print_tsv(meta: GoProMediaDownloadResponse) -> None
¶
Print tab-separated rows of variations or files, plus sidecars when present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
GoProMediaDownloadResponse
|
Download metadata response from the GoPro API. |
required |
Source code in gopro_api/cli/info.py
gopro_api.cli.pull.PullPrinter(console: Console | None = None)
¶
Handles Rich table and TSV rendering for the pull command.
Initialize with an optional Rich console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
console
|
Console | None
|
Console used for Rich output; a default soft-wrap console is
created when |
None
|
Source code in gopro_api/cli/pull.py
summary_cells(filename: str, asset: DownloadAsset) -> list[str]
¶
Build row cells for a single download asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Local filename that the asset will be saved as. |
required |
asset
|
DownloadAsset
|
Resolved download asset containing URL and dimensions. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Ordered list of strings matching |
Source code in gopro_api/cli/pull.py
print_rich(assets: dict[str, DownloadAsset], destination: str) -> None
¶
Print a Rich summary table of all assets to be downloaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assets
|
dict[str, DownloadAsset]
|
Mapping of local filename to resolved download asset. |
required |
destination
|
str
|
Target directory path shown in the header line. |
required |
Source code in gopro_api/cli/pull.py
print_tsv(assets: dict[str, DownloadAsset], destination: str) -> None
¶
Print a tab-separated summary of all assets for scripting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assets
|
dict[str, DownloadAsset]
|
Mapping of local filename to resolved download asset. |
required |
destination
|
str
|
Target directory path shown in the comment header. |
required |
Source code in gopro_api/cli/pull.py
gopro_api.cli.auth.AuthPrinter(console: Console | None = None)
¶
Handles Rich, TSV, and JSON rendering for the auth command.
Initialize with an optional Rich console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
console
|
Console | None
|
Console used for Rich output; a default soft-wrap console is
created when |
None
|
Source code in gopro_api/cli/auth.py
verifying_status() -> Iterator[None]
¶
Show a spinner while the API verification request runs.
print_rich(status: GoProAuthStatus) -> None
¶
Print authentication status as a Rich panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
GoProAuthStatus
|
Authentication status from the API client. |
required |
Source code in gopro_api/cli/auth.py
print_tsv(status: GoProAuthStatus) -> None
¶
Print authentication status as tab-separated key/value rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
GoProAuthStatus
|
Authentication status from the API client. |
required |
Source code in gopro_api/cli/auth.py
print_json(status: GoProAuthStatus) -> None
¶
Print authentication status as JSON on stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
GoProAuthStatus
|
Authentication status from the API client. |
required |
Source code in gopro_api/cli/auth.py
exit_code(status: GoProAuthStatus) -> int
¶
Map authentication status to a process exit code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
GoProAuthStatus
|
Authentication status from the API client. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|