ytstudio-cli 0.4.1__tar.gz → 0.4.2__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.
Files changed (64) hide show
  1. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/PKG-INFO +1 -1
  2. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/pyproject.toml +1 -1
  3. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/config.py +31 -4
  4. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_config.py +43 -1
  5. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/uv.lock +1 -1
  6. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.editorconfig +0 -0
  7. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.github/workflows/ci.yml +0 -0
  8. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.github/workflows/docs.yml +0 -0
  9. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.github/workflows/release.yml +0 -0
  10. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.github/workflows/test.yml +0 -0
  11. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.gitignore +0 -0
  12. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.pre-commit-config.yaml +0 -0
  13. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/.python-version +0 -0
  14. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/LICENSE +0 -0
  15. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/README.md +0 -0
  16. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/ascii.png +0 -0
  17. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/analytics.md +0 -0
  18. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/api-quota.md +0 -0
  19. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/comments.md +0 -0
  20. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/index.md +0 -0
  21. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/installation.md +0 -0
  22. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/livestreams.md +0 -0
  23. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/playlists.md +0 -0
  24. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/profiles.md +0 -0
  25. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/setup.md +0 -0
  26. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/stylesheets/extra.css +0 -0
  27. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/docs/videos.md +0 -0
  28. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/mkdocs.yml +0 -0
  29. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/scripts/build_docs_reference.py +0 -0
  30. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/scripts/build_skill_reference.py +0 -0
  31. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/skills/ytstudio/SKILL.md +0 -0
  32. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/skills/ytstudio/assets/upload-sidecar.example.yaml +0 -0
  33. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/skills/ytstudio/references/reference.md +0 -0
  34. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/__init__.py +0 -0
  35. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/api.py +0 -0
  36. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/__init__.py +0 -0
  37. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/analytics.py +0 -0
  38. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/comments.py +0 -0
  39. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/livestreams.py +0 -0
  40. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/playlists.py +0 -0
  41. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/profile.py +0 -0
  42. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/upload.py +0 -0
  43. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/commands/videos.py +0 -0
  44. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/main.py +0 -0
  45. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/registry.py +0 -0
  46. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/services.py +0 -0
  47. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/ui.py +0 -0
  48. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/upload_pipeline.py +0 -0
  49. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/src/ytstudio/version.py +0 -0
  50. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/__init__.py +0 -0
  51. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/conftest.py +0 -0
  52. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_analytics.py +0 -0
  53. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_api.py +0 -0
  54. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_comments.py +0 -0
  55. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_livestreams.py +0 -0
  56. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_main.py +0 -0
  57. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_playlists.py +0 -0
  58. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_profile.py +0 -0
  59. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_registry.py +0 -0
  60. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_skill_reference.py +0 -0
  61. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_upload_command.py +0 -0
  62. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_upload_pipeline.py +0 -0
  63. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_version.py +0 -0
  64. {ytstudio_cli-0.4.1 → ytstudio_cli-0.4.2}/tests/test_videos.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ytstudio-cli
3
- Version: 0.4.1
3
+ Version: 0.4.2
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ytstudio-cli"
3
- version = "0.4.1"
3
+ version = "0.4.2"
4
4
  description = "Manage and analyze your YouTube channel from the terminal. Designed for humans and AI agents."
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -1,4 +1,3 @@
1
- import fcntl
2
1
  import json
3
2
  import os
4
3
  import re
@@ -6,6 +5,15 @@ import shutil
6
5
  from contextlib import contextmanager
7
6
  from pathlib import Path
8
7
 
8
+ try:
9
+ import fcntl # POSIX advisory locking
10
+ except ImportError: # Windows
11
+ fcntl = None
12
+ try:
13
+ import msvcrt # Windows advisory locking
14
+ except ImportError: # POSIX
15
+ msvcrt = None
16
+
9
17
  from rich.prompt import Prompt
10
18
 
11
19
  from ytstudio.ui import console, success_message
@@ -30,7 +38,9 @@ def is_valid_profile_name(name: str) -> bool:
30
38
 
31
39
  def _ensure_private_dir(path: Path) -> None:
32
40
  path.mkdir(parents=True, exist_ok=True)
33
- path.chmod(0o700)
41
+ if os.name == "posix":
42
+ # On Windows chmod only toggles the read-only bit; owner-only is a POSIX guarantee.
43
+ path.chmod(0o700)
34
44
 
35
45
 
36
46
  def ensure_config_dir() -> None:
@@ -68,17 +78,34 @@ def _atomic_write_text(path: Path, text: str, mode: int = 0o644) -> None:
68
78
  tmp.replace(path)
