ytstudio-cli 0.3.0__tar.gz → 0.3.1__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.
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/PKG-INFO +1 -1
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/index.md +1 -1
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/videos.md +1 -1
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/mkdocs.yml +10 -2
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/pyproject.toml +1 -1
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/api.py +4 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/videos.py +30 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/upload_pipeline.py +1 -1
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_api.py +7 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_upload_command.py +1 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_upload_pipeline.py +19 -3
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_videos.py +67 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/uv.lock +1 -1
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/.editorconfig +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/.github/workflows/ci.yml +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/.github/workflows/docs.yml +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/.gitignore +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/.pre-commit-config.yaml +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/.python-version +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/LICENSE +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/README.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/ascii.png +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/analytics.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/api-quota.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/comments.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/installation.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/livestreams.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/profiles.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/setup.md +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/docs/stylesheets/extra.css +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/scripts/build_docs_reference.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/__init__.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/__init__.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/analytics.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/comments.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/livestreams.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/profile.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/commands/upload.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/config.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/main.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/registry.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/services.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/ui.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/src/ytstudio/version.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/__init__.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/conftest.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_analytics.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_comments.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_config.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_livestreams.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_profile.py +0 -0
- {ytstudio_cli-0.3.0 → ytstudio_cli-0.3.1}/tests/test_registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ytstudio-cli
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Manage and analyze your YouTube channel from the terminal. Designed for humans and AI agents.
|
|
5
5
|
Project-URL: Homepage, https://github.com/jdwit/ytstudio-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/jdwit/ytstudio-cli
|
|
@@ -97,7 +97,7 @@ description: |
|
|
|
97
97
|
privacy: private # private | unlisted | public
|
|
98
98
|
publish_at: 2026-06-01T10:00:00+02:00 # optional; forces privacy=private
|
|
99
99
|
tags: [travel, vlog]
|
|
100
|
-
category_id: "22" # YouTube category id;
|
|
100
|
+
category_id: "22" # YouTube category id; required. Run `ytstudio videos categories` for the full list.
|
|
101
101
|
default_language: nl
|
|
102
102
|
default_audio_language: nl
|
|
103
103
|
made_for_kids: false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
site_name: ytstudio
|
|
1
|
+
site_name: ytstudio-cli
|
|
2
2
|
site_description: Manage and analyze your YouTube channel from the terminal. Designed for humans and AI agents.
|
|
3
3
|
site_url: https://jdwit.github.io/ytstudio-cli/
|
|
4
4
|
site_author: Jelmer de Wit
|
|
@@ -66,7 +66,15 @@ markdown_extensions:
|
|
|
66
66
|
pygments_lang_class: true
|
|
67
67
|
- pymdownx.inlinehilite
|
|
68
68
|
- pymdownx.snippets
|
|
69
|
-
- pymdownx.superfences
|
|
69
|
+
- pymdownx.superfences:
|
|
70
|
+
# Mermaid.js fence handler. Material for MkDocs bundles
|
|
71
|
+
# Mermaid automatically when a `mermaid` custom-fence is
|
|
72
|
+
# declared; no separate plugin install is needed. See
|
|
73
|
+
# https://squidfunk.github.io/mkdocs-material/reference/diagrams/
|
|
74
|
+
custom_fences:
|
|
75
|
+
- name: mermaid
|
|
76
|
+
class: mermaid
|
|
77
|
+
format: !!python/name:pymdownx.superfences.fence_code_format
|
|
70
78
|
- pymdownx.tabbed:
|
|
71
79
|
alternate_style: true
|
|
72
80
|
- pymdownx.tasklist:
|
|
@@ -63,6 +63,10 @@ SCOPES = [
|
|
|
63
63
|
"https://www.googleapis.com/auth/youtube.readonly",
|
|
64
64
|
"https://www.googleapis.com/auth/youtube.force-ssl",
|
|
65
65
|
"https://www.googleapis.com/auth/yt-analytics.readonly",
|
|
66
|
+
# Required to read revenue/earnings metrics (estimatedRevenue, cpm, ...).
|
|
67
|
+
# Without it the Analytics API returns 401 "Insufficient permission" for
|
|
68
|
+
# the monetary metrics that the registry already exposes.
|
|
69
|
+
"https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
|
|
66
70
|
]
|
|
67
71
|
|
|
68
72
|
HEADLESS_REDIRECT_URI = "http://127.0.0.1:9876/"
|
|
@@ -492,4 +492,34 @@ def search_replace(
|
|
|
492
492
|
console.print(f"\n[bold]Done:[/bold] {success} updated, {failed} failed")
|
|
493
493
|
|
|
494
494
|
|
|
495
|
+
@app.command()
|
|
496
|
+
def categories(
|
|
497
|
+
region: str = typer.Option("US", "--region", "-r", help="Region code (ISO 3166-1 alpha-2)"),
|
|
498
|
+
output: str = typer.Option("table", "--output", "-o", help="Output format: table, json"),
|
|
499
|
+
):
|
|
500
|
+
"""List YouTube video categories assignable to uploads"""
|
|
501
|
+
service = get_data_service()
|
|
502
|
+
response = api(service.videoCategories().list(part="snippet", regionCode=region.upper()))
|
|
503
|
+
|
|
504
|
+
items = [
|
|
505
|
+
{"id": item["id"], "title": item["snippet"]["title"]}
|
|
506
|
+
for item in response.get("items", [])
|
|
507
|
+
if item["snippet"].get("assignable", False)
|
|
508
|
+
]
|
|
509
|
+
items.sort(key=lambda c: int(c["id"]))
|
|
510
|
+
|
|
511
|
+
if output == "json":
|
|
512
|
+
print(json.dumps(items, indent=2))
|
|
513
|
+
return
|
|
514
|
+
|
|
515
|
+
table = create_table()
|
|
516
|
+
table.add_column("ID", style="yellow", justify="right")
|
|
517
|
+
table.add_column("Title", style="cyan")
|
|
518
|
+
|
|
519
|
+
for c in items:
|
|
520
|
+
table.add_row(c["id"], c["title"])
|
|
521
|
+
|
|
522
|
+
console.print(table)
|
|
523
|
+
|
|
524
|
+
|
|
495
525
|
app.command("upload")(_upload_cmd)
|
|
@@ -25,7 +25,7 @@ class UploadSpec(BaseModel):
|
|
|
25
25
|
privacy: Privacy = Privacy.private
|
|
26
26
|
publish_at: datetime | None = None
|
|
27
27
|
tags: list[str] = Field(default_factory=list)
|
|
28
|
-
category_id: str =
|
|
28
|
+
category_id: str = Field(min_length=1)
|
|
29
29
|
default_language: str | None = None
|
|
30
30
|
default_audio_language: str | None = None
|
|
31
31
|
made_for_kids: bool = False
|
|
@@ -20,6 +20,13 @@ def make_http_error(status: int, reason: str = ""):
|
|
|
20
20
|
return error
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
class TestScopes:
|
|
24
|
+
def test_includes_monetary_analytics_scope(self):
|
|
25
|
+
# Revenue/earnings metrics (estimatedRevenue, cpm, ...) require this
|
|
26
|
+
# scope; without it the Analytics API returns 401 for monetary reports.
|
|
27
|
+
assert "https://www.googleapis.com/auth/yt-analytics-monetary.readonly" in api_module.SCOPES
|
|
28
|
+
|
|
29
|
+
|
|
23
30
|
class TestHandleApiError:
|
|
24
31
|
def test_quota_exceeded_exits(self):
|
|
25
32
|
error = make_http_error(403, "quotaExceeded")
|
|
@@ -21,7 +21,7 @@ from ytstudio.upload_pipeline import (
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def test_minimal_valid_spec():
|
|
24
|
-
spec = UploadSpec(title="Hello", description="World")
|
|
24
|
+
spec = UploadSpec(title="Hello", description="World", category_id="22")
|
|
25
25
|
assert spec.title == "Hello"
|
|
26
26
|
assert spec.description == "World"
|
|
27
27
|
assert spec.privacy == "private"
|
|
@@ -32,10 +32,21 @@ def test_minimal_valid_spec():
|
|
|
32
32
|
assert spec.uploaded_at is None
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def test_category_id_required():
|
|
36
|
+
with pytest.raises(ValidationError, match="category_id"):
|
|
37
|
+
UploadSpec(title="x", description="x")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_category_id_empty_rejected():
|
|
41
|
+
with pytest.raises(ValidationError, match="category_id"):
|
|
42
|
+
UploadSpec(title="x", description="x", category_id="")
|
|
43
|
+
|
|
44
|
+
|
|
35
45
|
def test_publish_at_forces_privacy_to_private():
|
|
36
46
|
spec = UploadSpec(
|
|
37
47
|
title="x",
|
|
38
48
|
description="x",
|
|
49
|
+
category_id="22",
|
|
39
50
|
privacy="public",
|
|
40
51
|
publish_at="2099-01-01T10:00:00+02:00",
|
|
41
52
|
)
|
|
@@ -47,6 +58,7 @@ def test_publish_at_must_be_future():
|
|
|
47
58
|
UploadSpec(
|
|
48
59
|
title="x",
|
|
49
60
|
description="x",
|
|
61
|
+
category_id="22",
|
|
50
62
|
publish_at="2000-01-01T10:00:00+02:00",
|
|
51
63
|
)
|
|
52
64
|
|
|
@@ -56,6 +68,7 @@ def test_publish_at_requires_timezone():
|
|
|
56
68
|
UploadSpec(
|
|
57
69
|
title="x",
|
|
58
70
|
description="x",
|
|
71
|
+
category_id="22",
|
|
59
72
|
publish_at="2099-01-01T10:00:00", # naive
|
|
60
73
|
)
|
|
61
74
|
|
|
@@ -85,6 +98,7 @@ SIDECAR_OK = """\
|
|
|
85
98
|
title: Sample
|
|
86
99
|
description: |
|
|
87
100
|
Sample body
|
|
101
|
+
category_id: "22"
|
|
88
102
|
"""
|
|
89
103
|
|
|
90
104
|
|
|
@@ -165,7 +179,7 @@ def test_discover_already_uploaded_flagged(tmp_path):
|
|
|
165
179
|
_write(tmp_path / "done.mp4")
|
|
166
180
|
_write(
|
|
167
181
|
tmp_path / "done.yaml",
|
|
168
|
-
|
|
182
|
+
'title: Done\ndescription: ok\ncategory_id: "22"\nvideo_id: abc123\n',
|
|
169
183
|
)
|
|
170
184
|
|
|
171
185
|
jobs = discover(tmp_path)
|
|
@@ -225,7 +239,7 @@ def test_validate_jobs_collects_all_errors(tmp_path):
|
|
|
225
239
|
|
|
226
240
|
|
|
227
241
|
def test_body_minimal():
|
|
228
|
-
spec = UploadSpec(title="Hi", description="Body")
|
|
242
|
+
spec = UploadSpec(title="Hi", description="Body", category_id="22")
|
|
229
243
|
body = to_youtube_body(spec)
|
|
230
244
|
|
|
231
245
|
assert body["snippet"]["title"] == "Hi"
|
|
@@ -241,6 +255,7 @@ def test_body_with_publish_at_uses_iso():
|
|
|
241
255
|
spec = UploadSpec(
|
|
242
256
|
title="Scheduled",
|
|
243
257
|
description="x",
|
|
258
|
+
category_id="22",
|
|
244
259
|
publish_at="2099-06-01T19:00:00+02:00",
|
|
245
260
|
)
|
|
246
261
|
body = to_youtube_body(spec)
|
|
@@ -256,6 +271,7 @@ def test_body_includes_languages_and_tags():
|
|
|
256
271
|
spec = UploadSpec(
|
|
257
272
|
title="Localised",
|
|
258
273
|
description="x",
|
|
274
|
+
category_id="22",
|
|
259
275
|
tags=["a", "b"],
|
|
260
276
|
default_language="nl",
|
|
261
277
|
default_audio_language="nl",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from unittest.mock import MagicMock, patch
|
|
2
3
|
|
|
3
4
|
import typer
|
|
@@ -133,6 +134,72 @@ class TestVideosCommands:
|
|
|
133
134
|
assert "Public Already" not in result.stdout
|
|
134
135
|
|
|
135
136
|
|
|
137
|
+
class TestCategories:
|
|
138
|
+
def _setup(self, mock_auth, items):
|
|
139
|
+
categories_list = MagicMock()
|
|
140
|
+
categories_list.execute.return_value = {"items": items}
|
|
141
|
+
mock_auth.videoCategories.return_value.list.return_value = categories_list
|
|
142
|
+
return categories_list
|
|
143
|
+
|
|
144
|
+
def _cat(self, cat_id, title, assignable=True):
|
|
145
|
+
return {"id": cat_id, "snippet": {"title": title, "assignable": assignable}}
|
|
146
|
+
|
|
147
|
+
def test_lists_assignable_categories(self, mock_auth):
|
|
148
|
+
self._setup(
|
|
149
|
+
mock_auth,
|
|
150
|
+
[
|
|
151
|
+
self._cat("22", "People & Blogs"),
|
|
152
|
+
self._cat("10", "Music"),
|
|
153
|
+
self._cat("18", "Short Movies", assignable=False),
|
|
154
|
+
],
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
result = runner.invoke(app, ["videos", "categories"])
|
|
158
|
+
|
|
159
|
+
assert result.exit_code == 0
|
|
160
|
+
assert "People & Blogs" in result.stdout
|
|
161
|
+
assert "Music" in result.stdout
|
|
162
|
+
assert "Short Movies" not in result.stdout
|
|
163
|
+
|
|
164
|
+
def test_defaults_to_us_region(self, mock_auth):
|
|
165
|
+
self._setup(mock_auth, [self._cat("22", "People & Blogs")])
|
|
166
|
+
|
|
167
|
+
runner.invoke(app, ["videos", "categories"])
|
|
168
|
+
|
|
169
|
+
mock_auth.videoCategories.return_value.list.assert_called_with(
|
|
170
|
+
part="snippet", regionCode="US"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
def test_region_flag_uppercased(self, mock_auth):
|
|
174
|
+
self._setup(mock_auth, [self._cat("22", "People & Blogs")])
|
|
175
|
+
|
|
176
|
+
result = runner.invoke(app, ["videos", "categories", "--region", "nl"])
|
|
177
|
+
|
|
178
|
+
assert result.exit_code == 0
|
|
179
|
+
mock_auth.videoCategories.return_value.list.assert_called_with(
|
|
180
|
+
part="snippet", regionCode="NL"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
def test_json_output(self, mock_auth):
|
|
184
|
+
self._setup(
|
|
185
|
+
mock_auth,
|
|
186
|
+
[
|
|
187
|
+
self._cat("22", "People & Blogs"),
|
|
188
|
+
self._cat("10", "Music"),
|
|
189
|
+
],
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
result = runner.invoke(app, ["videos", "categories", "-o", "json"])
|
|
193
|
+
|
|
194
|
+
assert result.exit_code == 0
|
|
195
|
+
|
|
196
|
+
payload = json.loads(result.stdout)
|
|
197
|
+
assert payload == [
|
|
198
|
+
{"id": "10", "title": "Music"},
|
|
199
|
+
{"id": "22", "title": "People & Blogs"},
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
|
|
136
203
|
class TestSearchReplace:
|
|
137
204
|
def test_dry_run_shows_preview(self, mock_auth):
|
|
138
205
|
videos = [make_search_video("vid1", "OLDNAME Episode 1")]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|