awstream 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.
- awstream-0.1.0/MANIFEST.in +2 -0
- awstream-0.1.0/PKG-INFO +30 -0
- awstream-0.1.0/README.md +17 -0
- awstream-0.1.0/awstream/__init__.py +20 -0
- awstream-0.1.0/awstream/cli.py +170 -0
- awstream-0.1.0/awstream/hud.py +489 -0
- awstream-0.1.0/awstream/obs.py +394 -0
- awstream-0.1.0/awstream/producer.py +232 -0
- awstream-0.1.0/awstream/state.py +276 -0
- awstream-0.1.0/awstream/youtube.py +84 -0
- awstream-0.1.0/awstream.egg-info/PKG-INFO +30 -0
- awstream-0.1.0/awstream.egg-info/SOURCES.txt +17 -0
- awstream-0.1.0/awstream.egg-info/dependency_links.txt +1 -0
- awstream-0.1.0/awstream.egg-info/entry_points.txt +2 -0
- awstream-0.1.0/awstream.egg-info/requires.txt +6 -0
- awstream-0.1.0/awstream.egg-info/top_level.txt +1 -0
- awstream-0.1.0/pyproject.toml +23 -0
- awstream-0.1.0/setup.cfg +4 -0
- awstream-0.1.0/tests/test_awstream.py +143 -0
awstream-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awstream
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dual-stream producer for YouTube Live + Discord: OBS WebSocket v5 control, live transparent HUD overlay, Privacy Shield, focus sprints, clips, and stream recaps.
|
|
5
|
+
Author-email: Aither World <dev@aitherium.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Provides-Extra: discord
|
|
10
|
+
Requires-Dist: awdiscord>=0.6.0; extra == "discord"
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
13
|
+
|
|
14
|
+
# awstream — Dual-Stream Producer for YouTube Live + Discord
|
|
15
|
+
|
|
16
|
+
Stdlib-only Aither World brick (`awstream`) that lets Aither and `awdk` agents set up, produce, and co-host live working/coding streams simultaneously on **YouTube Live (via OBS Studio)** and **Discord Voice**.
|
|
17
|
+
|
|
18
|
+
## What it does
|
|
19
|
+
- **OBS WebSocket v5 client** (`awstream.obs`) — zero external dependencies; auto-discovers OBS config on Windows, switches scenes, starts/stops YouTube RTMP streams, configures YouTube stream key safely, and triggers instant **Privacy Shield / BRB**.
|
|
20
|
+
- **Transparent 1920x1080 Browser Source HUD** (`awstream.hud`) — serves `http://127.0.0.1:47960/overlay` (matching `Aither_Live.json`'s `Aither Overlay` source) showing live status, current focus task, Pomodoro sprint timer, Aither DJ Now Playing + progress bar, highlight clip toasts, and full-screen Privacy Shield.
|
|
21
|
+
- **Producer state & recap** (`awstream.state`) — tracks focus changes, `"clip that!"` highlight timestamps, sprints, and renders a clean post-stream recap for Discord.
|
|
22
|
+
- **YouTube Live helper** (`awstream.youtube`) — validates YouTube Live URLs, polls optional YouTube Live Chat when an API key is configured, and guides RTMP setup.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
```bash
|
|
26
|
+
awstream doctor
|
|
27
|
+
awstream setup
|
|
28
|
+
awstream hud --port 47960
|
|
29
|
+
awstream start "Building AitherOS live" --topic "Voice DJ + awstream" --youtube "https://youtube.com/live/..."
|
|
30
|
+
```
|
awstream-0.1.0/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# awstream — Dual-Stream Producer for YouTube Live + Discord
|
|
2
|
+
|
|
3
|
+
Stdlib-only Aither World brick (`awstream`) that lets Aither and `awdk` agents set up, produce, and co-host live working/coding streams simultaneously on **YouTube Live (via OBS Studio)** and **Discord Voice**.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
- **OBS WebSocket v5 client** (`awstream.obs`) — zero external dependencies; auto-discovers OBS config on Windows, switches scenes, starts/stops YouTube RTMP streams, configures YouTube stream key safely, and triggers instant **Privacy Shield / BRB**.
|
|
7
|
+
- **Transparent 1920x1080 Browser Source HUD** (`awstream.hud`) — serves `http://127.0.0.1:47960/overlay` (matching `Aither_Live.json`'s `Aither Overlay` source) showing live status, current focus task, Pomodoro sprint timer, Aither DJ Now Playing + progress bar, highlight clip toasts, and full-screen Privacy Shield.
|
|
8
|
+
- **Producer state & recap** (`awstream.state`) — tracks focus changes, `"clip that!"` highlight timestamps, sprints, and renders a clean post-stream recap for Discord.
|
|
9
|
+
- **YouTube Live helper** (`awstream.youtube`) — validates YouTube Live URLs, polls optional YouTube Live Chat when an API key is configured, and guides RTMP setup.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
```bash
|
|
13
|
+
awstream doctor
|
|
14
|
+
awstream setup
|
|
15
|
+
awstream hud --port 47960
|
|
16
|
+
awstream start "Building AitherOS live" --topic "Voice DJ + awstream" --youtube "https://youtube.com/live/..."
|
|
17
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""awstream: dual-stream producer for YouTube Live (OBS) + Discord."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from awstream.obs import OBSClient, OBSError, discover_obs_config
|
|
5
|
+
from awstream.state import ClipMark, StreamSession, StreamStore
|
|
6
|
+
from awstream.youtube import extract_video_id, normalize_youtube_url
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"ClipMark",
|
|
12
|
+
"OBSClient",
|
|
13
|
+
"OBSError",
|
|
14
|
+
"StreamSession",
|
|
15
|
+
"StreamStore",
|
|
16
|
+
"__version__",
|
|
17
|
+
"discover_obs_config",
|
|
18
|
+
"extract_video_id",
|
|
19
|
+
"normalize_youtube_url",
|
|
20
|
+
]
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""CLI entrypoint for ``awstream`` (setup, doctor, hud, dual-stream controls)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
import tempfile
|
|
8
|
+
import threading
|
|
9
|
+
import urllib.request
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from awstream.hud import DEFAULT_HUD_PORT, create_hud_server
|
|
13
|
+
from awstream.obs import OBSError
|
|
14
|
+
from awstream.producer import StreamProducer
|
|
15
|
+
from awstream.state import StreamStore
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _self_test() -> int:
|
|
19
|
+
with tempfile.TemporaryDirectory(prefix="awstream-selftest-") as td:
|
|
20
|
+
prod = StreamProducer(store=StreamStore(Path(td) / "state.json"))
|
|
21
|
+
prod.set_focus("Self-test stream")
|
|
22
|
+
prod.clip("test highlight", by="selftest")
|
|
23
|
+
srv = create_hud_server(host="127.0.0.1", port=0, producer=prod, poll_dj=False)
|
|
24
|
+
port = srv.server_address[1]
|
|
25
|
+
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
|
26
|
+
try:
|
|
27
|
+
with urllib.request.urlopen(f"http://127.0.0.1:{port}/health", timeout=3) as r:
|
|
28
|
+
assert json.loads(r.read().decode())["ok"] is True
|
|
29
|
+
with urllib.request.urlopen(f"http://127.0.0.1:{port}/overlay", timeout=3) as r:
|
|
30
|
+
html = r.read().decode()
|
|
31
|
+
assert "<!doctype html>" in html.lower() or "<html" in html.lower()
|
|
32
|
+
finally:
|
|
33
|
+
srv.shutdown()
|
|
34
|
+
srv.server_close()
|
|
35
|
+
print(json.dumps({"self_test": "PASS", "hud": "ok", "state": "ok"}, indent=2))
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main(argv=None) -> int:
|
|
40
|
+
ap = argparse.ArgumentParser(
|
|
41
|
+
prog="awstream",
|
|
42
|
+
description="Dual-stream producer for YouTube Live (OBS) + Discord",
|
|
43
|
+
)
|
|
44
|
+
ap.add_argument("--self-test", action="store_true", help="Run offline HUD + state self-test")
|
|
45
|
+
sub = ap.add_subparsers(dest="cmd", required=False)
|
|
46
|
+
|
|
47
|
+
sub.add_parser("doctor", help="Check OBS WebSocket, YouTube RTMPS, and Stream HUD readiness")
|
|
48
|
+
|
|
49
|
+
p_setup = sub.add_parser("setup", help="Configure OBS work scenes, HUD browser source, and YouTube RTMPS")
|
|
50
|
+
p_setup.add_argument("--hud-port", type=int, default=DEFAULT_HUD_PORT)
|
|
51
|
+
p_setup.add_argument("--youtube-key", default="", help="YouTube Live stream key (never printed)")
|
|
52
|
+
|
|
53
|
+
p_hud = sub.add_parser("hud", help="Run the 1920x1080 transparent Stream HUD + Producer Control server")
|
|
54
|
+
p_hud.add_argument("--host", default="0.0.0.0")
|
|
55
|
+
p_hud.add_argument("--port", type=int, default=DEFAULT_HUD_PORT)
|
|
56
|
+
p_hud.add_argument("--no-dj-poll", action="store_true")
|
|
57
|
+
|
|
58
|
+
p_start = sub.add_parser("start", help="Start a dual-stream session")
|
|
59
|
+
p_start.add_argument("title", nargs="?", default="Working Live with Aither")
|
|
60
|
+
p_start.add_argument("--topic", default="")
|
|
61
|
+
p_start.add_argument("--youtube", default="")
|
|
62
|
+
p_start.add_argument("--obs", action="store_true", help="Also trigger OBS StartStream")
|
|
63
|
+
p_start.add_argument("--record", action="store_true", help="Also start local OBS recording")
|
|
64
|
+
|
|
65
|
+
p_stop = sub.add_parser("stop", help="Stop the stream and print the recap")
|
|
66
|
+
p_stop.add_argument("--keep-obs", action="store_true")
|
|
67
|
+
|
|
68
|
+
p_focus = sub.add_parser("focus", help="Update the 'Working On' task on the stream HUD")
|
|
69
|
+
p_focus.add_argument("topic")
|
|
70
|
+
|
|
71
|
+
p_sprint = sub.add_parser("sprint", help="Start a Pomodoro/focus sprint countdown on the HUD")
|
|
72
|
+
p_sprint.add_argument("minutes", type=float, nargs="?", default=25.0)
|
|
73
|
+
p_sprint.add_argument("--label", default="Focus Sprint")
|
|
74
|
+
|
|
75
|
+
p_clip = sub.add_parser("clip", help="Mark a highlight timestamp")
|
|
76
|
+
p_clip.add_argument("label", nargs="?", default="Highlight")
|
|
77
|
+
p_clip.add_argument("--by", default="Host")
|
|
78
|
+
|
|
79
|
+
p_priv = sub.add_parser("privacy", help="Toggle Privacy Shield / BRB screen")
|
|
80
|
+
p_priv.add_argument("state", choices=["on", "off"])
|
|
81
|
+
p_priv.add_argument("--message", default="")
|
|
82
|
+
|
|
83
|
+
p_scene = sub.add_parser("scene", help="Switch OBS program scene")
|
|
84
|
+
p_scene.add_argument("name")
|
|
85
|
+
|
|
86
|
+
sub.add_parser("status", help="Show current stream session JSON")
|
|
87
|
+
|
|
88
|
+
args = ap.parse_args(argv)
|
|
89
|
+
if args.self_test:
|
|
90
|
+
return _self_test()
|
|
91
|
+
if not args.cmd:
|
|
92
|
+
ap.print_help()
|
|
93
|
+
return 0
|
|
94
|
+
prod = StreamProducer()
|
|
95
|
+
|
|
96
|
+
if args.cmd == "doctor":
|
|
97
|
+
doc = prod.doctor()
|
|
98
|
+
for c in doc["checks"]:
|
|
99
|
+
mark = "OK " if c["ok"] else "WARN"
|
|
100
|
+
print(f"[{mark}] {c['name']}: {c['detail']}")
|
|
101
|
+
return 0 if doc["ready"] else 1
|
|
102
|
+
|
|
103
|
+
if args.cmd == "setup":
|
|
104
|
+
try:
|
|
105
|
+
res = prod.setup(hud_port=args.hud_port, youtube_key=args.youtube_key)
|
|
106
|
+
except OBSError as exc:
|
|
107
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
108
|
+
return 1
|
|
109
|
+
print(json.dumps(res, indent=2))
|
|
110
|
+
return 0
|
|
111
|
+
|
|
112
|
+
if args.cmd == "hud":
|
|
113
|
+
srv = create_hud_server(
|
|
114
|
+
host=args.host, port=args.port, producer=prod, poll_dj=not args.no_dj_poll,
|
|
115
|
+
)
|
|
116
|
+
print(
|
|
117
|
+
f"Aither Stream HUD live:\n"
|
|
118
|
+
f" OBS Overlay: http://127.0.0.1:{args.port}/overlay\n"
|
|
119
|
+
f" Control UI : http://127.0.0.1:{args.port}/control",
|
|
120
|
+
flush=True,
|
|
121
|
+
)
|
|
122
|
+
try:
|
|
123
|
+
srv.serve_forever()
|
|
124
|
+
except KeyboardInterrupt:
|
|
125
|
+
pass
|
|
126
|
+
return 0
|
|
127
|
+
|
|
128
|
+
if args.cmd == "start":
|
|
129
|
+
res = prod.start(
|
|
130
|
+
args.title, topic=args.topic, youtube_url=args.youtube,
|
|
131
|
+
start_obs=args.obs, record_local=args.record,
|
|
132
|
+
)
|
|
133
|
+
print(json.dumps(res, indent=2))
|
|
134
|
+
return 0
|
|
135
|
+
|
|
136
|
+
if args.cmd == "stop":
|
|
137
|
+
res = prod.stop(stop_obs=not args.keep_obs)
|
|
138
|
+
print(res["recap"])
|
|
139
|
+
return 0
|
|
140
|
+
|
|
141
|
+
if args.cmd == "focus":
|
|
142
|
+
print(json.dumps(prod.set_focus(args.topic).to_dict(), indent=2))
|
|
143
|
+
return 0
|
|
144
|
+
|
|
145
|
+
if args.cmd == "sprint":
|
|
146
|
+
print(json.dumps(prod.start_sprint(args.minutes, label=args.label).to_dict(), indent=2))
|
|
147
|
+
return 0
|
|
148
|
+
|
|
149
|
+
if args.cmd == "clip":
|
|
150
|
+
print(json.dumps(prod.clip(args.label, by=args.by), indent=2))
|
|
151
|
+
return 0
|
|
152
|
+
|
|
153
|
+
if args.cmd == "privacy":
|
|
154
|
+
print(json.dumps(prod.set_privacy(args.state == "on", message=args.message), indent=2))
|
|
155
|
+
return 0
|
|
156
|
+
|
|
157
|
+
if args.cmd == "scene":
|
|
158
|
+
res = prod.set_scene(args.name)
|
|
159
|
+
print(json.dumps(res, indent=2))
|
|
160
|
+
return 0 if res["ok"] else 1
|
|
161
|
+
|
|
162
|
+
if args.cmd == "status":
|
|
163
|
+
print(json.dumps(prod.status(), indent=2))
|
|
164
|
+
return 0
|
|
165
|
+
|
|
166
|
+
return 0
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
if __name__ == "__main__":
|
|
170
|
+
raise SystemExit(main())
|