yb.youtube.publish¶
High-level YouTube publishing: prepare → upload → captions → thumbnail.
Two entry points:
publish_content()— given a preparedyb.content.PublicationContent, upload it with captions,thumbnail, and chapters (in the description).
prepare_and_publish()— the one-call path: transcribe/derive metadata/detect chapters (viayb.content.prepare_content()) and upload, all from a media path.
Functions
|
One call: prepare publication content from |
|
Upload a prepared |
|
Lower-level upload: explicit |
Exceptions
|
The video was uploaded, then a later step failed (yb#21). |
- exception yb.youtube.publish.PartialPublish(result, *, step, error)[source]¶
Bases:
RuntimeErrorThe video was uploaded, then a later step failed (yb#21).
The upload is the expensive step (1,600 quota units); captions, thumbnail and playlist can each fail afterwards on quota, auth or a transient error. Raising the bare error lost the new video’s id, and a re-run uploaded a second copy. This carries what was done instead:
result: the dict the publish call would have returned, as far as it got (video_id,url,captionsattached so far,thumbnail,playlist). Persist it.step: the step that failed, e.g."caption ja".__cause__: the original error.
Finish later without re-uploading: pass
resume=err.resultto the same call (publish_video()orpublish_content(); forprepare_and_publish(), callpublish_content()with the content it prepared, rather than preparing it again). Steps already done are skipped. A resume trusts the saved result: it does not upload, so new metadata, video path or privacy in the resuming call are ignored, and the remaining steps target the savedvideo_id.resultis plain JSON-able data, and the exception pickles (so a worker process can hand it back);__cause__does not survive pickling.
- yb.youtube.publish.prepare_and_publish(media, *, language='English', language_code=None, audio_language_code=None, brand=None, extra_context=None, with_chapters=True, with_thumbnail=True, privacy_status=None, playlist=<object object>, category_id='28', config=None, client_secrets_file=None, token_file=None, progress=True, **cred_kwargs)[source]¶
One call: prepare publication content from
mediaand upload it.Transcribes (persisting the SRT next to the media) if needed, writes LLM metadata, detects chapters, renders a thumbnail, then uploads with captions + thumbnail + chapters and adds the video to the configured playlist.
privacy_statusandplaylistdefault to yourybconfig (seepublish_content()).cred_kwargsreachget_credentials()(e.g.open_browser=False, port=8080for headless consent).- Return type:
- yb.youtube.publish.publish_content(content, *, privacy_status=None, playlist=<object object>, category_id='28', with_chapters=True, attach_caption=True, set_thumb=True, config=None, client_secrets_file=None, token_file=None, progress=True, service=None, resume=None, **cred_kwargs)[source]¶
Upload a prepared
PublicationContentto YouTube.Maps the content to a YouTube snippet (chapters embedded in the description when present), uploads, attaches the SRT caption track (language =
content.audio_languageorcontent.language) and the thumbnail when available, and adds the video to the configured playlist.privacy_statusandplaylistdefault to yourybconfig (seeyb.config): unset means “use the config value”, so privacy falls back tounlistedand the video joins your configured playlist. Passplaylist=Noneto skip the playlist for one call, orplaylist="Name"to override the target.cred_kwargsreachget_credentials()(e.g.open_browser=False, port=8080for headless consent).- Return type:
- Returns:
{"video_id", "url", "studio_url", "privacy_status", "captions", "thumbnail", "playlist"}.privacy_statusreflects what YouTube actually set (an unaudited project may force"private");playlistis theadd_video_to_playlist()result orNone.- Raises:
PartialPublish – the upload succeeded and a later step failed;
err.resultholds the video id and what was done. Passresume=err.resultto finish without uploading again (yb#21).
- yb.youtube.publish.publish_video(video_path, metadata, *, privacy_status=None, playlist=<object object>, captions=None, thumbnail=None, config=None, client_secrets_file=None, token_file=None, progress=True, service=None, resume=None, **cred_kwargs)[source]¶
Lower-level upload: explicit
VideoMetadata+ caption tracks.privacy_statusandplaylistdefault to yourybconfig (seepublish_content()).If a step after the upload fails,
PartialPublishis raised with the new video’s id and what was done so far (err.result). Passresume=err.resultto finish without uploading again (yb#21).cred_kwargsreachget_credentials()(e.g.open_browser=False, port=8080for headless consent).- Return type: