Unable to get the correct "Publish date" from the original YouTube video
I have a simple zap: whenever I put a youtube video on a given playlist, the zap creates a row in google sheet with info relevant to that video: title, link, date published and chanel name. It turns out that the Publish Date I get is the date I put the video on my playlist and not the date when the creators published their videos. See the screenshot.
How do I get “the right publish date”? I mean the original date of publishing the video?
ok Thank you! Let us see if anyone has another suggestion.
@Wojtek108
Can you post screenshots with how your Zap steps are configured to make sure we have full context?
Here you go:
thank you!
I got around the problem by making a macro in google sheets and running it manually on and off. It gives me what I want but it is a semi-automatic solution.
Hi there @Wojtek108!
I did some checking and according to YouTube’s API the Published At value is supposed to be the date the video was added to the playlist, not when the video itself was published:
Glad you were able to come up with a workaround here. I’m not sure what the macro is doing exactly but the only other workaround I could think of would be to:
Set up another Zap that uses a New Video In Channel (YouTube) trigger - which should give the date and time the video was actually published (not when it was added to a specific playlist).
In that Zap, you’d record information for the videos in another Google Sheets spreadsheet using a Create Spreadsheet Row (Google Sheets) action.
Then in your current Zap, you’d use a Lookup Spreadsheet Row (Google Sheets) action to search for that video to retrieve the desired publish date (from the new spreadsheet) and add that into the spreadsheet to record the correct publish date.
If you decide to give that suggested workaround a try and run into any trouble let us know. Happy to help further!
Hey @SamB!
Thank you for taking the time and looking into the matter. The thing is that I put on my playlist videos from different channels, so it does not make sens to set up a zap for every channel I run into and find interesting.
Thanks again for going to trouble. I appreciate it!
Apologies for missing your reply here previously, @Wojtek108!
Ah I see! Sorry to hear the alternative workaround I suggested won’t be suitable for your use case here. Seems like sticking with your current semi-automated workaround may be the best way forward for now.
That said, it may also be worth reaching out to YouTube and the Zapier Support team to request that a feature request be opened to also have the date the video was published not just the date the video was added to the playlist. Although it’s not currently possible with YouTube’s API, at least it would make them aware of the need for this and allow us to track user interest.
I got around the problem by making a macro in google sheets and running it manually on and off. It gives me what I want but it is a semi-automatic solution.
can you post the macro?
Here you go. You have to though get the indentation right. As I pasted the script, it all got messed up and aligned to the left. But you get the point. Use chatgpt to help you along.
function fetchYouTubeVideoPublishedDate(videoId) {
var apiKey = 'xxxxx'; // Replace with your actual API key
var apiUrl = 'https://www.googleapis.com/youtube/v3/videos?id=' + videoId + '&part=snippet&key=' + apiKey;
try {
var response = UrlFetchApp.fetch(apiUrl);
var data = JSON.parse(response.getContentText());
if (data.items && data.items.length > 0) {
var publishedDate = data.itemse0].snippet.publishedAt;
return publishedDate;
} else {
return 'Video not found';
}
} catch (error) {
return 'Error fetching video data';
}
}
function pasteVideoPublishedDateToSheet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var selectedRow = sheet.getActiveRange().getRow();
var videoId = sheet.getRange(selectedRow, 5).getValue();
var publishedDate = fetchYouTubeVideoPublishedDate(videoId);
var columnToPaste = 6; // Change this to the desired column index