feat(youtube): add new video in channel trigger
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Youtube',
|
||||
@@ -13,4 +14,5 @@ export default defineApp({
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
});
|
||||
|
3
packages/backend/src/apps/youtube/triggers/index.ts
Normal file
3
packages/backend/src/apps/youtube/triggers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import newVideoInChannel from './new-video-in-channel';
|
||||
|
||||
export default [newVideoInChannel];
|
@@ -0,0 +1,48 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New video in channel',
|
||||
key: 'newVideoInChannel',
|
||||
description:
|
||||
'Triggers when a new video is published to a specific Youtube channel.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Channel ID',
|
||||
key: 'channelId',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description:
|
||||
'Get the new videos uploaded to this channel. If the URL of the youtube channel looks like this www.youtube.com/channel/UCbxb2fqe9oNgglAoYqsYOtQ then you must use UCbxb2fqe9oNgglAoYqsYOtQ as a value in this field.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const channelId = $.step.parameters.channelId as string;
|
||||
|
||||
const params = {
|
||||
pageToken: undefined as unknown as string,
|
||||
part: 'snippet',
|
||||
channelId: channelId,
|
||||
maxResults: 50,
|
||||
order: 'date',
|
||||
type: 'video',
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get('/v3/search', { params });
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (data?.items?.length) {
|
||||
for (const item of data.items) {
|
||||
$.pushTriggerItem({
|
||||
raw: item,
|
||||
meta: {
|
||||
internalId: item.etag,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.pageToken);
|
||||
},
|
||||
});
|
@@ -415,7 +415,10 @@ export default defineConfig({
|
||||
text: 'Youtube',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/youtube/connection' }],
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/youtube/triggers' },
|
||||
{ text: 'Connection', link: '/apps/youtube/connection' },
|
||||
],
|
||||
},
|
||||
],
|
||||
'/': [
|
||||
|
12
packages/docs/pages/apps/youtube/triggers.md
Normal file
12
packages/docs/pages/apps/youtube/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/youtube.svg
|
||||
items:
|
||||
- name: New video in channel
|
||||
desc: Triggers when a new video is published to a specific Youtube channel.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -43,3 +43,4 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Typeform](/apps/typeform/triggers)
|
||||
- [Webhooks](/apps/webhooks/triggers)
|
||||
- [WordPress](/apps/wordpress/triggers)
|
||||
- [Youtube](/apps/youtube/triggers)
|
||||
|
Reference in New Issue
Block a user