@crievo/omni 0.0.0-stage → 0.1.0
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.
- package/.env.example +41 -0
- package/README.md +2 -2
- package/bin/omni.mjs +14 -0
- package/docs/onboarding/clone-voice.png +0 -0
- package/docs/onboarding/getting-started.png +0 -0
- package/docs/onboarding/new-video.png +0 -0
- package/docs/onboarding/providers.png +0 -0
- package/docs/onboarding/publish.png +0 -0
- package/docs/onboarding/references.png +0 -0
- package/docs/onboarding.md +212 -0
- package/omnivideo.config.example.json +437 -0
- package/package.json +40 -4
- package/reference/captions.md +156 -0
- package/reference/carousel-contract.md +91 -0
- package/reference/cloud.md +96 -0
- package/reference/learnings.md +792 -0
- package/reference/omnichat.md +305 -0
- package/reference/premiere-mcp.md +91 -0
- package/reference/publish.md +305 -0
- package/reference/scenes-contract.md +109 -0
- package/reference/studio.md +666 -0
- package/reference/voicestudio.md +81 -0
- package/reference/writing-for-voice.md +67 -0
- package/requirements.txt +3 -0
- package/studio/api/app.ts +87 -0
- package/studio/api/lib/errors.ts +33 -0
- package/studio/api/lib/files.ts +41 -0
- package/studio/api/lib/hono.ts +9 -0
- package/studio/api/lib/result.ts +14 -0
- package/studio/api/lib/validate.ts +31 -0
- package/studio/api/lib/video.ts +10 -0
- package/studio/api/middleware/json-charset.ts +11 -0
- package/studio/api/middleware/local-only.ts +32 -0
- package/studio/api/middleware/no-timeout.ts +10 -0
- package/studio/api/routes/admin.ts +18 -0
- package/studio/api/routes/agent-cascade.ts +100 -0
- package/studio/api/routes/agent-history.ts +23 -0
- package/studio/api/routes/agent.ts +162 -0
- package/studio/api/routes/analytics.ts +31 -0
- package/studio/api/routes/approval.ts +60 -0
- package/studio/api/routes/archive.ts +12 -0
- package/studio/api/routes/captions.ts +28 -0
- package/studio/api/routes/carousel.ts +38 -0
- package/studio/api/routes/clone.ts +27 -0
- package/studio/api/routes/create.ts +19 -0
- package/studio/api/routes/events.ts +11 -0
- package/studio/api/routes/export.ts +14 -0
- package/studio/api/routes/media.ts +30 -0
- package/studio/api/routes/omnichat.ts +113 -0
- package/studio/api/routes/onboarding.ts +14 -0
- package/studio/api/routes/publish.ts +40 -0
- package/studio/api/routes/queue.ts +14 -0
- package/studio/api/routes/references.ts +40 -0
- package/studio/api/routes/runner.ts +17 -0
- package/studio/api/routes/schedule.ts +47 -0
- package/studio/api/routes/services.ts +11 -0
- package/studio/api/routes/sessions.ts +27 -0
- package/studio/api/routes/settings.ts +102 -0
- package/studio/api/routes/sound.ts +45 -0
- package/studio/api/routes/thumbnail.ts +18 -0
- package/studio/api/routes/usage.ts +13 -0
- package/studio/api/routes/videos.ts +41 -0
- package/studio/api/routes/voices.ts +71 -0
- package/studio/api/services/admin.ts +113 -0
- package/studio/api/services/agent-cascade.ts +975 -0
- package/studio/api/services/agent-claude.ts +47 -0
- package/studio/api/services/agent-history.ts +103 -0
- package/studio/api/services/agent-persona.ts +77 -0
- package/studio/api/services/agent-tools.ts +2237 -0
- package/studio/api/services/agent-ui-tools.ts +259 -0
- package/studio/api/services/agent-wait.ts +32 -0
- package/studio/api/services/agent.ts +553 -0
- package/studio/api/services/analytics.ts +92 -0
- package/studio/api/services/approval.ts +134 -0
- package/studio/api/services/archive.ts +38 -0
- package/studio/api/services/captions.ts +268 -0
- package/studio/api/services/carousel.ts +206 -0
- package/studio/api/services/classify.ts +196 -0
- package/studio/api/services/clone-phrases.ts +75 -0
- package/studio/api/services/clone.ts +722 -0
- package/studio/api/services/create.ts +421 -0
- package/studio/api/services/events.ts +215 -0
- package/studio/api/services/media.ts +32 -0
- package/studio/api/services/omnichat.ts +624 -0
- package/studio/api/services/onboarding.ts +77 -0
- package/studio/api/services/publish.ts +287 -0
- package/studio/api/services/queue.ts +150 -0
- package/studio/api/services/references.ts +269 -0
- package/studio/api/services/root.ts +60 -0
- package/studio/api/services/services.ts +114 -0
- package/studio/api/services/sessions.ts +1007 -0
- package/studio/api/services/settings.ts +983 -0
- package/studio/api/services/sound.ts +311 -0
- package/studio/api/services/thumbnail.ts +133 -0
- package/studio/api/services/usage.ts +27 -0
- package/studio/api/services/videos.ts +418 -0
- package/studio/api/services/voice-pause.ts +98 -0
- package/studio/api/services/voices.ts +324 -0
- package/studio/runner/runner.ts +244 -0
- package/studio/shared/omni-actions.ts +68 -0
- package/studio/shared/omni-admin.ts +52 -0
- package/studio/shared/omni-farewell.ts +48 -0
- package/studio/shared/omni-hotword.ts +20 -0
- package/studio/shared/omni-screens.ts +228 -0
- package/studio/shared/schemas/admin.ts +15 -0
- package/studio/shared/schemas/agent-cascade.ts +58 -0
- package/studio/shared/schemas/agent-history.ts +73 -0
- package/studio/shared/schemas/agent.ts +50 -0
- package/studio/shared/schemas/analytics.ts +6 -0
- package/studio/shared/schemas/approval.ts +22 -0
- package/studio/shared/schemas/captions.ts +19 -0
- package/studio/shared/schemas/carousel.ts +26 -0
- package/studio/shared/schemas/clone.ts +40 -0
- package/studio/shared/schemas/common.ts +16 -0
- package/studio/shared/schemas/omnichat.ts +54 -0
- package/studio/shared/schemas/onboarding.ts +5 -0
- package/studio/shared/schemas/publish.ts +45 -0
- package/studio/shared/schemas/references.ts +20 -0
- package/studio/shared/schemas/settings.ts +82 -0
- package/studio/shared/schemas/sound.ts +22 -0
- package/studio/shared/schemas/videos.ts +38 -0
- package/studio/shared/schemas/voices.ts +23 -0
- package/studio/shared/types/api.ts +1290 -0
- package/studio/studio.ts +148 -0
- package/studio/tsconfig.json +15 -0
- package/studio/web/assets/logos/cartesia.svg +4 -0
- package/studio/web/assets/logos/elevenlabs.svg +12 -0
- package/studio/web/assets/logos/fish.svg +24 -0
- package/studio/web/assets/logos/omni-black.png +0 -0
- package/studio/web/assets/logos/omni-white.png +0 -0
- package/studio/web/assets/logos/voicestudio.svg +21 -0
- package/studio/web/components/AgentMark.tsx +7 -0
- package/studio/web/components/AgentWalking.tsx +11 -0
- package/studio/web/components/ApiKeyField.tsx +104 -0
- package/studio/web/components/AppShell.tsx +64 -0
- package/studio/web/components/ApprovalNotice.tsx +65 -0
- package/studio/web/components/AvatarGroupIcon.tsx +22 -0
- package/studio/web/components/AvatarNameField.tsx +86 -0
- package/studio/web/components/AvatarPicker.tsx +84 -0
- package/studio/web/components/BrandLogo.tsx +16 -0
- package/studio/web/components/CartesiaPlanSetting.tsx +90 -0
- package/studio/web/components/ClaudeWalking.tsx +32 -0
- package/studio/web/components/CloneVoiceDialog/GuidedScript.tsx +39 -0
- package/studio/web/components/CloneVoiceDialog/LanguageBar.tsx +37 -0
- package/studio/web/components/CloneVoiceDialog/LevelMeter.tsx +31 -0
- package/studio/web/components/CloneVoiceDialog/ProviderChoice.tsx +81 -0
- package/studio/web/components/CloneVoiceDialog/QualityPanel.tsx +62 -0
- package/studio/web/components/CloneVoiceDialog/RecordStep.tsx +50 -0
- package/studio/web/components/CloneVoiceDialog/RecorderBar.tsx +79 -0
- package/studio/web/components/CloneVoiceDialog/RedoSummary.tsx +54 -0
- package/studio/web/components/CloneVoiceDialog/SaveStep.tsx +91 -0
- package/studio/web/components/CloneVoiceDialog/SourceBar.tsx +30 -0
- package/studio/web/components/CloneVoiceDialog/index.tsx +141 -0
- package/studio/web/components/CloneVoiceDialog/types.ts +28 -0
- package/studio/web/components/CloneVoiceDialog/useCloneVoice.ts +528 -0
- package/studio/web/components/ConnectionSignals.tsx +51 -0
- package/studio/web/components/EditVoiceDialog/EditVoiceFooter.tsx +72 -0
- package/studio/web/components/EditVoiceDialog/ProviderCards.tsx +81 -0
- package/studio/web/components/EditVoiceDialog/index.tsx +256 -0
- package/studio/web/components/ErrorBanner.tsx +115 -0
- package/studio/web/components/FinishedTask.tsx +41 -0
- package/studio/web/components/FishModelSetting.tsx +69 -0
- package/studio/web/components/FishPriceSetting.tsx +44 -0
- package/studio/web/components/HumanBanner.tsx +64 -0
- package/studio/web/components/Lightbox.tsx +41 -0
- package/studio/web/components/LogStream.tsx +42 -0
- package/studio/web/components/Markdown.tsx +21 -0
- package/studio/web/components/MissingDmsPanel/BatchSend.tsx +137 -0
- package/studio/web/components/MissingDmsPanel/CommentCard.tsx +168 -0
- package/studio/web/components/MissingDmsPanel/CommentFeed.tsx +45 -0
- package/studio/web/components/MissingDmsPanel/DmBubble.tsx +38 -0
- package/studio/web/components/MissingDmsPanel/ReplyComposer.tsx +63 -0
- package/studio/web/components/MissingDmsPanel/index.tsx +98 -0
- package/studio/web/components/NotFound.tsx +48 -0
- package/studio/web/components/Omni/OmniAvatarPicker.tsx +92 -0
- package/studio/web/components/Omni/OmniCards.tsx +202 -0
- package/studio/web/components/Omni/OmniGlow.tsx +183 -0
- package/studio/web/components/Omni/OmniHistory.tsx +119 -0
- package/studio/web/components/Omni/OmniHotword.tsx +40 -0
- package/studio/web/components/Omni/OmniMicSelect.tsx +92 -0
- package/studio/web/components/Omni/OmniVoiceSample.tsx +81 -0
- package/studio/web/components/Omni/OmniWidget.tsx +743 -0
- package/studio/web/components/Omni/PendingActions.tsx +200 -0
- package/studio/web/components/Omni/Transcript.tsx +127 -0
- package/studio/web/components/OmnichatAccountStatus.tsx +87 -0
- package/studio/web/components/OmnichatRulePanel/RuleConfig.tsx +150 -0
- package/studio/web/components/OmnichatRulePanel/RuleDryRun.tsx +15 -0
- package/studio/web/components/OmnichatRulePanel/RuleEnableConfirm.tsx +42 -0
- package/studio/web/components/OmnichatRulePanel/RuleSkeleton.tsx +18 -0
- package/studio/web/components/OmnichatRulePanel/RuleStatus.tsx +55 -0
- package/studio/web/components/OmnichatRulePanel/index.tsx +115 -0
- package/studio/web/components/OmnichatRulePanel/rule-steps.ts +67 -0
- package/studio/web/components/OmnichatRulePanel/steps/MessageStep.tsx +91 -0
- package/studio/web/components/OmnichatRulePanel/steps/RepliesStep.tsx +201 -0
- package/studio/web/components/OmnichatRulePanel/steps/TriggerStep.tsx +76 -0
- package/studio/web/components/OmnichatRulePanel/steps/types.ts +11 -0
- package/studio/web/components/Palette.tsx +17 -0
- package/studio/web/components/PlatformCard.tsx +109 -0
- package/studio/web/components/PlatformIcon.tsx +19 -0
- package/studio/web/components/ProviderCard.tsx +80 -0
- package/studio/web/components/ProviderDetail.tsx +367 -0
- package/studio/web/components/ProviderLogo.tsx +20 -0
- package/studio/web/components/QueuePanel.tsx +77 -0
- package/studio/web/components/ReferenceActions.tsx +89 -0
- package/studio/web/components/ReferencePicker.tsx +136 -0
- package/studio/web/components/ResultMessage.tsx +7 -0
- package/studio/web/components/RuleForm.tsx +138 -0
- package/studio/web/components/RuleLog.tsx +151 -0
- package/studio/web/components/RunningTask.tsx +23 -0
- package/studio/web/components/SampleList.tsx +55 -0
- package/studio/web/components/SessionPanel.tsx +352 -0
- package/studio/web/components/SettingRow.tsx +14 -0
- package/studio/web/components/SettingsCategorySkeleton.tsx +25 -0
- package/studio/web/components/SidePanel.tsx +77 -0
- package/studio/web/components/Sidebar.tsx +289 -0
- package/studio/web/components/StageStepper.tsx +87 -0
- package/studio/web/components/StudioOffline.tsx +80 -0
- package/studio/web/components/TaskName.tsx +17 -0
- package/studio/web/components/TopBanners.tsx +30 -0
- package/studio/web/components/VideoOmnichatPanel.tsx +287 -0
- package/studio/web/components/VoiceAvatar.tsx +33 -0
- package/studio/web/components/VoiceCarousel.tsx +196 -0
- package/studio/web/components/VoiceCategory.tsx +9 -0
- package/studio/web/components/VoiceModal.tsx +39 -0
- package/studio/web/components/VoiceProfileCard.tsx +75 -0
- package/studio/web/components/VoiceProfilePicker.tsx +107 -0
- package/studio/web/components/VoiceProfilesSettings.tsx +150 -0
- package/studio/web/components/VoiceProviderCard.tsx +118 -0
- package/studio/web/components/VoiceProvidersCard.tsx +26 -0
- package/studio/web/components/WaitList.tsx +21 -0
- package/studio/web/components/icons.tsx +247 -0
- package/studio/web/components/ui/accordion.tsx +47 -0
- package/studio/web/components/ui/badge.tsx +18 -0
- package/studio/web/components/ui/calendar.tsx +43 -0
- package/studio/web/components/ui/chart.tsx +229 -0
- package/studio/web/components/ui/checkbox.tsx +26 -0
- package/studio/web/components/ui/cx.ts +2 -0
- package/studio/web/components/ui/date-time-picker.tsx +84 -0
- package/studio/web/components/ui/panel.tsx +23 -0
- package/studio/web/components/ui/picker.tsx +58 -0
- package/studio/web/components/ui/popover.tsx +24 -0
- package/studio/web/components/ui/select.tsx +89 -0
- package/studio/web/components/ui/skeleton.tsx +10 -0
- package/studio/web/components/ui/slider.tsx +68 -0
- package/studio/web/components/ui/switch.tsx +13 -0
- package/studio/web/components/ui/tooltip.test.tsx +30 -0
- package/studio/web/components/ui/tooltip.tsx +59 -0
- package/studio/web/hooks/useAccounts.ts +27 -0
- package/studio/web/hooks/useAdmin.ts +12 -0
- package/studio/web/hooks/useAnalytics.ts +21 -0
- package/studio/web/hooks/useAvatarAudioReactive.ts +87 -0
- package/studio/web/hooks/useBrowserConnect.ts +48 -0
- package/studio/web/hooks/useClonePlan.ts +14 -0
- package/studio/web/hooks/useConnected.ts +7 -0
- package/studio/web/hooks/useLiveQuery.ts +29 -0
- package/studio/web/hooks/useMenuCollapsed.ts +32 -0
- package/studio/web/hooks/useMicDevices.ts +53 -0
- package/studio/web/hooks/useMissingDms.ts +211 -0
- package/studio/web/hooks/useMissingSetupSteps.ts +26 -0
- package/studio/web/hooks/useNow.ts +11 -0
- package/studio/web/hooks/useOmniAgent.ts +278 -0
- package/studio/web/hooks/useOmniClaude.ts +124 -0
- package/studio/web/hooks/useOmniDock.ts +142 -0
- package/studio/web/hooks/useOmniGreeting.ts +60 -0
- package/studio/web/hooks/useOmniHotword.ts +128 -0
- package/studio/web/hooks/useOmnichat.ts +26 -0
- package/studio/web/hooks/useOnboarding.ts +27 -0
- package/studio/web/hooks/usePost.ts +23 -0
- package/studio/web/hooks/useQueue.ts +10 -0
- package/studio/web/hooks/useReferences.ts +20 -0
- package/studio/web/hooks/useRuleEditor.ts +101 -0
- package/studio/web/hooks/useRunner.ts +24 -0
- package/studio/web/hooks/useSaveAction.ts +23 -0
- package/studio/web/hooks/useSchedule.ts +11 -0
- package/studio/web/hooks/useServices.ts +10 -0
- package/studio/web/hooks/useSessions.ts +15 -0
- package/studio/web/hooks/useSettings.ts +11 -0
- package/studio/web/hooks/useSettingsSection.ts +30 -0
- package/studio/web/hooks/useSidePanel.ts +23 -0
- package/studio/web/hooks/useSound.ts +30 -0
- package/studio/web/hooks/useUsage.ts +11 -0
- package/studio/web/hooks/useVideoVoice.ts +36 -0
- package/studio/web/hooks/useVideos.ts +21 -0
- package/studio/web/hooks/useVoiceProfilePreview.ts +52 -0
- package/studio/web/hooks/useVoiceProfiles.ts +7 -0
- package/studio/web/hooks/useVoiceRunning.ts +10 -0
- package/studio/web/hooks/useVoiceStudioClosed.ts +8 -0
- package/studio/web/index.html +19 -0
- package/studio/web/lib/agent.ts +7 -0
- package/studio/web/lib/alerts.ts +210 -0
- package/studio/web/lib/analytics-metrics.ts +351 -0
- package/studio/web/lib/api.ts +70 -0
- package/studio/web/lib/audio.ts +39 -0
- package/studio/web/lib/avatars.ts +41 -0
- package/studio/web/lib/calendar.ts +218 -0
- package/studio/web/lib/caption-position.ts +249 -0
- package/studio/web/lib/carousel.ts +24 -0
- package/studio/web/lib/chime.ts +42 -0
- package/studio/web/lib/clone-voice.ts +55 -0
- package/studio/web/lib/export.ts +11 -0
- package/studio/web/lib/files.ts +8 -0
- package/studio/web/lib/format.ts +93 -0
- package/studio/web/lib/media.ts +29 -0
- package/studio/web/lib/mic-device.ts +72 -0
- package/studio/web/lib/missing-dms.ts +70 -0
- package/studio/web/lib/omni-cards.ts +42 -0
- package/studio/web/lib/omni-cascade.ts +1067 -0
- package/studio/web/lib/omni-greeting-audio.ts +24 -0
- package/studio/web/lib/omni-hotword.ts +231 -0
- package/studio/web/lib/omni-panel.ts +67 -0
- package/studio/web/lib/omni-realtime.ts +811 -0
- package/studio/web/lib/omni-ui.ts +402 -0
- package/studio/web/lib/omni-wait.ts +174 -0
- package/studio/web/lib/omnichat-api.ts +44 -0
- package/studio/web/lib/orb.ts +270 -0
- package/studio/web/lib/pcm-recorder.ts +115 -0
- package/studio/web/lib/platforms.ts +17 -0
- package/studio/web/lib/providers.ts +27 -0
- package/studio/web/lib/publish-draft.ts +52 -0
- package/studio/web/lib/publish-settings.ts +81 -0
- package/studio/web/lib/query-client.ts +122 -0
- package/studio/web/lib/references.ts +13 -0
- package/studio/web/lib/services.ts +40 -0
- package/studio/web/lib/sessions.ts +103 -0
- package/studio/web/lib/settings-categories.ts +58 -0
- package/studio/web/lib/sound-audio.ts +33 -0
- package/studio/web/lib/sound-timeline.ts +291 -0
- package/studio/web/lib/sse.ts +86 -0
- package/studio/web/lib/stage-history.ts +141 -0
- package/studio/web/lib/stages.ts +344 -0
- package/studio/web/lib/studio-offline.ts +60 -0
- package/studio/web/lib/upload.ts +24 -0
- package/studio/web/lib/video-tabs.ts +118 -0
- package/studio/web/lib/voice-profile-draft.ts +34 -0
- package/studio/web/lib/voice-profiles.ts +3 -0
- package/studio/web/main.tsx +14 -0
- package/studio/web/pages/AdminPage/index.tsx +123 -0
- package/studio/web/pages/AgentPage/components/Measurements.tsx +102 -0
- package/studio/web/pages/AgentPage/index.tsx +28 -0
- package/studio/web/pages/AnalyticsPage/components/About.tsx +52 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelCards.tsx +106 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelView.tsx +137 -0
- package/studio/web/pages/AnalyticsPage/components/CollectionStatus.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/Comparison.tsx +68 -0
- package/studio/web/pages/AnalyticsPage/components/Diagnosis.tsx +50 -0
- package/studio/web/pages/AnalyticsPage/components/Highlights.tsx +49 -0
- package/studio/web/pages/AnalyticsPage/components/Hint.tsx +11 -0
- package/studio/web/pages/AnalyticsPage/components/HookVsBody.tsx +100 -0
- package/studio/web/pages/AnalyticsPage/components/HourlyWave.tsx +133 -0
- package/studio/web/pages/AnalyticsPage/components/Insights.tsx +70 -0
- package/studio/web/pages/AnalyticsPage/components/MetricCard.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/PlanSection.tsx +40 -0
- package/studio/web/pages/AnalyticsPage/components/ProgressionChart.tsx +155 -0
- package/studio/web/pages/AnalyticsPage/components/ReelBarsChart.tsx +154 -0
- package/studio/web/pages/AnalyticsPage/components/ReelThumb.tsx +19 -0
- package/studio/web/pages/AnalyticsPage/components/ReelView.tsx +290 -0
- package/studio/web/pages/AnalyticsPage/components/ReelsTable.tsx +269 -0
- package/studio/web/pages/AnalyticsPage/components/RequestWithFocus.tsx +38 -0
- package/studio/web/pages/AnalyticsPage/components/SegmentedControl.tsx +35 -0
- package/studio/web/pages/AnalyticsPage/components/VsMedian.tsx +31 -0
- package/studio/web/pages/AnalyticsPage/index.tsx +17 -0
- package/studio/web/pages/GettingStartedPage/index.tsx +174 -0
- package/studio/web/pages/NewVideoPage/components/DeliverablesPicker.tsx +62 -0
- package/studio/web/pages/NewVideoPage/components/FormatPicker.tsx +33 -0
- package/studio/web/pages/NewVideoPage/index.tsx +133 -0
- package/studio/web/pages/NotFoundPage/index.tsx +9 -0
- package/studio/web/pages/OmnichatPage/components/NewFromLink.tsx +59 -0
- package/studio/web/pages/OmnichatPage/components/RuleListItem.tsx +64 -0
- package/studio/web/pages/OmnichatPage/components/RulePreview.tsx +14 -0
- package/studio/web/pages/OmnichatPage/components/RuleView.tsx +88 -0
- package/studio/web/pages/OmnichatPage/index.tsx +153 -0
- package/studio/web/pages/QueuePage/index.tsx +22 -0
- package/studio/web/pages/ReferencePage/components/ReferenceTexts.tsx +131 -0
- package/studio/web/pages/ReferencePage/index.tsx +216 -0
- package/studio/web/pages/ReferencesPage/components/NewReferenceForm.tsx +150 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceCard.tsx +42 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceGridSkeleton.tsx +31 -0
- package/studio/web/pages/ReferencesPage/index.tsx +67 -0
- package/studio/web/pages/SchedulePage/components/CalendarSkeleton.tsx +18 -0
- package/studio/web/pages/SchedulePage/components/DayView.tsx +177 -0
- package/studio/web/pages/SchedulePage/components/HourPicker.tsx +103 -0
- package/studio/web/pages/SchedulePage/components/MonthDayCell.tsx +111 -0
- package/studio/web/pages/SchedulePage/components/MonthView.tsx +47 -0
- package/studio/web/pages/SchedulePage/components/PlatformIcons.tsx +12 -0
- package/studio/web/pages/SchedulePage/components/PostThumb.tsx +15 -0
- package/studio/web/pages/SchedulePage/components/WeekColumn.tsx +75 -0
- package/studio/web/pages/SchedulePage/components/WeekView.tsx +35 -0
- package/studio/web/pages/SchedulePage/index.tsx +285 -0
- package/studio/web/pages/SettingsPage/components/AgentAccounts.tsx +263 -0
- package/studio/web/pages/SettingsPage/components/AgentCategory.tsx +20 -0
- package/studio/web/pages/SettingsPage/components/ModelPicker.tsx +49 -0
- package/studio/web/pages/SettingsPage/components/ModelsSettings.tsx +138 -0
- package/studio/web/pages/SettingsPage/components/PlatformsCategory.tsx +23 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AccountStatus.tsx +29 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AutoPublishPanel.tsx +90 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/BrowserConnect.tsx +62 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/CheckField.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/InstagramPanel.tsx +113 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/OmnichatSettingsPanel.tsx +146 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SaveBar.tsx +33 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SchedulePanel.tsx +132 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCard.tsx +47 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCardGroup.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TextPanel.tsx +55 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TiktokPanel.tsx +123 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/YoutubePanel.tsx +100 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/badges.tsx +15 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/index.tsx +40 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/types.ts +10 -0
- package/studio/web/pages/SettingsPage/components/UsageCategory.tsx +389 -0
- package/studio/web/pages/SettingsPage/components/VoiceProvidersCategory.tsx +97 -0
- package/studio/web/pages/SettingsPage/index.tsx +85 -0
- package/studio/web/pages/VideoPage/components/AudioPlayer.tsx +113 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/AxisField.tsx +50 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionList.tsx +56 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionListItem.tsx +92 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionMargins.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionStyleFields.tsx +70 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionTextForm.tsx +87 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/ColorField.tsx +37 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/MarginField.tsx +59 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/NumberField.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/PositionControls.tsx +140 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/captionEditor.ts +215 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/useCaptionPosition.ts +154 -0
- package/studio/web/pages/VideoPage/components/CarouselChangeRequest.tsx +72 -0
- package/studio/web/pages/VideoPage/components/CarouselCompositionStage.tsx +80 -0
- package/studio/web/pages/VideoPage/components/CarouselCreate.tsx +63 -0
- package/studio/web/pages/VideoPage/components/CarouselMissing.tsx +19 -0
- package/studio/web/pages/VideoPage/components/CarouselPublishStage.tsx +173 -0
- package/studio/web/pages/VideoPage/components/CarouselScriptStage.tsx +82 -0
- package/studio/web/pages/VideoPage/components/CarouselSlideCard.tsx +49 -0
- package/studio/web/pages/VideoPage/components/CarouselViewer.tsx +55 -0
- package/studio/web/pages/VideoPage/components/ChangedVoices.tsx +53 -0
- package/studio/web/pages/VideoPage/components/CompositionStage.tsx +78 -0
- package/studio/web/pages/VideoPage/components/CoverPicker.tsx +32 -0
- package/studio/web/pages/VideoPage/components/EditorStage.tsx +53 -0
- package/studio/web/pages/VideoPage/components/LineTakes.tsx +160 -0
- package/studio/web/pages/VideoPage/components/LineTextEditor.tsx +124 -0
- package/studio/web/pages/VideoPage/components/LineVoicePicker.tsx +37 -0
- package/studio/web/pages/VideoPage/components/MediaImage.tsx +25 -0
- package/studio/web/pages/VideoPage/components/MotionScriptStage.tsx +39 -0
- package/studio/web/pages/VideoPage/components/NarrationStage.tsx +70 -0
- package/studio/web/pages/VideoPage/components/PublishForm.tsx +387 -0
- package/studio/web/pages/VideoPage/components/PublishStage.tsx +76 -0
- package/studio/web/pages/VideoPage/components/PublishText.tsx +149 -0
- package/studio/web/pages/VideoPage/components/ScenesApprovalPanel.tsx +278 -0
- package/studio/web/pages/VideoPage/components/ScheduledInfo.tsx +72 -0
- package/studio/web/pages/VideoPage/components/ScriptApprovalPanel.tsx +189 -0
- package/studio/web/pages/VideoPage/components/ScriptStage.tsx +17 -0
- package/studio/web/pages/VideoPage/components/SequencePlayer.tsx +146 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AddSound.tsx +117 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AreaSelection.tsx +74 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedPanel.tsx +94 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedRow.tsx +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionOverlay.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionSaveBar.tsx +32 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionsPanel.tsx +22 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipBlock.tsx +111 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipPanel.tsx +76 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CutsPanel.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EditorTabBar.tsx +73 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectChoice.tsx +46 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectItem.tsx +89 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectPanel.tsx +232 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectsRow.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Lane.tsx +39 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MarkerRow.tsx +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MuteButton.tsx +36 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/NumberInput.tsx +37 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlanWarnings.tsx +19 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlayerResizeHandle.tsx +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PreviewControls.tsx +51 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SceneRow.tsx +54 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SettingsPanel.tsx +65 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundLibrary.tsx +99 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundPreview.tsx +82 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SpeedPanel.tsx +128 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineDock.tsx +56 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineFooter.tsx +26 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineSkeleton.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineToolbar.tsx +160 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineTracks.tsx +121 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TrackSidebar.tsx +30 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/VoiceRow.tsx +53 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Waveform.tsx +97 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/clipActions.ts +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/effectActions.ts +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/index.tsx +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/timelineGeometry.ts +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/types.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useAutosave.ts +107 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useEditorShortcuts.ts +168 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFitHeight.ts +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFollowPlayhead.ts +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useListenMix.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayback.ts +231 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayerWidth.ts +27 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundData.ts +124 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundTimeline.ts +511 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/CompareVersions.tsx +111 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionCard.tsx +81 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionMedia.tsx +24 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionText.tsx +15 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/index.tsx +109 -0
- package/studio/web/pages/VideoPage/components/StageProcess.tsx +126 -0
- package/studio/web/pages/VideoPage/components/StageResult.tsx +69 -0
- package/studio/web/pages/VideoPage/components/SwapReference.tsx +92 -0
- package/studio/web/pages/VideoPage/components/ThumbnailPanel.tsx +252 -0
- package/studio/web/pages/VideoPage/components/TimingPanel.tsx +89 -0
- package/studio/web/pages/VideoPage/components/VideoPlayer.tsx +18 -0
- package/studio/web/pages/VideoPage/components/VideoSkeleton.tsx +50 -0
- package/studio/web/pages/VideoPage/components/VideoVoiceInfo.tsx +33 -0
- package/studio/web/pages/VideoPage/components/VideoVoicePicker.tsx +165 -0
- package/studio/web/pages/VideoPage/components/VoicePauseBanner.tsx +56 -0
- package/studio/web/pages/VideoPage/components/WithLogo.tsx +10 -0
- package/studio/web/pages/VideoPage/index.tsx +295 -0
- package/studio/web/pages/VideosPage/components/PublishedOn.tsx +85 -0
- package/studio/web/pages/VideosPage/components/ServicesPanel.tsx +81 -0
- package/studio/web/pages/VideosPage/components/SessionsPanel.tsx +62 -0
- package/studio/web/pages/VideosPage/components/VideoListSkeleton.tsx +25 -0
- package/studio/web/pages/VideosPage/components/VideoRow.tsx +122 -0
- package/studio/web/pages/VideosPage/index.tsx +134 -0
- package/studio/web/pages/VoicePage/index.tsx +28 -0
- package/studio/web/router.tsx +201 -0
- package/studio/web/styles/base/elements.css +55 -0
- package/studio/web/styles/base/utilities.css +25 -0
- package/studio/web/styles/components/badge.css +33 -0
- package/studio/web/styles/components/claude-running.css +27 -0
- package/studio/web/styles/components/claude-session.css +212 -0
- package/studio/web/styles/components/claude-walking.css +92 -0
- package/studio/web/styles/components/clone-voice-save.css +136 -0
- package/studio/web/styles/components/clone-voice.css +379 -0
- package/studio/web/styles/components/controls.css +70 -0
- package/studio/web/styles/components/data-and-image.css +54 -0
- package/studio/web/styles/components/forms.css +132 -0
- package/studio/web/styles/components/human-banner.css +99 -0
- package/studio/web/styles/components/lightbox.css +50 -0
- package/studio/web/styles/components/markdown.css +68 -0
- package/studio/web/styles/components/modal.css +70 -0
- package/studio/web/styles/components/omni-cards.css +105 -0
- package/studio/web/styles/components/omni.css +859 -0
- package/studio/web/styles/components/omnichat.css +538 -0
- package/studio/web/styles/components/panel.css +115 -0
- package/studio/web/styles/components/platform-card.css +140 -0
- package/studio/web/styles/components/provider-card.css +132 -0
- package/studio/web/styles/components/queue.css +185 -0
- package/studio/web/styles/components/reference-actions.css +133 -0
- package/studio/web/styles/components/reference-picker.css +146 -0
- package/studio/web/styles/components/results-drawer.css +224 -0
- package/studio/web/styles/components/segmented.css +115 -0
- package/studio/web/styles/components/side-panel-tab.css +23 -0
- package/studio/web/styles/components/status-signals.css +66 -0
- package/studio/web/styles/components/stepper.css +208 -0
- package/studio/web/styles/components/table.css +19 -0
- package/studio/web/styles/components/tabs.css +24 -0
- package/studio/web/styles/components/ui/accordion.css +71 -0
- package/studio/web/styles/components/ui/chart.css +162 -0
- package/studio/web/styles/components/ui/checkbox.css +37 -0
- package/studio/web/styles/components/ui/date-picker.css +153 -0
- package/studio/web/styles/components/ui/select.css +110 -0
- package/studio/web/styles/components/ui/skeleton.css +25 -0
- package/studio/web/styles/components/ui/slider.css +81 -0
- package/studio/web/styles/components/ui/switch.css +41 -0
- package/studio/web/styles/components/ui/tooltip.css +24 -0
- package/studio/web/styles/components/voice-carousel.css +255 -0
- package/studio/web/styles/components/voice-editor.css +179 -0
- package/studio/web/styles/components/voice-grid.css +56 -0
- package/studio/web/styles/components/voice-profiles.css +192 -0
- package/studio/web/styles/design-system.md +136 -0
- package/studio/web/styles/index.css +116 -0
- package/studio/web/styles/layout/page.css +41 -0
- package/studio/web/styles/layout/sidebar-groups.css +39 -0
- package/studio/web/styles/layout/sidebar.css +111 -0
- package/studio/web/styles/pages/agent.css +26 -0
- package/studio/web/styles/pages/analytics/dashboard.css +614 -0
- package/studio/web/styles/pages/analytics/insights.css +48 -0
- package/studio/web/styles/pages/getting-started.css +166 -0
- package/studio/web/styles/pages/new-video/form.css +32 -0
- package/studio/web/styles/pages/not-found.css +59 -0
- package/studio/web/styles/pages/references.css +204 -0
- package/studio/web/styles/pages/schedule/calendar.css +541 -0
- package/studio/web/styles/pages/schedule/chip-states.css +60 -0
- package/studio/web/styles/pages/settings/models.css +72 -0
- package/studio/web/styles/pages/settings/shell.css +361 -0
- package/studio/web/styles/pages/settings/usage.css +63 -0
- package/studio/web/styles/pages/studio-offline.css +105 -0
- package/studio/web/styles/pages/video/caption-controls.css +194 -0
- package/studio/web/styles/pages/video/captions-grid.css +70 -0
- package/studio/web/styles/pages/video/captions.css +79 -0
- package/studio/web/styles/pages/video/editor-chat.css +103 -0
- package/studio/web/styles/pages/video/export.css +50 -0
- package/studio/web/styles/pages/video/frames.css +29 -0
- package/studio/web/styles/pages/video/fullscreen-stage.css +400 -0
- package/studio/web/styles/pages/video/instagram-carousel.css +309 -0
- package/studio/web/styles/pages/video/layout.css +285 -0
- package/studio/web/styles/pages/video/narration.css +138 -0
- package/studio/web/styles/pages/video/preview-overview.css +11 -0
- package/studio/web/styles/pages/video/processing-notice.css +34 -0
- package/studio/web/styles/pages/video/publish-when.css +76 -0
- package/studio/web/styles/pages/video/publish.css +97 -0
- package/studio/web/styles/pages/video/result.css +96 -0
- package/studio/web/styles/pages/video/scenes.css +167 -0
- package/studio/web/styles/pages/video/sound-timeline.css +672 -0
- package/studio/web/styles/pages/video/sound-toolbar.css +149 -0
- package/studio/web/styles/pages/video/take-player.css +100 -0
- package/studio/web/styles/pages/video/thumbnail.css +157 -0
- package/studio/web/styles/pages/video/timeline.css +117 -0
- package/studio/web/styles/pages/video/voice-picker.css +14 -0
- package/studio/web/styles/pages/video-list/active-row.css +27 -0
- package/studio/web/styles/pages/video-list/card-link.css +49 -0
- package/studio/web/styles/pages/video-list/list.css +86 -0
- package/studio/web/styles/theme/identity/details.css +204 -0
- package/studio/web/styles/theme/identity/shell.css +249 -0
- package/studio/web/styles/theme/identity/surfaces.css +183 -0
- package/studio/web/styles/theme/identity/titles-and-buttons.css +120 -0
- package/studio/web/styles/theme/no-borders/blocks.css +208 -0
- package/studio/web/styles/theme/no-borders/controls.css +256 -0
- package/studio/web/styles/tokens.css +245 -0
- package/studio/web/types/api.ts +2 -0
- package/studio/web/types/assets.d.ts +9 -0
- package/templates/brief.md +27 -0
- package/templates/captions.html +204 -0
- package/templates/carousel-composition.md +47 -0
- package/templates/carousel-script.md +60 -0
- package/templates/components/voiceavatar/README.md +87 -0
- package/templates/components/voiceavatar/demo.html +50 -0
- package/templates/components/voiceavatar/voiceavatar.js +415 -0
- package/templates/motion.md +80 -0
- package/templates/playbook.md +43 -0
- package/templates/reference.md +123 -0
- package/templates/scene.html +112 -0
- package/templates/scenes.example.json +96 -0
- package/templates/script.md +63 -0
- package/templates/slide.html +71 -0
- package/templates/wireframe.html +91 -0
- package/tools/analysis.mjs +300 -0
- package/tools/approval.mjs +442 -0
- package/tools/assemble.mjs +942 -0
- package/tools/build-motion.mjs +437 -0
- package/tools/captions.mjs +246 -0
- package/tools/carousel.mjs +558 -0
- package/tools/compose.mjs +307 -0
- package/tools/cuts.mjs +74 -0
- package/tools/editor.mjs +419 -0
- package/tools/epidemic-capture.js +54 -0
- package/tools/fanout.mjs +69 -0
- package/tools/history.mjs +70 -0
- package/tools/history.py +61 -0
- package/tools/job-queue.mjs +180 -0
- package/tools/job_queue.py +430 -0
- package/tools/lib/agents.mjs +412 -0
- package/tools/lib/channel.mjs +399 -0
- package/tools/lib/claude-settings.mjs +67 -0
- package/tools/lib/cli.mjs +9 -0
- package/tools/lib/fanout.mjs +234 -0
- package/tools/lib/http.mjs +94 -0
- package/tools/lib/index.js +14 -0
- package/tools/lib/mcp-server.mjs +69 -0
- package/tools/lib/metrics/metrics.mjs +204 -0
- package/tools/lib/narration.mjs +15 -0
- package/tools/lib/oauth-client.mjs +295 -0
- package/tools/lib/omnichat/config.mjs +139 -0
- package/tools/lib/omnichat/errors.mjs +42 -0
- package/tools/lib/omnichat/extract.mjs +82 -0
- package/tools/lib/omnichat/gate.mjs +151 -0
- package/tools/lib/omnichat/manual.mjs +166 -0
- package/tools/lib/omnichat/match.mjs +78 -0
- package/tools/lib/omnichat/pass.mjs +393 -0
- package/tools/lib/omnichat/record.mjs +208 -0
- package/tools/lib/omnichat/text.mjs +315 -0
- package/tools/lib/omnichat/webhook.mjs +166 -0
- package/tools/lib/pairing.mjs +99 -0
- package/tools/lib/paths.mjs +41 -0
- package/tools/lib/platforms/instagram.mjs +469 -0
- package/tools/lib/platforms/tiktok.mjs +343 -0
- package/tools/lib/platforms/youtube.mjs +228 -0
- package/tools/lib/publish/publish.mjs +244 -0
- package/tools/lib/schedule/schedule.mjs +191 -0
- package/tools/lib/service.mjs +134 -0
- package/tools/lib/skill-client.mjs +126 -0
- package/tools/lib/skills-release.mjs +196 -0
- package/tools/lib/testing.mjs +52 -0
- package/tools/lib/up.mjs +187 -0
- package/tools/metrics.mjs +415 -0
- package/tools/models.mjs +134 -0
- package/tools/narrate.mjs +257 -0
- package/tools/omni.mjs +298 -0
- package/tools/omni_paths.py +12 -0
- package/tools/omnichat.mjs +1577 -0
- package/tools/omnivideo.py +1122 -0
- package/tools/package.mjs +130 -0
- package/tools/platforms.mjs +236 -0
- package/tools/premiere.mjs +533 -0
- package/tools/publish.mjs +1496 -0
- package/tools/reference.mjs +1408 -0
- package/tools/render.mjs +426 -0
- package/tools/runner.mjs +156 -0
- package/tools/setup.mjs +466 -0
- package/tools/skills-release.mjs +93 -0
- package/tools/sound.mjs +1323 -0
- package/tools/soundtrack.mjs +217 -0
- package/tools/thumbnail.mjs +271 -0
- package/tools/timing.mjs +108 -0
- package/tools/usage.py +628 -0
- package/tools/voice-envelope.mjs +185 -0
- package/tools/voice.py +448 -0
- package/tools/voice_sample.py +75 -0
- package/tools/wireframe.mjs +230 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
TikTok (Content Posting API, Login Kit for desktop). The access token lasts
|
|
3
|
+
24 h and the refresh one a year: each use renews whatever expired and writes
|
|
4
|
+
both back to the injected TokenStore. `mode: "direct"` publishes to the
|
|
5
|
+
profile (video.publish); `"draft"` sends it to the app's inbox
|
|
6
|
+
(video.upload). An unaudited app only publishes as "only me" (SELF_ONLY).
|
|
7
|
+
Pure: the file comes in as bytes.
|
|
8
|
+
============================================================================ */
|
|
9
|
+
|
|
10
|
+
import { request, withDefaults } from "../http.mjs";
|
|
11
|
+
|
|
12
|
+
/** @typedef {import("../http.mjs").Deps} Deps */
|
|
13
|
+
/** @typedef {import("../http.mjs").TokenStore} TokenStore */
|
|
14
|
+
|
|
15
|
+
export const TT = "https://open.tiktokapis.com/v2";
|
|
16
|
+
export const TT_AUTH = "https://www.tiktok.com/v2/auth/authorize/";
|
|
17
|
+
export const TT_SCOPES = ["user.info.basic", "user.info.profile", "video.publish", "video.upload"];
|
|
18
|
+
const MB = 1024 * 1024;
|
|
19
|
+
/** The access token is reused while more than this is left. */
|
|
20
|
+
export const ACCESS_MARGIN_MS = 10 * 60_000;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The app credentials from the store.
|
|
24
|
+
* @param {TokenStore} store
|
|
25
|
+
*/
|
|
26
|
+
export function tiktokApp(store) {
|
|
27
|
+
const key = store.get("TIKTOK_CLIENT_KEY"),
|
|
28
|
+
secret = store.get("TIKTOK_CLIENT_SECRET");
|
|
29
|
+
if (!key || !secret)
|
|
30
|
+
throw new Error("faltam TIKTOK_CLIENT_KEY e TIKTOK_CLIENT_SECRET no .env (reference/publish.md, TikTok passo 2)");
|
|
31
|
+
return { key, secret };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Is the stored access token still good for this call?
|
|
36
|
+
* @param {{ access: string, expires: number, now: number }} p `expires` epoch ms (NaN when unknown)
|
|
37
|
+
*/
|
|
38
|
+
export const tiktokAccessValid = ({ access, expires, now }) => !!access && expires - now > ACCESS_MARGIN_MS;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The store values a token answer becomes.
|
|
42
|
+
* @param {any} j the /oauth/token/ body
|
|
43
|
+
* @param {number} now
|
|
44
|
+
* @returns {Record<string, string>}
|
|
45
|
+
*/
|
|
46
|
+
export const tiktokTokenValues = (j, now) => ({
|
|
47
|
+
TIKTOK_ACCESS_TOKEN: j.access_token,
|
|
48
|
+
TIKTOK_ACCESS_EXPIRES: new Date(now + j.expires_in * 1000).toISOString(),
|
|
49
|
+
...(j.refresh_token ? { TIKTOK_REFRESH_TOKEN: j.refresh_token } : {}),
|
|
50
|
+
...(j.refresh_expires_in
|
|
51
|
+
? { TIKTOK_REFRESH_EXPIRES: new Date(now + j.refresh_expires_in * 1000).toISOString() }
|
|
52
|
+
: {}),
|
|
53
|
+
...(j.open_id ? { TIKTOK_OPEN_ID: j.open_id } : {}),
|
|
54
|
+
...(j.scope ? { TIKTOK_SCOPES: j.scope } : {}),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The token route answers 200 even on error (`error` in the body). Stores what comes back.
|
|
59
|
+
* @param {{ store: TokenStore, body: Record<string, string>, label: string } & Deps} p
|
|
60
|
+
* @returns {Promise<string>} the access token
|
|
61
|
+
*/
|
|
62
|
+
export async function fetchTiktokToken({ store, body, label, ...deps }) {
|
|
63
|
+
const d = withDefaults(deps);
|
|
64
|
+
const { key, secret } = tiktokApp(store);
|
|
65
|
+
const { j } = await request(
|
|
66
|
+
`${TT}/oauth/token/`,
|
|
67
|
+
{
|
|
68
|
+
method: "POST",
|
|
69
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
70
|
+
body: new URLSearchParams({ client_key: key, client_secret: secret, ...body }),
|
|
71
|
+
},
|
|
72
|
+
label,
|
|
73
|
+
d,
|
|
74
|
+
);
|
|
75
|
+
if (!j?.access_token) throw new Error(`${label}: ${j?.error_description || j?.error || "sem access_token"}`);
|
|
76
|
+
await store.set(tiktokTokenValues(j, d.now()));
|
|
77
|
+
return j.access_token;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A usable access token: the stored one while valid, else renewed with the refresh token.
|
|
82
|
+
* @param {{ store: TokenStore } & Deps} p
|
|
83
|
+
* @returns {Promise<string>}
|
|
84
|
+
*/
|
|
85
|
+
export async function tiktokAccessToken({ store, ...deps }) {
|
|
86
|
+
const d = withDefaults(deps);
|
|
87
|
+
tiktokApp(store);
|
|
88
|
+
const refresh = store.get("TIKTOK_REFRESH_TOKEN");
|
|
89
|
+
if (!refresh) throw new Error("TikTok não conectado: rode node tools/publish.mjs auth tiktok");
|
|
90
|
+
const access = store.get("TIKTOK_ACCESS_TOKEN");
|
|
91
|
+
if (tiktokAccessValid({ access, expires: Date.parse(store.get("TIKTOK_ACCESS_EXPIRES")), now: d.now() }))
|
|
92
|
+
return access;
|
|
93
|
+
try {
|
|
94
|
+
return await fetchTiktokToken({
|
|
95
|
+
store,
|
|
96
|
+
body: { grant_type: "refresh_token", refresh_token: refresh },
|
|
97
|
+
label: "token do TikTok",
|
|
98
|
+
...d,
|
|
99
|
+
});
|
|
100
|
+
} catch (e) {
|
|
101
|
+
if (/invalid_grant|expired|revoked|invalid_request/i.test(/** @type {Error} */ (e).message))
|
|
102
|
+
throw new Error("o login do TikTok venceu ou foi revogado: rode node tools/publish.mjs auth tiktok de novo");
|
|
103
|
+
throw e;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The consent URL for the desktop login. TikTok desktop PKCE: the challenge is the SHA-256 in hex.
|
|
109
|
+
* @param {{ clientKey: string, redirect: string, state: string, challenge: string }} p
|
|
110
|
+
*/
|
|
111
|
+
export const tiktokAuthUrl = ({ clientKey, redirect, state, challenge }) =>
|
|
112
|
+
`${TT_AUTH}?${new URLSearchParams({
|
|
113
|
+
client_key: clientKey,
|
|
114
|
+
scope: TT_SCOPES.join(","),
|
|
115
|
+
response_type: "code",
|
|
116
|
+
redirect_uri: redirect,
|
|
117
|
+
state,
|
|
118
|
+
code_challenge: challenge,
|
|
119
|
+
code_challenge_method: "S256",
|
|
120
|
+
})}`;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* JSON POST to the API: the error comes in `error.code` even with HTTP 200.
|
|
124
|
+
* @param {string} token @param {string} path @param {any} body @param {string} label @param {Deps} [deps]
|
|
125
|
+
* @returns {Promise<{ data: any, text: string }>}
|
|
126
|
+
*/
|
|
127
|
+
export async function ttApi(token, path, body, label, deps = {}) {
|
|
128
|
+
const { j, text } = await request(
|
|
129
|
+
`${TT}${path}`,
|
|
130
|
+
{
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: { authorization: `Bearer ${token}`, "content-type": "application/json; charset=UTF-8" },
|
|
133
|
+
body: JSON.stringify(body),
|
|
134
|
+
},
|
|
135
|
+
label,
|
|
136
|
+
withDefaults(deps),
|
|
137
|
+
);
|
|
138
|
+
if (j?.error?.code && j.error.code !== "ok") {
|
|
139
|
+
/** @type {import("../http.mjs").PlatformError} */
|
|
140
|
+
const error = new Error(`${label}: ${j.error.message || j.error.code} (${j.error.code})`);
|
|
141
|
+
error.code = j.error.code;
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
return { data: j?.data ?? {}, text };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The account card. `username` needs user.info.profile: without it, the display name stays.
|
|
149
|
+
* @param {string} token @param {Deps} [deps]
|
|
150
|
+
*/
|
|
151
|
+
export async function tiktokAccount(token, deps = {}) {
|
|
152
|
+
const d = withDefaults(deps);
|
|
153
|
+
/** @param {string} fields */
|
|
154
|
+
const read = async fields =>
|
|
155
|
+
(
|
|
156
|
+
await request(
|
|
157
|
+
`${TT}/user/info/?fields=${fields}`,
|
|
158
|
+
{ headers: { authorization: `Bearer ${token}` } },
|
|
159
|
+
"conta do TikTok",
|
|
160
|
+
d,
|
|
161
|
+
)
|
|
162
|
+
).j?.data?.user ?? {};
|
|
163
|
+
let u;
|
|
164
|
+
try {
|
|
165
|
+
u = await read("open_id,avatar_url,display_name,username");
|
|
166
|
+
} catch {
|
|
167
|
+
u = await read("open_id,avatar_url,display_name");
|
|
168
|
+
}
|
|
169
|
+
const username = u.username ? `@${u.username}` : null;
|
|
170
|
+
return {
|
|
171
|
+
account: username ?? u.display_name ?? "conta conectada",
|
|
172
|
+
username,
|
|
173
|
+
name: u.display_name ?? null,
|
|
174
|
+
avatar: u.avatar_url ?? null,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* How the file is split: up to 64 MB in one chunk; above, 10 MB chunks and the last takes the rest.
|
|
180
|
+
* @param {number} size
|
|
181
|
+
*/
|
|
182
|
+
export function tiktokChunks(size) {
|
|
183
|
+
const chunk = size <= 64 * MB ? size : 10 * MB;
|
|
184
|
+
return { chunk, chunks: Math.floor(size / chunk) };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @typedef {object} TiktokSettings publish.tiktok in the config
|
|
189
|
+
* @property {"direct" | "draft"} mode
|
|
190
|
+
* @property {boolean} audited
|
|
191
|
+
* @property {boolean} comments
|
|
192
|
+
* @property {boolean} duet
|
|
193
|
+
* @property {boolean} stitch
|
|
194
|
+
* @property {boolean} ai_content
|
|
195
|
+
* @property {number | null} cover_at_s
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @typedef {{ publish_id: string, privacy: string | null, draft: boolean, username: string | null }} TiktokStarted
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Opens the upload and sends the file; TikTok processes it after. `tiktokUploadStatus` says when it is done
|
|
204
|
+
* (a cloud function asks once per run instead of waiting).
|
|
205
|
+
* @param {{ token: string, bytes: Uint8Array, caption: string, video: { duration: number },
|
|
206
|
+
* requestedPrivacy: string, settings: TiktokSettings } & Deps} p
|
|
207
|
+
* @returns {Promise<TiktokStarted>}
|
|
208
|
+
*/
|
|
209
|
+
export async function startTiktokUpload({ token, bytes, caption, video, requestedPrivacy, settings, ...deps }) {
|
|
210
|
+
const d = withDefaults(deps);
|
|
211
|
+
let draft = settings.mode === "draft";
|
|
212
|
+
const size = bytes.byteLength;
|
|
213
|
+
const { chunk, chunks } = tiktokChunks(size);
|
|
214
|
+
const source_info = { source: "FILE_UPLOAD", video_size: size, chunk_size: chunk, total_chunk_count: chunks };
|
|
215
|
+
|
|
216
|
+
/** @type {string | null} */
|
|
217
|
+
let privacy = null;
|
|
218
|
+
let init;
|
|
219
|
+
if (!draft) {
|
|
220
|
+
const { data: info } = await ttApi(token, "/post/publish/creator_info/query/", {}, "TikTok (conta)", d);
|
|
221
|
+
privacy = requestedPrivacy;
|
|
222
|
+
if (!settings.audited && privacy !== "SELF_ONLY") {
|
|
223
|
+
d.log('TikTok: o app ainda não passou pela auditoria, então o vídeo sobe como "só eu" (publish.tiktok.audited)');
|
|
224
|
+
privacy = "SELF_ONLY";
|
|
225
|
+
}
|
|
226
|
+
const options = info.privacy_level_options ?? [];
|
|
227
|
+
if (options.length && !options.includes(privacy))
|
|
228
|
+
throw new Error(`a conta do TikTok não aceita privacidade ${privacy} (aceita: ${options.join(", ")})`);
|
|
229
|
+
if (info.max_video_post_duration_sec && video.duration > info.max_video_post_duration_sec) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
`a conta do TikTok aceita vídeo de até ${info.max_video_post_duration_sec} s; este tem ${video.duration.toFixed(1)} s`,
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
init = (
|
|
236
|
+
await ttApi(
|
|
237
|
+
token,
|
|
238
|
+
"/post/publish/video/init/",
|
|
239
|
+
{
|
|
240
|
+
post_info: {
|
|
241
|
+
title: caption,
|
|
242
|
+
privacy_level: privacy,
|
|
243
|
+
disable_comment: !settings.comments || !!info.comment_disabled,
|
|
244
|
+
disable_duet: !settings.duet || !!info.duet_disabled,
|
|
245
|
+
disable_stitch: !settings.stitch || !!info.stitch_disabled,
|
|
246
|
+
is_aigc: !!settings.ai_content,
|
|
247
|
+
...(settings.cover_at_s != null
|
|
248
|
+
? { video_cover_timestamp_ms: Math.round(settings.cover_at_s * 1000) }
|
|
249
|
+
: {}),
|
|
250
|
+
},
|
|
251
|
+
source_info,
|
|
252
|
+
},
|
|
253
|
+
"TikTok (abrir envio)",
|
|
254
|
+
d,
|
|
255
|
+
)
|
|
256
|
+
).data;
|
|
257
|
+
} catch (e) {
|
|
258
|
+
/* an unaudited app only posts directly to private accounts: a public account gets a draft */
|
|
259
|
+
if (/** @type {any} */ (e).code !== "unaudited_client_can_only_post_to_private_accounts") throw e;
|
|
260
|
+
d.log(
|
|
261
|
+
"TikTok: app sem auditoria só publica direto em conta privada, e esta é pública. Vai como rascunho para a caixa de entrada do app: termine a postagem lá.",
|
|
262
|
+
);
|
|
263
|
+
draft = true;
|
|
264
|
+
privacy = null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (draft) {
|
|
268
|
+
init = (await ttApi(token, "/post/publish/inbox/video/init/", { source_info }, "TikTok (abrir envio)", d)).data;
|
|
269
|
+
}
|
|
270
|
+
if (!init.publish_id || !init.upload_url)
|
|
271
|
+
throw new Error("TikTok (abrir envio): sem publish_id ou upload_url na resposta");
|
|
272
|
+
|
|
273
|
+
d.log(`TikTok: enviando ${(size / 1e6).toFixed(1)} MB${chunks > 1 ? ` em ${chunks} partes` : ""}…`);
|
|
274
|
+
for (let i = 0; i < chunks; i++) {
|
|
275
|
+
const start = i * chunk;
|
|
276
|
+
const end = i === chunks - 1 ? size - 1 : start + chunk - 1;
|
|
277
|
+
await request(
|
|
278
|
+
init.upload_url,
|
|
279
|
+
{
|
|
280
|
+
method: "PUT",
|
|
281
|
+
headers: { "content-type": "video/mp4", "content-range": `bytes ${start}-${end}/${size}` },
|
|
282
|
+
body: /** @type {any} */ (bytes.subarray(start, end + 1)),
|
|
283
|
+
},
|
|
284
|
+
`TikTok (enviar${chunks > 1 ? ` parte ${i + 1}/${chunks}` : ""})`,
|
|
285
|
+
d,
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
d.log("TikTok: processando o vídeo…");
|
|
290
|
+
let username = null;
|
|
291
|
+
try {
|
|
292
|
+
username = (await tiktokAccount(token, d)).username;
|
|
293
|
+
} catch {
|
|
294
|
+
/* no @, no link */
|
|
295
|
+
}
|
|
296
|
+
return { publish_id: init.publish_id, privacy, draft, username };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* One look at the processing: the result when done, null while TikTok is still on it; throws when refused.
|
|
301
|
+
* @param {{ token: string, started: TiktokStarted } & Deps} p
|
|
302
|
+
*/
|
|
303
|
+
export async function tiktokUploadStatus({ token, started, ...deps }) {
|
|
304
|
+
const d = withDefaults(deps);
|
|
305
|
+
const { data: s, text } = await ttApi(
|
|
306
|
+
token,
|
|
307
|
+
"/post/publish/status/fetch/",
|
|
308
|
+
{ publish_id: started.publish_id },
|
|
309
|
+
"TikTok (status)",
|
|
310
|
+
d,
|
|
311
|
+
);
|
|
312
|
+
if (s.status === "FAILED") throw new Error(`o TikTok recusou o vídeo: ${s.fail_reason ?? "sem motivo"}`);
|
|
313
|
+
if (s.status === "SEND_TO_USER_INBOX") return { id: started.publish_id, url: null, draft: true };
|
|
314
|
+
if (s.status === "PUBLISH_COMPLETE") {
|
|
315
|
+
/* the post id is int64: read from the text, JSON.parse would lose the last digits */
|
|
316
|
+
const post = /"publicaly_available_post_id"\s*:\s*\[\s*"?(\d+)/.exec(text)?.[1] ?? null;
|
|
317
|
+
return {
|
|
318
|
+
id: post ?? started.publish_id,
|
|
319
|
+
publish_id: started.publish_id,
|
|
320
|
+
url: post && started.username ? `https://www.tiktok.com/${started.username}/video/${post}` : null,
|
|
321
|
+
privacy: started.privacy,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Uploads and waits for TikTok to process (the CLI: up to 10 min, a look every 5 s).
|
|
329
|
+
* @param {{ token: string, bytes: Uint8Array, caption: string, video: { duration: number },
|
|
330
|
+
* requestedPrivacy: string, settings: TiktokSettings } & Deps} p
|
|
331
|
+
*/
|
|
332
|
+
export async function uploadTiktok(p) {
|
|
333
|
+
const d = withDefaults(p);
|
|
334
|
+
const started = await startTiktokUpload(p);
|
|
335
|
+
const deadline = d.now() + 10 * 60_000;
|
|
336
|
+
for (;;) {
|
|
337
|
+
const r = await tiktokUploadStatus({ token: p.token, started, ...d });
|
|
338
|
+
if (r) return r;
|
|
339
|
+
if (d.now() > deadline)
|
|
340
|
+
throw new Error(`10 min e o TikTok não terminou de processar (publish_id ${started.publish_id})`);
|
|
341
|
+
await d.sleep(5000);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
YouTube (Data API v3): OAuth token from the stored refresh token, the
|
|
3
|
+
channel, the resumable upload and the custom thumbnail. Pure: the file comes
|
|
4
|
+
in as bytes, the credentials from an injected TokenStore.
|
|
5
|
+
============================================================================ */
|
|
6
|
+
|
|
7
|
+
import { request, withDefaults } from "../http.mjs";
|
|
8
|
+
|
|
9
|
+
/** @typedef {import("../http.mjs").Deps} Deps */
|
|
10
|
+
/** @typedef {import("../http.mjs").TokenStore} TokenStore */
|
|
11
|
+
|
|
12
|
+
export const GOOGLE_AUTH = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
13
|
+
export const GOOGLE_TOKEN = "https://oauth2.googleapis.com/token";
|
|
14
|
+
/* readonly only to show the channel's name and picture in status */
|
|
15
|
+
export const SCOPES = [
|
|
16
|
+
"https://www.googleapis.com/auth/youtube.upload",
|
|
17
|
+
"https://www.googleapis.com/auth/youtube.readonly",
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The OAuth client from the store.
|
|
22
|
+
* @param {TokenStore} store
|
|
23
|
+
*/
|
|
24
|
+
export function googleClient(store) {
|
|
25
|
+
const id = store.get("YOUTUBE_CLIENT_ID"),
|
|
26
|
+
secret = store.get("YOUTUBE_CLIENT_SECRET");
|
|
27
|
+
if (!id || !secret)
|
|
28
|
+
throw new Error("faltam YOUTUBE_CLIENT_ID e YOUTUBE_CLIENT_SECRET no .env (reference/publish.md, YouTube passo 1)");
|
|
29
|
+
return { id, secret };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A fresh access token from the stored refresh token (Google's last ~1 h, so it is always fetched).
|
|
34
|
+
* @param {{ store: TokenStore } & Deps} p
|
|
35
|
+
* @returns {Promise<string>}
|
|
36
|
+
*/
|
|
37
|
+
export async function youtubeAccessToken({ store, ...deps }) {
|
|
38
|
+
const { id, secret } = googleClient(store);
|
|
39
|
+
const refresh = store.get("YOUTUBE_REFRESH_TOKEN");
|
|
40
|
+
if (!refresh) throw new Error("YouTube não conectado: rode node tools/publish.mjs auth youtube");
|
|
41
|
+
try {
|
|
42
|
+
const { j } = await request(
|
|
43
|
+
GOOGLE_TOKEN,
|
|
44
|
+
{
|
|
45
|
+
method: "POST",
|
|
46
|
+
body: new URLSearchParams({
|
|
47
|
+
client_id: id,
|
|
48
|
+
client_secret: secret,
|
|
49
|
+
refresh_token: refresh,
|
|
50
|
+
grant_type: "refresh_token",
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
"token do YouTube",
|
|
54
|
+
withDefaults(deps),
|
|
55
|
+
);
|
|
56
|
+
return j.access_token;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
if (/invalid_grant|expired|revoked/i.test(/** @type {Error} */ (e).message))
|
|
59
|
+
throw new Error("o login do YouTube venceu ou foi revogado: rode node tools/publish.mjs auth youtube de novo");
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The consent URL for the desktop login (PKCE S256).
|
|
66
|
+
* @param {{ clientId: string, redirect: string, state: string, challenge: string }} p
|
|
67
|
+
*/
|
|
68
|
+
export const youtubeAuthUrl = ({ clientId, redirect, state, challenge }) =>
|
|
69
|
+
`${GOOGLE_AUTH}?${new URLSearchParams({
|
|
70
|
+
client_id: clientId,
|
|
71
|
+
redirect_uri: redirect,
|
|
72
|
+
response_type: "code",
|
|
73
|
+
scope: SCOPES.join(" "),
|
|
74
|
+
access_type: "offline",
|
|
75
|
+
prompt: "consent",
|
|
76
|
+
state,
|
|
77
|
+
code_challenge: challenge,
|
|
78
|
+
code_challenge_method: "S256",
|
|
79
|
+
})}`;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Exchanges the login code for tokens.
|
|
83
|
+
* @param {{ clientId: string, secret: string, code: string, redirect: string, verifier: string } & Deps} p
|
|
84
|
+
* @returns {Promise<{ access_token: string, refresh_token?: string }>}
|
|
85
|
+
*/
|
|
86
|
+
export async function exchangeGoogleCode({ clientId, secret, code, redirect, verifier, ...deps }) {
|
|
87
|
+
const { j } = await request(
|
|
88
|
+
GOOGLE_TOKEN,
|
|
89
|
+
{
|
|
90
|
+
method: "POST",
|
|
91
|
+
body: new URLSearchParams({
|
|
92
|
+
code,
|
|
93
|
+
client_id: clientId,
|
|
94
|
+
client_secret: secret,
|
|
95
|
+
redirect_uri: redirect,
|
|
96
|
+
grant_type: "authorization_code",
|
|
97
|
+
code_verifier: verifier,
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
"token do Google",
|
|
101
|
+
withDefaults(deps),
|
|
102
|
+
);
|
|
103
|
+
return j;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The channel: `account` is the text line; the rest is the studio card.
|
|
108
|
+
* @param {string} token
|
|
109
|
+
* @param {Deps} [deps]
|
|
110
|
+
* @returns {Promise<{ account: string, username: string | null, name: string, avatar: string | null }>}
|
|
111
|
+
*/
|
|
112
|
+
export async function youtubeChannel(token, deps = {}) {
|
|
113
|
+
const { j } = await request(
|
|
114
|
+
"https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true",
|
|
115
|
+
{ headers: { authorization: `Bearer ${token}` } },
|
|
116
|
+
"canal do YouTube",
|
|
117
|
+
withDefaults(deps),
|
|
118
|
+
);
|
|
119
|
+
const c = j.items?.[0];
|
|
120
|
+
if (!c) throw new Error("esta conta do Google não tem canal no YouTube");
|
|
121
|
+
const s = c.snippet;
|
|
122
|
+
const t = s.thumbnails ?? {};
|
|
123
|
+
return {
|
|
124
|
+
account: s.customUrl ? `${s.title} (${s.customUrl})` : s.title,
|
|
125
|
+
username: s.customUrl ?? null,
|
|
126
|
+
name: s.title,
|
|
127
|
+
avatar: (t.default ?? t.medium ?? t.high)?.url ?? null,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Up to 3 min in 9:16 YouTube treats it as a Short.
|
|
133
|
+
* @param {{ w: number, h: number, duration: number }} video
|
|
134
|
+
*/
|
|
135
|
+
export const isShort = video => video.h > video.w && video.duration <= 180;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* thumbnails.set: the channel needs advanced features (phone verification). Never throws.
|
|
139
|
+
* @param {{ token: string, videoId: string, jpeg: Uint8Array, version: string } & Deps} p
|
|
140
|
+
* @returns {Promise<{ version: string, applied: boolean, error?: string }>}
|
|
141
|
+
*/
|
|
142
|
+
export async function setYoutubeThumbnail({ token, videoId, jpeg, version, ...deps }) {
|
|
143
|
+
try {
|
|
144
|
+
await request(
|
|
145
|
+
`https://www.googleapis.com/upload/youtube/v3/thumbnails/set?videoId=${videoId}`,
|
|
146
|
+
{
|
|
147
|
+
method: "POST",
|
|
148
|
+
headers: { authorization: `Bearer ${token}`, "content-type": "image/jpeg" },
|
|
149
|
+
body: /** @type {any} */ (jpeg),
|
|
150
|
+
},
|
|
151
|
+
"YouTube (capa)",
|
|
152
|
+
withDefaults(deps),
|
|
153
|
+
);
|
|
154
|
+
return { version, applied: true };
|
|
155
|
+
} catch (e) {
|
|
156
|
+
const msg = /** @type {Error} */ (e).message;
|
|
157
|
+
const reason = /403|forbidden/i.test(msg)
|
|
158
|
+
? `${msg} (o canal precisa dos recursos avançados para capa própria: youtube.com/verify)`
|
|
159
|
+
: msg;
|
|
160
|
+
return { version, applied: false, error: reason };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @typedef {object} YoutubeSettings publish.youtube in the config
|
|
166
|
+
* @property {string | number} category
|
|
167
|
+
* @property {string} language
|
|
168
|
+
* @property {boolean} made_for_kids
|
|
169
|
+
* @property {boolean} synthetic_content
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The resumable upload: the first call opens the session, the second sends the file.
|
|
174
|
+
* @param {{ token: string, bytes: Uint8Array, meta: { title: string, description: string, tags: string[] },
|
|
175
|
+
* privacy: string, video: { w: number, h: number, duration: number }, settings: YoutubeSettings,
|
|
176
|
+
* cover?: { version: string, jpeg: Uint8Array } | null } & Deps} p
|
|
177
|
+
*/
|
|
178
|
+
export async function uploadYoutube({ token, bytes, meta, privacy, video, settings, cover, ...deps }) {
|
|
179
|
+
const d = withDefaults(deps);
|
|
180
|
+
const body = {
|
|
181
|
+
snippet: {
|
|
182
|
+
title: meta.title,
|
|
183
|
+
description: meta.description,
|
|
184
|
+
categoryId: String(settings.category),
|
|
185
|
+
defaultLanguage: settings.language,
|
|
186
|
+
defaultAudioLanguage: settings.language,
|
|
187
|
+
...(meta.tags.length ? { tags: meta.tags } : {}),
|
|
188
|
+
},
|
|
189
|
+
status: {
|
|
190
|
+
privacyStatus: privacy,
|
|
191
|
+
selfDeclaredMadeForKids: !!settings.made_for_kids,
|
|
192
|
+
...(settings.synthetic_content ? { containsSyntheticMedia: true } : {}),
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
const { r } = await request(
|
|
196
|
+
"https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status",
|
|
197
|
+
{
|
|
198
|
+
method: "POST",
|
|
199
|
+
headers: {
|
|
200
|
+
authorization: `Bearer ${token}`,
|
|
201
|
+
"content-type": "application/json; charset=UTF-8",
|
|
202
|
+
"x-upload-content-type": "video/mp4",
|
|
203
|
+
"x-upload-content-length": String(bytes.byteLength),
|
|
204
|
+
},
|
|
205
|
+
body: JSON.stringify(body),
|
|
206
|
+
},
|
|
207
|
+
"YouTube (abrir upload)",
|
|
208
|
+
d,
|
|
209
|
+
);
|
|
210
|
+
const session = r.headers.get("location");
|
|
211
|
+
if (!session) throw new Error("YouTube (abrir upload): sem Location na resposta");
|
|
212
|
+
d.log(`YouTube: enviando ${(bytes.byteLength / 1e6).toFixed(1)} MB…`);
|
|
213
|
+
const { j } = await request(
|
|
214
|
+
session,
|
|
215
|
+
{ method: "PUT", headers: { "content-type": "video/mp4" }, body: /** @type {any} */ (bytes) },
|
|
216
|
+
"YouTube (enviar)",
|
|
217
|
+
d,
|
|
218
|
+
);
|
|
219
|
+
return {
|
|
220
|
+
id: j.id,
|
|
221
|
+
url: isShort(video) ? `https://youtube.com/shorts/${j.id}` : `https://youtu.be/${j.id}`,
|
|
222
|
+
studio: `https://studio.youtube.com/video/${j.id}/edit`,
|
|
223
|
+
privacy: j.status?.privacyStatus ?? privacy,
|
|
224
|
+
...(cover
|
|
225
|
+
? { cover: await setYoutubeThumbnail({ token, videoId: j.id, jpeg: cover.jpeg, version: cover.version, ...d }) }
|
|
226
|
+
: {}),
|
|
227
|
+
};
|
|
228
|
+
}
|