I'm trying to write a script that would automate the scheduling of uploaded videos on youtube. they are already uploaded and currently in draft mode.
however, when I get to the point when I need to change the date value, I'm just not able to exactly get this date field for some reason. Upon checking, the id of the input value increments everytime you close and open it. it appears to be dynamic. it will show the id as input-22 now, but when you close the date selector dropdown, the date input field's ID will become input-23
here's my script so far
(async function() {
console.log(" Starting draft video scheduling...");
// Find draft videos (videos with "Draft" label)
// const drafts = document.querySelectorAll('ytcp-video-row[status="DRAFT"]');
const drafts = document.querySelectorAll('ytcp-video-row');
if (drafts.length === 0) {
console.log("No draft videos found!");
return;
}
console.log("Found ${drafts.length} draft(s). Selecting the first one...");
// Click the first draft video to edit
console.log(1)
drafts[0].querySelector("#video-title").click();
// Wait for the details page to load
console.log(2)
await new Promise(resolve => setTimeout(resolve, 2000));
// Click "Visibility" settings button
console.log(3)
document.querySelector("#step-badge-3").click();
await new Promise(resolve => setTimeout(resolve, 1000));
// Select "Schedule"
console.log(4)
document.querySelector('#second-container-expand-button').click();
await new Promise(resolve => setTimeout(resolve, 500));
// Open date picker
console.log(5);
document.querySelector("#datepicker-trigger").click();
await new Promise(resolve => setTimeout(resolve, 1000));
// Set the scheduled date
console.log(6);
const scheduleDate = "February 10, 2025"; // Change this to your desired date
console.log(6.1);
document.querySelector("input.style-scope.tp-yt-paper-input").value = scheduleDate;
console.log('schedule date assigned new value, now displaying again')
console.log(document.querySelector("input.style-scope.tp-yt-paper-input").value)
})();
I tried implementing something using the youtube API for the credits for a free user gets used up after a couple of tries so I'm doing this instead