I am using “YouTube (Data API)” selecting new posts by channel ID.
I build the data I want and send to a FB Group. this part is all working.
But I only want normal videos. I want to exclude Shorts.
I don’t see anything in the parsed data that differentiates normal video from shorts.
I could see video length or aspect ratio or if there was something that specifically categorized “shorts”.
To exclude YouTube Shorts from your workflow, you can use the video’s duration or aspect ratio as a filter since Shorts are typically less than 60 seconds long and have a vertical aspect ratio. Unfortunately, the YouTube Data API does not provide a direct flag to differentiate Shorts from regular videos, but these properties can be a good proxy.
Here’s a general approach using Pipedream’s Node.js code step:
Use the “New Videos by Channel ID” trigger from the YouTube Data API to initiate your workflow.
Add a Node.js code step after the trigger to check the video’s duration and aspect ratio.
Use the YouTube Data API to get additional details about the video if necessary.
If the video does not meet the criteria for a Short, send the data to the FB Group.
Below is an example of a Node.js code step that you might include in your Pipedream workflow to filter out Shorts:
export default defineComponent({
async run({ steps, $ }) {
// Assume `steps.trigger.event` contains the data from the YouTube trigger
const video = steps.trigger.event;
// Check if the video duration is available and parse it
// You will need to adjust the logic to extract and parse the duration from your specific trigger data
const duration = parseDuration(video.contentDetails.duration);
// Define the maximum duration for a Short (e.g., 60 seconds)
const maxShortDuration = 60;
// Check if the aspect ratio is vertical (e.g., height is greater than width)
// You will need to adjust the logic to extract the width and height from your specific trigger data
const isVertical = video.snippet.thumbnails.default.height > video.snippet.thumbnails.default.width;
// If the video is longer than the max duration for Shorts or is not vertical, it's not a Short
if (duration > maxShortDuration || !isVertical) {
// Send the video data to the FB Group
// Replace this with your logic to send data to the FB Group
await sendToFBGroup(video);
} else {
// It's a Short, so we do nothing
console.log(`Video ${video.id} is a Short and has been excluded.`);
}
},
});
// Helper function to parse ISO 8601 duration (you will need to implement this)
function parseDuration(isoDuration) {
// Implement
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! [Learn how to build your own.](https://pipedream.com/blog/using-the-new-openai-actions-in-pipedream/)
Thanks, this looks like what Ill need. But when I add and test it I get error (which is complaining about the apostrophe in I’m on the last line):
Code Error
Unexpected character ‘’’ (32:3)
DETAILS
SyntaxError: Unexpected character '’' (32:3)
at pp$4.raise (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:2927:15)
at pp$9.getTokenFromCode (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:4708:10)
at anonymous.getTokenFromCode (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn-node/lib/private-class-elements/index.js:83:48)
at pp$9.readToken (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:4409:17)
at pp$9.nextToken (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:4400:17)
at pp$9.next (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:4357:10)
at pp$3.parseIdent (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:2880:10)
at anonymous.parseIdent (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn-node/lib/class-fields/index.js:67:47)
at anonymous.parseIdent (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn-node/lib/static-class-features/index.js:86:55)
at pp$3.parseExprAtom (/var/task/node_modules/@lambda-v2/builder-helpers/node_modules/acorn/dist/acorn.js:2254:21)