Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(YouTube Node): Fix Date filters #10725

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
} from 'n8n-workflow';
import { NodeConnectionType, BINARY_ENCODING, NodeOperationError } from 'n8n-workflow';

import { DateTime } from 'luxon';
import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions';

import { channelFields, channelOperations } from './ChannelDescription';
Expand Down Expand Up @@ -762,6 +763,28 @@ export class YouTube implements INodeType {
qs.type = 'video';

qs.forMine = true;
if (filters.publishedAfter) {
const publishedAfter = DateTime.fromISO(filters.publishedAfter as string);
if (publishedAfter.isValid) {
filters.publishedAfter = publishedAfter.setZone(this.getTimezone()).toISO();
} else {
throw new NodeOperationError(
this.getNode(),
`The value "${filters.publishedAfter as string}" is not a valid DateTime.`,
);
}
}
if (filters.publishedBefore) {
const publishedBefore = DateTime.fromISO(filters.publishedBefore as string);
if (publishedBefore.isValid) {
filters.publishedAfter = publishedBefore.setZone(this.getTimezone()).toISO();
} else {
throw new NodeOperationError(
this.getNode(),
`The value "${filters.publishedBefore as string}" is not a valid DateTime.`,
);
}
}

Object.assign(qs, options, filters);

Expand Down
Loading