autolecture 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ *.egg
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ .coverage
9
+ htmlcov/
10
+ dist/
11
+ build/
12
+ .venv/
13
+ venv/
14
+ .env
15
+ .env.*
16
+ *.log
17
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 scao7
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: autolecture
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for AutoLecture (https://autolecture.ai). Generate explainer videos from script or audio via a clean HTTP client.
5
+ Project-URL: Homepage, https://autolecture.ai
6
+ Project-URL: Repository, https://github.com/scao7/autolecture-python
7
+ Project-URL: Documentation, https://autolecture.ai/docs/dsl
8
+ Project-URL: Issues, https://github.com/scao7/autolecture-python/issues
9
+ Author-email: scao7 <codescao7@gmail.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: ai,autolecture,explainer,lecturetex,manim,remotion,tts,video,videotex
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Multimedia :: Video
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: httpx>=0.27
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.10; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: respx>=0.21; extra == 'dev'
30
+ Requires-Dist: ruff>=0.6; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # autolecture — Python SDK
34
+
35
+ Official Python SDK for [AutoLecture](https://autolecture.ai) — author
36
+ explainer videos as a `.tex` source, render them on the server,
37
+ download an mp4. The SDK wraps the v2 HTTP API end-to-end: projects,
38
+ assets, tex source, compile jobs (with polling), final-video download,
39
+ voice clone, billing-adjacent reads.
40
+
41
+ The SDK is the supported way to drive AutoLecture from outside the web
42
+ UI — built for CLIs, Claude Code skills, and any service-to-service
43
+ use case where a JWT login flow doesn't fit.
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install autolecture
49
+ ```
50
+
51
+ Python 3.10+. The SDK depends only on `httpx>=0.27`.
52
+
53
+ ## Auth
54
+
55
+ Every call needs an API key. To mint one:
56
+
57
+ 1. Sign in at <https://autolecture.ai>.
58
+ 2. Open <https://autolecture.ai/account>, find the **API Keys** section.
59
+ 3. Click **Generate** — copy the `al_live_…` string **immediately**, it's
60
+ only shown once.
61
+
62
+ Pass it to the `Client` constructor (or read from `AUTOLECTURE_API_KEY`
63
+ env var in your own code — the SDK doesn't read env vars itself, that's
64
+ caller-side).
65
+
66
+ ## Quickstart
67
+
68
+ ```python
69
+ from pathlib import Path
70
+ from autolecture import Client
71
+
72
+ with Client(api_key="al_live_…") as al:
73
+ # 1. Create a project.
74
+ project = al.create_project(name="My first AutoLecture video")
75
+ pid = project["id"]
76
+
77
+ # 2. Upload a script + any assets you want to reference.
78
+ al.upload_asset(pid, Path("./recording.mp3"))
79
+
80
+ # 3. Write the VideoTeX source. See https://autolecture.ai/docs/dsl.
81
+ al.put_tex(pid, "main.tex", r"""
82
+ \title{Demo}
83
+ \aspect{16:9}
84
+ \begin{videotex}
85
+ \begin{view}
86
+ \say{Hello, AutoLecture!}
87
+ \image[engine=gemini]{a duck explaining a concept on a chalkboard}
88
+ \end{view}
89
+ \end{videotex}
90
+ """.strip())
91
+
92
+ # 4. Compile. `compile()` blocks until the job terminates;
93
+ # `on_progress` fires after each poll for progress UI.
94
+ job = al.compile(
95
+ pid,
96
+ on_progress=lambda j: print(f" [{j['blocks_done']}/{j['blocks_total'] or '?'}] {j['status']}"),
97
+ )
98
+ print(f"Compile finished — {job['actual_cost_credits']} ✦ spent")
99
+
100
+ # 5. Download the final mp4.
101
+ al.download_preview(pid, dest="./out.mp4")
102
+ print("Saved to ./out.mp4")
103
+ ```
104
+
105
+ ## Errors
106
+
107
+ Every SDK exception inherits from `AutoLectureError`. The common
108
+ subclasses carry the backend's structured-error fields as attributes:
109
+
110
+ ```python
111
+ from autolecture import (
112
+ AutoLectureError, AuthenticationError, PermissionError,
113
+ QuotaExceededError, InsufficientCreditsError, RateLimitError,
114
+ CompileFailedError, NotFoundError, APIError,
115
+ )
116
+
117
+ try:
118
+ al.compile(pid)
119
+ except InsufficientCreditsError as e:
120
+ print(f"Need {e.shortfall} more ✦. Balance: {e.balance}, needed: {e.needed}")
121
+ except QuotaExceededError as e:
122
+ print(f"Plan {e.plan} caps at {e.limit} projects (you have {e.used}).")
123
+ except CompileFailedError as e:
124
+ print(f"Render failed:\n{e.error_log}")
125
+ except AutoLectureError as e:
126
+ # Catch-all — every SDK error inherits from this.
127
+ print(f"[{e.code}] {e.message}")
128
+ ```
129
+
130
+ For a less specific error (e.g. an HTTP status we don't have a subclass
131
+ for yet), you get a generic `APIError` with `.status_code` and `.code`.
132
+
133
+ ## What's in `Client`
134
+
135
+ | Area | Methods |
136
+ |---|---|
137
+ | Projects | `list_projects` / `create_project` / `create_project_from_zip` / `get_project` / `update_project` / `delete_project` / `archive_project` / `unarchive_project` / `duplicate_project` |
138
+ | Tex source | `get_tex` / `put_tex` |
139
+ | Assets | `upload_asset` / `list_assets` / `delete_asset` |
140
+ | Compile | `compile` (high-level + polling) / `start_compile` / `get_compile_job` / `cancel_compile` |
141
+ | Preview | `download_preview` / `download_block_preview` |
142
+ | Voice clone | `upload_voice_sample` / `get_voice_sample` / `delete_voice_sample` |
143
+ | Account | `get_balance` / `get_quota` / `get_usage` |
144
+ | API key | `mint_api_key` / `get_api_key_status` / `revoke_api_key` |
145
+
146
+ See the docstrings — every public method maps 1:1 to a documented
147
+ HTTP endpoint at <https://autolecture.ai/api/v2/...>.
148
+
149
+ ## Pointing at a different server
150
+
151
+ Most users won't need this. For local development or staging:
152
+
153
+ ```python
154
+ al = Client(api_key="al_live_…", base_url="https://dev.autolecture.ai")
155
+ # or
156
+ al = Client(api_key="al_live_…", base_url="http://localhost:8000")
157
+ ```
158
+
159
+ ## Async?
160
+
161
+ v0.1 is sync-only — `httpx.Client`, no `await`. An async variant
162
+ (`AsyncClient`) is on the roadmap for v0.2 if there's demand; the
163
+ typical "script in a Claude Code skill" use case is sync-friendly,
164
+ so async hasn't been a priority.
165
+
166
+ ## Development
167
+
168
+ ```bash
169
+ git clone https://github.com/scao7/autolecture-python
170
+ cd autolecture-python
171
+ pip install -e ".[dev]"
172
+ pytest -q
173
+ ruff check src tests
174
+ mypy src
175
+ ```
176
+
177
+ Tests use `respx` to mock the backend HTTP — nothing reaches the network.
178
+
179
+ ## License
180
+
181
+ MIT — see [LICENSE](LICENSE).
182
+
183
+ ## Links
184
+
185
+ - AutoLecture web app — <https://autolecture.ai>
186
+ - DSL reference — <https://autolecture.ai/docs/dsl>
187
+ - Companion Claude Code skill — <https://github.com/scao7/autolecture-claude-skill>
188
+ - Backend repo — <https://github.com/scao7/autolecture>
@@ -0,0 +1,156 @@
1
+ # autolecture — Python SDK
2
+
3
+ Official Python SDK for [AutoLecture](https://autolecture.ai) — author
4
+ explainer videos as a `.tex` source, render them on the server,
5
+ download an mp4. The SDK wraps the v2 HTTP API end-to-end: projects,
6
+ assets, tex source, compile jobs (with polling), final-video download,
7
+ voice clone, billing-adjacent reads.
8
+
9
+ The SDK is the supported way to drive AutoLecture from outside the web
10
+ UI — built for CLIs, Claude Code skills, and any service-to-service
11
+ use case where a JWT login flow doesn't fit.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install autolecture
17
+ ```
18
+
19
+ Python 3.10+. The SDK depends only on `httpx>=0.27`.
20
+
21
+ ## Auth
22
+
23
+ Every call needs an API key. To mint one:
24
+
25
+ 1. Sign in at <https://autolecture.ai>.
26
+ 2. Open <https://autolecture.ai/account>, find the **API Keys** section.
27
+ 3. Click **Generate** — copy the `al_live_…` string **immediately**, it's
28
+ only shown once.
29
+
30
+ Pass it to the `Client` constructor (or read from `AUTOLECTURE_API_KEY`
31
+ env var in your own code — the SDK doesn't read env vars itself, that's
32
+ caller-side).
33
+
34
+ ## Quickstart
35
+
36
+ ```python
37
+ from pathlib import Path
38
+ from autolecture import Client
39
+
40
+ with Client(api_key="al_live_…") as al:
41
+ # 1. Create a project.
42
+ project = al.create_project(name="My first AutoLecture video")
43
+ pid = project["id"]
44
+
45
+ # 2. Upload a script + any assets you want to reference.
46
+ al.upload_asset(pid, Path("./recording.mp3"))
47
+
48
+ # 3. Write the VideoTeX source. See https://autolecture.ai/docs/dsl.
49
+ al.put_tex(pid, "main.tex", r"""
50
+ \title{Demo}
51
+ \aspect{16:9}
52
+ \begin{videotex}
53
+ \begin{view}
54
+ \say{Hello, AutoLecture!}
55
+ \image[engine=gemini]{a duck explaining a concept on a chalkboard}
56
+ \end{view}
57
+ \end{videotex}
58
+ """.strip())
59
+
60
+ # 4. Compile. `compile()` blocks until the job terminates;
61
+ # `on_progress` fires after each poll for progress UI.
62
+ job = al.compile(
63
+ pid,
64
+ on_progress=lambda j: print(f" [{j['blocks_done']}/{j['blocks_total'] or '?'}] {j['status']}"),
65
+ )
66
+ print(f"Compile finished — {job['actual_cost_credits']} ✦ spent")
67
+
68
+ # 5. Download the final mp4.
69
+ al.download_preview(pid, dest="./out.mp4")
70
+ print("Saved to ./out.mp4")
71
+ ```
72
+
73
+ ## Errors
74
+
75
+ Every SDK exception inherits from `AutoLectureError`. The common
76
+ subclasses carry the backend's structured-error fields as attributes:
77
+
78
+ ```python
79
+ from autolecture import (
80
+ AutoLectureError, AuthenticationError, PermissionError,
81
+ QuotaExceededError, InsufficientCreditsError, RateLimitError,
82
+ CompileFailedError, NotFoundError, APIError,
83
+ )
84
+
85
+ try:
86
+ al.compile(pid)
87
+ except InsufficientCreditsError as e:
88
+ print(f"Need {e.shortfall} more ✦. Balance: {e.balance}, needed: {e.needed}")
89
+ except QuotaExceededError as e:
90
+ print(f"Plan {e.plan} caps at {e.limit} projects (you have {e.used}).")
91
+ except CompileFailedError as e:
92
+ print(f"Render failed:\n{e.error_log}")
93
+ except AutoLectureError as e:
94
+ # Catch-all — every SDK error inherits from this.
95
+ print(f"[{e.code}] {e.message}")
96
+ ```
97
+
98
+ For a less specific error (e.g. an HTTP status we don't have a subclass
99
+ for yet), you get a generic `APIError` with `.status_code` and `.code`.
100
+
101
+ ## What's in `Client`
102
+
103
+ | Area | Methods |
104
+ |---|---|
105
+ | Projects | `list_projects` / `create_project` / `create_project_from_zip` / `get_project` / `update_project` / `delete_project` / `archive_project` / `unarchive_project` / `duplicate_project` |
106
+ | Tex source | `get_tex` / `put_tex` |
107
+ | Assets | `upload_asset` / `list_assets` / `delete_asset` |
108
+ | Compile | `compile` (high-level + polling) / `start_compile` / `get_compile_job` / `cancel_compile` |
109
+ | Preview | `download_preview` / `download_block_preview` |
110
+ | Voice clone | `upload_voice_sample` / `get_voice_sample` / `delete_voice_sample` |
111
+ | Account | `get_balance` / `get_quota` / `get_usage` |
112
+ | API key | `mint_api_key` / `get_api_key_status` / `revoke_api_key` |
113
+
114
+ See the docstrings — every public method maps 1:1 to a documented
115
+ HTTP endpoint at <https://autolecture.ai/api/v2/...>.
116
+
117
+ ## Pointing at a different server
118
+
119
+ Most users won't need this. For local development or staging:
120
+
121
+ ```python
122
+ al = Client(api_key="al_live_…", base_url="https://dev.autolecture.ai")
123
+ # or
124
+ al = Client(api_key="al_live_…", base_url="http://localhost:8000")
125
+ ```
126
+
127
+ ## Async?
128
+
129
+ v0.1 is sync-only — `httpx.Client`, no `await`. An async variant
130
+ (`AsyncClient`) is on the roadmap for v0.2 if there's demand; the
131
+ typical "script in a Claude Code skill" use case is sync-friendly,
132
+ so async hasn't been a priority.
133
+
134
+ ## Development
135
+
136
+ ```bash
137
+ git clone https://github.com/scao7/autolecture-python
138
+ cd autolecture-python
139
+ pip install -e ".[dev]"
140
+ pytest -q
141
+ ruff check src tests
142
+ mypy src
143
+ ```
144
+
145
+ Tests use `respx` to mock the backend HTTP — nothing reaches the network.
146
+
147
+ ## License
148
+
149
+ MIT — see [LICENSE](LICENSE).
150
+
151
+ ## Links
152
+
153
+ - AutoLecture web app — <https://autolecture.ai>
154
+ - DSL reference — <https://autolecture.ai/docs/dsl>
155
+ - Companion Claude Code skill — <https://github.com/scao7/autolecture-claude-skill>
156
+ - Backend repo — <https://github.com/scao7/autolecture>
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "autolecture"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for AutoLecture (https://autolecture.ai). Generate explainer videos from script or audio via a clean HTTP client."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "scao7", email = "codescao7@gmail.com" }]
13
+ keywords = ["autolecture", "video", "explainer", "manim", "remotion", "ai", "tts", "lecturetex", "videotex"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Multimedia :: Video",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Typing :: Typed",
25
+ ]
26
+ dependencies = [
27
+ "httpx>=0.27",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ dev = [
32
+ "pytest>=8",
33
+ "pytest-cov>=5",
34
+ "respx>=0.21",
35
+ "mypy>=1.10",
36
+ "ruff>=0.6",
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://autolecture.ai"
41
+ Repository = "https://github.com/scao7/autolecture-python"
42
+ Documentation = "https://autolecture.ai/docs/dsl"
43
+ Issues = "https://github.com/scao7/autolecture-python/issues"
44
+
45
+ [tool.hatch.build.targets.wheel]
46
+ packages = ["src/autolecture"]
47
+
48
+ [tool.pytest.ini_options]
49
+ testpaths = ["tests"]
50
+ addopts = "-ra -q --strict-markers"
51
+ asyncio_mode = "auto"
52
+
53
+ [tool.ruff]
54
+ line-length = 100
55
+ target-version = "py310"
56
+
57
+ [tool.ruff.lint]
58
+ select = ["E", "F", "I", "B", "UP", "SIM", "RUF"]
59
+ ignore = ["E501"] # line-length handled by formatter
60
+
61
+ [tool.mypy]
62
+ python_version = "3.10"
63
+ strict = true
64
+ warn_unused_ignores = true
65
+ files = ["src/autolecture"]
@@ -0,0 +1,88 @@
1
+ r"""autolecture — Official Python SDK for AutoLecture (https://autolecture.ai).
2
+
3
+ Quickstart:
4
+
5
+ from autolecture import Client
6
+
7
+ al = Client(api_key="al_live_…") # mint at https://autolecture.ai/account
8
+ project = al.create_project(name="My first video")
9
+ al.upload_asset(project["id"], "./recording.mp3")
10
+ al.put_tex(project["id"], "main.tex", r'''
11
+ \title{Demo}
12
+ \begin{videotex}
13
+ \begin{view}\say{Hello, AutoLecture!}\end{view}
14
+ \end{videotex}
15
+ ''')
16
+ job = al.compile(project["id"], on_progress=lambda j: print(j["progress_pct"], "%"))
17
+ al.download_preview(project["id"], dest="./out.mp4")
18
+
19
+ Errors raised by the SDK all inherit from `AutoLectureError`. The
20
+ common subclasses (`InsufficientCreditsError`, `QuotaExceededError`,
21
+ `RateLimitError`, `CompileFailedError`, …) carry the server's
22
+ structured-error fields as attributes — no need to re-parse JSON.
23
+ """
24
+ from autolecture.client import Client
25
+ from autolecture.exceptions import (
26
+ APIError,
27
+ AuthenticationError,
28
+ AutoLectureError,
29
+ CompileCancelledError,
30
+ CompileFailedError,
31
+ InsufficientCreditsError,
32
+ NotFoundError,
33
+ PermissionError,
34
+ QuotaExceededError,
35
+ RateLimitError,
36
+ ServerError,
37
+ )
38
+ from autolecture.types import (
39
+ ApiKeyMintResult,
40
+ ApiKeyStatus,
41
+ Asset,
42
+ Balance,
43
+ CompileBlockInfo,
44
+ CompileJob,
45
+ CompileStatus,
46
+ CreditTopup,
47
+ Project,
48
+ ProjectFull,
49
+ ProjectQuota,
50
+ Quota,
51
+ Usage,
52
+ VoiceSampleStatus,
53
+ )
54
+
55
+ __version__ = "0.1.0"
56
+
57
+ __all__ = [
58
+ # client
59
+ "Client",
60
+ # exceptions
61
+ "APIError",
62
+ "AuthenticationError",
63
+ "AutoLectureError",
64
+ "CompileCancelledError",
65
+ "CompileFailedError",
66
+ "InsufficientCreditsError",
67
+ "NotFoundError",
68
+ "PermissionError",
69
+ "QuotaExceededError",
70
+ "RateLimitError",
71
+ "ServerError",
72
+ # types
73
+ "ApiKeyMintResult",
74
+ "ApiKeyStatus",
75
+ "Asset",
76
+ "Balance",
77
+ "CompileBlockInfo",
78
+ "CompileJob",
79
+ "CompileStatus",
80
+ "CreditTopup",
81
+ "Project",
82
+ "ProjectFull",
83
+ "ProjectQuota",
84
+ "Quota",
85
+ "Usage",
86
+ "VoiceSampleStatus",
87
+ "__version__",
88
+ ]