File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ CRON_SECRET= # Secret for authenticating cron job re
5656# YouTube integration
5757YOUTUBE_API_KEY = # YouTube Data API v3 key
5858YOUTUBE_CHANNEL_ID = # YouTube channel ID to fetch videos from
59+ YOUTUBE_UPLOAD_VISIBILITY = # YouTube upload privacy: "public", "private", or "unlisted" (default: "private")
5960
6061# Vercel
6162VERCEL_PROJECT_PRODUCTION_URL = # Production URL (auto-set by Vercel)
Original file line number Diff line number Diff line change @@ -10,6 +10,14 @@ oauth2Client.setCredentials({
1010
1111const youtube = google . youtube ( { version : "v3" , auth : oauth2Client } ) ;
1212
13+ function getDefaultPrivacyStatus ( ) : "public" | "private" | "unlisted" {
14+ const envValue = process . env . YOUTUBE_UPLOAD_VISIBILITY ?. toLowerCase ( ) ;
15+ if ( envValue === "public" || envValue === "private" || envValue === "unlisted" ) {
16+ return envValue ;
17+ }
18+ return "private" ; // Default to private when not set
19+ }
20+
1321interface UploadOptions {
1422 title : string ;
1523 description : string ;
@@ -27,6 +35,9 @@ export async function uploadVideo(opts: UploadOptions): Promise<{ videoId: strin
2735 const response = await fetch ( opts . videoUrl ) ;
2836 if ( ! response . ok ) throw new Error ( `Failed to fetch video: ${ response . statusText } ` ) ;
2937
38+ const resolvedPrivacyStatus = opts . privacyStatus || getDefaultPrivacyStatus ( ) ;
39+ console . log ( `[youtube-upload] Uploading "${ opts . title . slice ( 0 , 60 ) } " with privacy: ${ resolvedPrivacyStatus } ` ) ;
40+
3041 const res = await youtube . videos . insert ( {
3142 part : [ "snippet" , "status" ] ,
3243 requestBody : {
@@ -38,7 +49,7 @@ export async function uploadVideo(opts: UploadOptions): Promise<{ videoId: strin
3849 defaultLanguage : "en" ,
3950 } ,
4051 status : {
41- privacyStatus : opts . privacyStatus || "public" ,
52+ privacyStatus : resolvedPrivacyStatus ,
4253 selfDeclaredMadeForKids : opts . madeForKids ?? false ,
4354 } ,
4455 } ,
You can’t perform that action at this time.
0 commit comments