What I'm trying to do
I want to automatically upload a video my code generates every day to my YouTube channel. It should upload the video file and add the thumbnail.
What goes wrong
When I let my code upload the video, the video plays fine and everything works, but there's a restriction on the video that causes it to be locked on private. No further information is given and appealing is not possible. I've tried uploading as unlisted after which everything seems fine. However, when I manually set it to public, even after waiting 12 hours, the video is locked on private yet again.
Video illustrating the issue:
How do avoid this issue and make sure people can see the video? I can't find anything that would be against the terms and policies of YouTube. When I upload the exact same video manually, everything works fine.
My code
I'm using the google-api-nodejs-client with OAuth2. I generated the authentication URL with:
const authUrl = oauth2Client.generateAuthUrl({ access_type: "offline", scope: ["https://www.googleapis.com/auth/youtube","https://www.googleapis.com/auth/youtube.upload","https://www.googleapis.com/auth/youtube.readonly" ];});
Code for uploading video:
youtube.videos.insert( { auth: auth, part: "snippet,contentDetails,status", resource: { snippet: { title: "Title goes here", description: "Description goes here", tags: ["tags", "go", "here"], }, status: { privacyStatus: "private", selfDeclaredMadeForKids: false, }, }, media: { body: fs.createReadStream("./video.avi"), }, }, async (error, data) => { if (error) return reject(error); });
Code for changing the thumbnail:
youtube.thumbnails.set( { auth: auth, videoId: videoId, media: { mimeType: "image/jpeg", body: fs.readFileSync(`./thumbnail.png`) }, }, (err, thumbResponse) => { if (err) { console.log("Error response"); console.log(err); } console.log(thumbResponse); });