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=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
|
Source code in gopro_api/cli/app.py
71 72 73 74 75 76 77 | |
Application
gopro_api.cli.app
Typer application instance, root callback, and CLI entrypoint.
main(argv=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
|
Source code in gopro_api/cli/app.py
71 72 73 74 75 76 77 | |
Commands
gopro_api.cli.search_command(ctx, *, start=typer.Option(..., '--start', help='Range start: YYYY-MM-DD or ISO datetime'), end=typer.Option(..., '--end', help='Range end: YYYY-MM-DD or ISO datetime (API treats range as in query string)'), page=typer.Option(1, '--page', help='Page number (default: 1)'), per_page=typer.Option(30, '--per-page', help='Page size (default: 30)'), all_pages=typer.Option(False, '--all-pages', help='Keep requesting pages until a page returns no media'), tsv=typer.Option(False, '--tsv', help='Print tab-separated values (header row + metadata line) for scripting'), json_out=typer.Option(False, '--json', help='Print full API JSON (with --all-pages: list of page payloads)'))
Run search against the cloud API and print results.
Source code in gopro_api/cli/search.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
gopro_api.cli.info_command(ctx, media_id=typer.Argument(..., help='Media id from search'), tsv=typer.Option(False, '--tsv', help='Print tab-separated values for scripting'), json_out=typer.Option(False, '--json', help='Print full API JSON'))
Fetch and display download metadata for media_id.
Source code in gopro_api/cli/info.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
gopro_api.cli.pull_command(ctx, media_id=typer.Argument(..., help='Media id from search'), destination=typer.Argument(..., help='Path to save the file'), height=typer.Option(None, '--height', metavar='PX', help='For video: pick the variation whose height is closest to PX (default: tallest)'), width=typer.Option(None, '--width', metavar='PX', help='For video: pick the variation whose width is closest to PX (default: tallest)'), tsv=typer.Option(False, '--tsv', help='Print tab-separated summary instead of the Rich table'))
Download all resolved files for media_id into destination.
Source code in gopro_api/cli/pull.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Printers
gopro_api.cli.search.SearchPrinter
Handles all search output formatting: Rich table, TSV, and JSON key renaming.
Source code in gopro_api/cli/search.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
__init__(console=None)
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
45 46 47 48 49 50 51 52 | |
page_meta_line(page)
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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
emit_embedded_errors(page)
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
70 71 72 73 74 75 76 77 78 79 80 81 82 | |
cells_plain(item)
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
84 85 86 87 88 89 90 91 92 93 94 95 | |
cells_rich(item)
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
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
make_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
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
print_table(table)
Print a Rich table to the console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Fully populated Rich table to render. |
required |
Source code in gopro_api/cli/search.py
145 146 147 148 149 150 151 | |
print_tsv_page(page, *, header=True)
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
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
print_rich_page(page)
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
170 171 172 173 174 175 176 177 178 179 180 181 | |
append_rich_rows(table, page)
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
183 184 185 186 187 188 189 190 191 192 193 194 195 | |
rename_payload(payload)
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
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
gopro_api.cli.info.InfoPrinter
Handles Rich table and TSV rendering for the info command.
Source code in gopro_api/cli/info.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
__init__(console=None)
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
31 32 33 34 35 36 37 38 | |
variation_cells(idx, v)
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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
file_cells(idx, f)
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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
sidecar_cells(idx, s)
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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
print_rich(meta)
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
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
print_tsv(meta)
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
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
gopro_api.cli.pull.PullPrinter
Handles Rich table and TSV rendering for the pull command.
Source code in gopro_api/cli/pull.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
__init__(console=None)
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
25 26 27 28 29 30 31 32 | |
summary_cells(filename, asset)
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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
print_rich(assets, destination)
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
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
print_tsv(assets, destination)
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
67 68 69 70 71 72 73 74 75 76 77 | |