Commitbbc0ca08Recorded25 Mar 2026Repositorysigil-youtube
Fix youtube-video-update missing required fields and remove unused sigil-log dep
Message
youtube-video-update now validates that title: and categoryId: are both present when updating snippet fields, as the YouTube API requires them. Previously the function would silently send an incomplete snippet, causing a 400 error from the API.
Also removes sigil-log from package.sgl dependencies since no module imports it.
Changed
README.md | 1 -
package.sgl | 3 +--
src/sigil/youtube.sgl | 18 ++++++++++++++++++
3 files changed, 19 insertions(+), 3 deletions(-)Diff
README.mdmodified
@@ -32,7 +32,6 @@ analytics, livestreaming, and playlist APIs.
32
- `sigil-json` — JSON encode/decode 33
- `sigil-http` — HTTP client 34
- `sigil-tls` — HTTPS support−35
- `sigil-log` — logging 35
36
All dependencies are from the [sigil](https://codeberg.org/sigil/sigil) mono-repo. 37
package.sglmodified
@@ -29,8 +29,7 @@
29
(from-git url: sigil-repo package: "sigil-stdlib") 30
(from-git url: sigil-repo package: "sigil-tls") 31
(from-git url: sigil-repo package: "sigil-http")−32
(from-git url: sigil-repo package: "sigil-json")−33
(from-git url: sigil-repo package: "sigil-log"))+32
(from-git url: sigil-repo package: "sigil-json")) 33
34
tasks: (list 35
(tasksrc/sigil/youtube.sglmodified
@@ -318,6 +318,13 @@
318
;;; Update video metadata. Takes a video ID and a dict of fields to update. 319
;;; Only fields present in updates are sent; omitted fields are not touched. 320
;;; Supported fields: title:, description:, tags:, categoryId:, privacyStatus:.+321
;;;+322
;;; IMPORTANT: YouTube requires both title: and categoryId: when updating+323
;;; any snippet field. If you update description: or tags:, you must also+324
;;; include title: and categoryId: in the updates dict. This function+325
;;; raises an error if snippet fields are being updated without both+326
;;; title: and categoryId: present.+327
;;; 328
;;; Quota cost: 50 units. 329
(define (youtube-video-update client video-id updates) 330
(let* ((snippet-keys '((title: . title:)@@ -337,6 +344,17 @@
344
(if (null? status-fields) '() '("status"))))) 345
(if (null? parts) 346
(error "youtube-video-update: no fields to update"))+347
;; YouTube requires both title and categoryId when snippet is in part+348
(if (not (null? snippet-fields))+349
(begin+350
(if (not (dict-ref updates title: #f))+351
(error (string-append+352
"youtube-video-update: title: is required when updating "+353
"snippet fields (YouTube API requirement)")))+354
(if (not (dict-ref updates categoryId: #f))+355
(error (string-append+356
"youtube-video-update: categoryId: is required when updating "+357
"snippet fields (YouTube API requirement)"))))) 358
(let* ((fields->dict 359
(lambda (fields) 360
(apply dict (apply append