69
79
 
70
80
 
81
+ def _lock_file(fh) -> None:
82
+ if fcntl is not None:
83
+ fcntl.flock(fh.fileno(), fcntl.LOCK_EX)
84
+ elif msvcrt is not None:
85
+ fh.seek(0)
86
+ msvcrt.locking(fh.fileno(), msvcrt.LK_LOCK, 1)
87
+ # else: no advisory locking primitive available; a single-user CLI degrades safely.
88
+
89
+
90
+ def _unlock_file(fh) -> None:
91
+ if fcntl is not None:
92
+ fcntl.flock(fh.fileno(), fcntl.LOCK_UN)
93
+ elif msvcrt is not None:
94
+ fh.seek(0)
95
+ msvcrt.locking(fh.fileno(), msvcrt.LK_UNLCK, 1)
96
+
97
+
71
98
  @contextmanager
72
99
  def _config_lock():
73
100
  """Serialize state mutations and the legacy migration across CLI invocations."""
74
101
  ensure_config_dir()
75
102
  lock_path = CONFIG_DIR / ".lock"
76
103
  with lock_path.open("w") as fh:
104
+ _lock_file(fh)
77
105
  try:
78
- fcntl.flock(fh.fileno(), fcntl.LOCK_EX)
79
106
  yield
80
107
  finally:
81
- fcntl.flock(fh.fileno(), fcntl.LOCK_UN)
108
+ _unlock_file(fh)
82
109
 
83
110
 
84
111
  # --- client secrets (shared OAuth app, identical for every profile) ---
@@ -1,6 +1,6 @@
1
1
  import json
2
2
  import stat
3
- from unittest.mock import patch
3
+ from unittest.mock import MagicMock, patch
4
4
 
5
5
  import pytest
6
6
 
@@ -175,6 +175,48 @@ class TestMigration:
175
175
  assert config.LEGACY_CREDENTIALS_FILE.exists()
176
176
 
177
177
 
178
+ class TestCrossPlatformLock:
179
+ def test_config_lock_roundtrip(self, temp_config):
180
+ """The lock acquires and releases without error on the host platform."""
181
+ with config._config_lock():
182
+ pass
183
+ assert (temp_config / ".lock").exists()
184
+
185
+ def test_lock_uses_msvcrt_when_fcntl_absent(self, temp_config):
186
+ """On Windows (no fcntl) the lock falls through to msvcrt.locking."""
187
+ fake_msvcrt = MagicMock()
188
+ fake_msvcrt.LK_LOCK = 1
189
+ fake_msvcrt.LK_UNLCK = 0
190
+ with (
191
+ patch.object(config, "fcntl", None),
192
+ patch.object(config, "msvcrt", fake_msvcrt),
193
+ config._config_lock(),
194
+ ):
195
+ pass
196
+ # msvcrt.locking(fd, mode, nbytes); fd is runtime-dependent so assert on mode/nbytes.
197
+ modes = [(call.args[1], call.args[2]) for call in fake_msvcrt.locking.call_args_list]
198
+ assert (fake_msvcrt.LK_LOCK, 1) in modes
199
+ assert (fake_msvcrt.LK_UNLCK, 1) in modes
200
+
201
+ def test_lock_degrades_without_any_primitive(self, temp_config):
202
+ """With neither fcntl nor msvcrt the lock is a no-op, not a crash."""
203
+ with (
204
+ patch.object(config, "fcntl", None),
205
+ patch.object(config, "msvcrt", None),
206
+ config._config_lock(),
207
+ ):
208
+ pass
209
+
210
+ def test_set_active_profile_under_simulated_windows(self, temp_config):
211
+ """A real state mutation works on the msvcrt code path."""
212
+ fake_msvcrt = MagicMock()
213
+ fake_msvcrt.LK_LOCK = 1
214
+ fake_msvcrt.LK_UNLCK = 0
215
+ with patch.object(config, "fcntl", None), patch.object(config, "msvcrt", fake_msvcrt):
216
+ config.set_active_profile("work")
217
+ assert config.get_active_profile() == "work"
218
+
219
+
178
220
  class TestAtomicState:
179
221
  def test_state_file_write_is_atomic(self, temp_config):
180
222
  """A truncated/partial state.json must not slip past _save_state."""
@@ -1230,7 +1230,7 @@ wheels = [
1230
1230
 
1231
1231
  [[package]]
1232
1232
  name = "ytstudio-cli"
1233
- version = "0.4.1"
1233
+ version = "0.4.2"
1234
1234
  source = { editable = "." }
1235
1235
  dependencies = [
1236
1236
  { name = "google-api-python-client" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes