Hi @dzg,
To accomplish this, you can create a Pipedream workflow with a trigger of your choice (e.g., an HTTP trigger or a scheduled trigger). In the workflow, you can use the Pexels API to fetch the videos from your collection and compare them with the previously fetched videos to identify the new ones. Then, you can take action on the new videos as needed.
Here’s an example Pipedream component that fetches videos from the Pexels API:
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
pexels: {
type: "app",
app: "pexels",
},
collectionId: {
type: "string",
label: "Collection ID",
},
},
async run({ steps, $ }) {
const response = await axios($, {
url: `https://api.pexels.com/v1/collections/${this.collectionId}`,
headers: {
"Authorization": `${this.pexels.$auth.api_key}`,
},
});
const videos = response.data.videos;
return videos;
},
});
To check for new items, you can store the fetched videos in a Pipedream key-value store using this.$checkpoint
. You can then compare the stored videos with the newly fetched videos to identify the new ones.
For example, after fetching the videos, you can add the following code to the run
method:
const previousVideos = this.$checkpoint("videos") || [];
const newVideos = videos.filter(
(video) => !previousVideos.some((prevVideo) => prevVideo.id === video.id)
);
// Take action on new videos here
// Update the checkpoint with the latest videos
this.$checkpoint("videos", videos);
This code checks for new videos and takes action on them. After that, it updates the checkpoint with the latest videos.
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.