Improvements

This commit is contained in:
ricardo 2020-08-11 16:07:23 -04:00
parent 1e81b7d54f
commit 8c24858f99
5 changed files with 515 additions and 156 deletions

View file

@ -15,6 +15,11 @@ export const channelOperations = [
}, },
}, },
options: [ options: [
{
name: 'Get',
value: 'get',
description: 'Retrieve a channel',
},
{ {
name: 'Get All', name: 'Get All',
value: 'getAll', value: 'getAll',
@ -45,10 +50,6 @@ export const channelFields = [
name: 'part', name: 'part',
type: 'multiOptions', type: 'multiOptions',
options: [ options: [
{
name: 'Audit Details',
value: 'auditDetails',
},
{ {
name: 'Branding Settings', name: 'Branding Settings',
value: 'brandingSettings', value: 'brandingSettings',
@ -186,13 +187,6 @@ export const channelFields = [
default: false, default: false,
description: `Set this parameter's value to true to instruct the API to only return channels managed by the content owner that the onBehalfOfContentOwner parameter specifies`, description: `Set this parameter's value to true to instruct the API to only return channels managed by the content owner that the onBehalfOfContentOwner parameter specifies`,
}, },
{
displayName: 'Mine',
name: 'mine',
type: 'boolean',
default: false,
description: `This parameter can only be used in a properly authorized request. Set this parameter's value to true to instruct the API to only return channels owned by the authenticated user.`,
},
], ],
}, },
{ {
@ -232,6 +226,82 @@ export const channelFields = [
], ],
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* channel:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Channel ID',
name: 'channelId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'channel',
],
},
},
default: '',
},
{
displayName: 'Fields',
name: 'part',
type: 'multiOptions',
options: [
{
name: 'Branding Settings',
value: 'brandingSettings',
},
{
name: 'Content Details',
value: 'contentDetails',
},
{
name: 'Content Owner Details',
value: 'contentOwnerDetails',
},
{
name: 'ID',
value: 'id',
},
{
name: 'Localizations',
value: 'localizations',
},
{
name: 'Snippet',
value: 'snippet',
},
{
name: 'Statistics',
value: 'statistics',
},
{
name: 'Status',
value: 'status',
},
{
name: 'Topic Details',
value: 'topicDetails',
},
],
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'channel',
],
},
},
description: 'The fields parameter specifies a comma-separated list of one or more channel resource properties that the API response will include.',
default: ''
},
/* -------------------------------------------------------------------------- */
/* channel:update */ /* channel:update */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {

View file

@ -25,6 +25,11 @@ export const playlistOperations = [
value: 'delete', value: 'delete',
description: 'Delete a playlist', description: 'Delete a playlist',
}, },
{
name: 'Get',
value: 'get',
description: 'Get a playlist',
},
{ {
name: 'Get All', name: 'Get All',
value: 'getAll', value: 'getAll',
@ -118,7 +123,10 @@ export const playlistFields = [
{ {
displayName: 'Default Language', displayName: 'Default Language',
name: 'defaultLanguage', name: 'defaultLanguage',
type: 'string', type: 'options',
typeOptions: {
loadOptionsMethod: 'getLanguages',
},
default: '', default: '',
description: `The language of the text in the playlist resource's title and description properties.`, description: `The language of the text in the playlist resource's title and description properties.`,
}, },
@ -141,6 +149,104 @@ export const playlistFields = [
], ],
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* playlist:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Playlist ID',
name: 'playlistId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'playlist',
],
},
},
default: '',
},
{
displayName: 'Fields',
name: 'part',
type: 'multiOptions',
options: [
{
name: 'Content Details',
value: 'contentDetails',
},
{
name: 'ID',
value: 'id',
},
{
name: 'Localizations',
value: 'localizations',
},
{
name: 'Player',
value: 'player',
},
{
name: 'Snippet',
value: 'snippet',
},
{
name: 'Status',
value: 'status',
},
],
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'playlist',
],
},
},
description: 'The fields parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include.',
default: ''
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'playlist',
],
},
},
options: [
{
displayName: 'On Behalf Of Content Owner',
name: 'onBehalfOfContentOwner',
type: 'string',
default: '',
description: `The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify<br>
a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value`,
},
{
displayName: 'On Behalf Of Content Owner Channel',
name: 'onBehalfOfContentOwnerChannel',
type: 'string',
default: '',
description: `The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added`,
},
],
},
/* -------------------------------------------------------------------------- */
/* playlist:delete */ /* playlist:delete */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
@ -306,13 +412,6 @@ export const playlistFields = [
default: '', default: '',
description: `The id parameter specifies a comma-separated list of the YouTube playlist ID(s) for the resource(s) that are being retrieved. In a playlist resource, the id property specifies the playlist's YouTube playlist ID.`, description: `The id parameter specifies a comma-separated list of the YouTube playlist ID(s) for the resource(s) that are being retrieved. In a playlist resource, the id property specifies the playlist's YouTube playlist ID.`,
}, },
{
displayName: 'Mine',
name: 'mine',
type: 'boolean',
default: false,
description: `Set this parameter's value to true to instruct the API to only return playlists owned by the authenticated user.`,
},
], ],
}, },
{ {
@ -371,6 +470,24 @@ export const playlistFields = [
default: '', default: '',
description: `The playlist's title.`, description: `The playlist's title.`,
}, },
{
displayName: 'Title',
name: 'title',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'playlist',
],
},
},
default: '',
description: `The playlist's title.`,
},
{ {
displayName: 'Update Fields', displayName: 'Update Fields',
name: 'updateFields', name: 'updateFields',
@ -388,6 +505,16 @@ export const playlistFields = [
}, },
}, },
options: [ options: [
{
displayName: 'Default Language',
name: 'defaultLanguage',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getLanguages',
},
default: '',
description: `The language of the text in the playlist resource's title and description properties.`,
},
{ {
displayName: 'Description', displayName: 'Description',
name: 'description', name: 'description',
@ -395,6 +522,14 @@ export const playlistFields = [
default: '', default: '',
description: `The playlist's description.`, description: `The playlist's description.`,
}, },
{
displayName: 'On Behalf Of Content Owner',
name: 'onBehalfOfContentOwner',
type: 'string',
default: '',
description: `The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify<br>
a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value`,
},
{ {
displayName: 'Privacy Status', displayName: 'Privacy Status',
name: 'privacyStatus', name: 'privacyStatus',
@ -423,27 +558,6 @@ export const playlistFields = [
default: '', default: '',
description: `Keyword tags associated with the playlist. Mulplie can be defined separated by comma`, description: `Keyword tags associated with the playlist. Mulplie can be defined separated by comma`,
}, },
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
},
{
displayName: 'Default Language',
name: 'defaultLanguage',
type: 'string',
default: '',
description: `The language of the text in the playlist resource's title and description properties.`,
},
{
displayName: 'On Behalf Of Content Owner',
name: 'onBehalfOfContentOwner',
type: 'string',
default: '',
description: `The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify<br>
a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value`,
},
], ],
}, },
] as INodeProperties[]; ] as INodeProperties[];

View file

@ -0,0 +1,95 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const videoCategoryOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'videoCategory',
],
},
},
options: [
{
name: 'Get All',
value: 'getAll',
description: 'Retrieve all video categories',
},
],
default: 'getAll',
description: 'The operation to perform.'
}
] as INodeProperties[];
export const videoCategoryFields = [
/* -------------------------------------------------------------------------- */
/* videoCategory:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Region Code',
name: 'regionCode',
type: 'options',
required: true,
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'videoCategory',
],
},
},
typeOptions: {
loadOptionsMethod: 'getCountriesCodes',
},
default: '',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'videoCategory',
],
},
},
default: false,
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'videoCategory',
],
returnAll: [
false,
],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'How many results to return.',
},
] as INodeProperties[];

View file

@ -73,8 +73,8 @@ export const videoFields = [
default: '', default: '',
}, },
{ {
displayName: 'Country Code', displayName: 'Region Code',
name: 'countryCode', name: 'regionCode',
type: 'options', type: 'options',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getCountriesCodes', loadOptionsMethod: 'getCountriesCodes',
@ -98,7 +98,7 @@ export const videoFields = [
typeOptions: { typeOptions: {
loadOptionsMethod: 'getVideoCategories', loadOptionsMethod: 'getVideoCategories',
loadOptionsDependsOn: [ loadOptionsDependsOn: [
'countryCode', 'regionCode',
], ],
}, },
displayOptions: { displayOptions: {
@ -150,7 +150,10 @@ export const videoFields = [
{ {
displayName: 'Default Language', displayName: 'Default Language',
name: 'defaultLanguage', name: 'defaultLanguage',
type: 'string', type: 'options',
typeOptions: {
loadOptionsMethod: 'getLanguages',
},
default: '', default: '',
description: `The language of the text in the playlist resource's title and description properties.`, description: `The language of the text in the playlist resource's title and description properties.`,
}, },
@ -182,7 +185,7 @@ export const videoFields = [
value: 'youtube', value: 'youtube',
}, },
], ],
default: false, default: '',
description: `The video's license.`, description: `The video's license.`,
}, },
{ {
@ -326,10 +329,6 @@ export const videoFields = [
name: 'Content Details', name: 'Content Details',
value: 'contentDetails', value: 'contentDetails',
}, },
{
name: 'Field Details',
value: 'fieldDetails',
},
{ {
name: 'ID', name: 'ID',
value: 'id', value: 'id',
@ -346,10 +345,6 @@ export const videoFields = [
name: 'Player', name: 'Player',
value: 'player', value: 'player',
}, },
{
name: 'Processing Details',
value: 'processingDetails',
},
{ {
name: 'Recording Details', name: 'Recording Details',
value: 'recordingDetails', value: 'recordingDetails',
@ -428,10 +423,6 @@ export const videoFields = [
name: 'Content Details', name: 'Content Details',
value: 'contentDetails', value: 'contentDetails',
}, },
{
name: 'File Details',
value: 'fileDetails',
},
{ {
name: 'ID', name: 'ID',
value: 'id', value: 'id',
@ -448,10 +439,6 @@ export const videoFields = [
name: 'Player', name: 'Player',
value: 'player', value: 'player',
}, },
{
name: 'Processing Details',
value: 'processingDetails',
},
{ {
name: 'Recording Details', name: 'Recording Details',
value: 'recordingDetails', value: 'recordingDetails',
@ -692,47 +679,64 @@ export const videoFields = [
}, },
default: '', default: '',
}, },
// { {
// displayName: 'Country Code', displayName: 'Title',
// name: 'countryCode', name: 'title',
// type: 'options', type: 'string',
// typeOptions: { required: true,
// loadOptionsMethod: 'getCountriesCodes', displayOptions: {
// }, show: {
// displayOptions: { operation: [
// show: { 'update',
// operation: [ ],
// 'update', resource: [
// ], 'video',
// resource: [ ],
// 'video', },
// ], },
// }, default: '',
// }, },
// default: '', {
// }, displayName: 'Region Code',
// { name: 'regionCode',
// displayName: 'Category ID', type: 'options',
// name: 'categoryId', typeOptions: {
// type: 'options', loadOptionsMethod: 'getCountriesCodes',
// typeOptions: { },
// loadOptionsMethod: 'getVideoCategories', displayOptions: {
// loadOptionsDependsOn: [ show: {
// 'countryCode', operation: [
// ], 'update',
// }, ],
// displayOptions: { resource: [
// show: { 'video',
// operation: [ ],
// 'update', },
// ], },
// resource: [ default: '',
// 'video', },
// ], {
// }, displayName: 'Category ID',
// }, name: 'categoryId',
// default: '', type: 'options',
// }, typeOptions: {
loadOptionsMethod: 'getVideoCategories',
loadOptionsDependsOn: [
'regionCode',
],
},
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'video',
],
},
},
default: '',
},
{ {
displayName: 'Update Fields', displayName: 'Update Fields',
name: 'updateFields', name: 'updateFields',
@ -753,7 +757,10 @@ export const videoFields = [
{ {
displayName: 'Default Language', displayName: 'Default Language',
name: 'defaultLanguage', name: 'defaultLanguage',
type: 'string', type: 'options',
typeOptions: {
loadOptionsMethod: 'getLanguages',
},
default: '', default: '',
description: `The language of the text in the playlist resource's title and description properties.`, description: `The language of the text in the playlist resource's title and description properties.`,
}, },
@ -785,7 +792,7 @@ export const videoFields = [
value: 'youtube', value: 'youtube',
}, },
], ],
default: false, default: '',
description: `The video's license.`, description: `The video's license.`,
}, },
{ {
@ -851,12 +858,6 @@ export const videoFields = [
default: '', default: '',
description: `Keyword tags associated with the playlist. Mulplie can be defined separated by comma`, description: `Keyword tags associated with the playlist. Mulplie can be defined separated by comma`,
}, },
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
},
], ],
}, },
] as INodeProperties[]; ] as INodeProperties[];

View file

@ -32,6 +32,11 @@ import {
videoFields, videoFields,
} from './VideoDescription'; } from './VideoDescription';
import {
videoCategoryOperations,
videoCategoryFields,
} from './VideoCategoryDescription';
import { import {
countriesCodes, countriesCodes,
} from './CountryCodes'; } from './CountryCodes';
@ -75,6 +80,10 @@ export class YouTube implements INodeType {
name: 'Video', name: 'Video',
value: 'video', value: 'video',
}, },
{
name: 'Video Category',
value: 'videoCategory',
},
], ],
default: 'channel', default: 'channel',
description: 'The resource to operate on.' description: 'The resource to operate on.'
@ -87,6 +96,9 @@ export class YouTube implements INodeType {
...videoOperations, ...videoOperations,
...videoFields, ...videoFields,
...videoCategoryOperations,
...videoCategoryFields,
], ],
}; };
@ -133,7 +145,8 @@ export class YouTube implements INodeType {
async getVideoCategories( async getVideoCategories(
this: ILoadOptionsFunctions this: ILoadOptionsFunctions
): Promise<INodePropertyOptions[]> { ): Promise<INodePropertyOptions[]> {
const countryCode = this.getCurrentNodeParameter('countryCode') as string; const countryCode = this.getCurrentNodeParameter('regionCode') as string;
const returnData: INodePropertyOptions[] = []; const returnData: INodePropertyOptions[] = [];
const qs: IDataObject = {}; const qs: IDataObject = {};
qs.regionCode = countryCode; qs.regionCode = countryCode;
@ -169,6 +182,25 @@ export class YouTube implements INodeType {
const operation = this.getNodeParameter('operation', 0) as string; const operation = this.getNodeParameter('operation', 0) as string;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (resource === 'channel') { if (resource === 'channel') {
if (operation === 'get') {
//https://developers.google.com/youtube/v3/docs/channels/list
const part = this.getNodeParameter('part', i) as string[];
const channelId = this.getNodeParameter('channelId', i) as string;
qs.part = part.join(',');
qs.id = channelId;
responseData = await googleApiRequest.call(
this,
'GET',
`/youtube/v3/channels`,
{},
qs
);
responseData = responseData.items;
}
//https://developers.google.com/youtube/v3/docs/channels/list //https://developers.google.com/youtube/v3/docs/channels/list
if (operation === 'getAll') { if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean; const returnAll = this.getNodeParameter('returnAll', i) as boolean;
@ -178,27 +210,14 @@ export class YouTube implements INodeType {
qs.part = part.join(','); qs.part = part.join(',');
if (filters.categoryId) { Object.assign(qs, options, filters);
qs.categoryId = filters.categoryId as string;
} qs.mine = true;
if (filters.forUsername) {
qs.forUsername = filters.forUsername as string; if (qs.categoryId || qs.forUsername || qs.id || qs.managedByMe) {
} delete qs.mine;
if (filters.id) {
qs.id = filters.id as string;
}
if (filters.managedByMe) {
qs.managedByMe = filters.managedByMe as boolean;
}
if (filters.mine) {
qs.mine = filters.mine as boolean;
}
if (options.h1) {
qs.h1 = options.h1 as string;
}
if (options.onBehalfOfContentOwner) {
qs.onBehalfOfContentOwner = options.onBehalfOfContentOwner as string;
} }
if (returnAll) { if (returnAll) {
responseData = await googleApiRequestAllItems.call( responseData = await googleApiRequestAllItems.call(
this, this,
@ -371,6 +390,28 @@ export class YouTube implements INodeType {
} }
} }
if (resource === 'playlist') { if (resource === 'playlist') {
//https://developers.google.com/youtube/v3/docs/playlists/list
if (operation === 'get') {
const part = this.getNodeParameter('part', i) as string[];
const playlistId = this.getNodeParameter('playlistId', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
qs.part = part.join(',');
qs.id = playlistId;
Object.assign(qs, options);
responseData = await googleApiRequest.call(
this,
'GET',
`/youtube/v3/playlists`,
{},
qs
);
responseData = responseData.items;
}
//https://developers.google.com/youtube/v3/docs/playlists/list //https://developers.google.com/youtube/v3/docs/playlists/list
if (operation === 'getAll') { if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean; const returnAll = this.getNodeParameter('returnAll', i) as boolean;
@ -382,6 +423,12 @@ export class YouTube implements INodeType {
Object.assign(qs, options, filters); Object.assign(qs, options, filters);
qs.mine = true;
if (qs.channelId || qs.id) {
delete qs.mine;
}
if (returnAll) { if (returnAll) {
responseData = await googleApiRequestAllItems.call( responseData = await googleApiRequestAllItems.call(
this, this,
@ -450,14 +497,18 @@ export class YouTube implements INodeType {
//https://developers.google.com/youtube/v3/docs/playlists/update //https://developers.google.com/youtube/v3/docs/playlists/update
if (operation === 'update') { if (operation === 'update') {
const playlistId = this.getNodeParameter('playlistId', i) as string; const playlistId = this.getNodeParameter('playlistId', i) as string;
const title = this.getNodeParameter('title', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
qs.part = 'snippet'; qs.part = 'snippet, status';
const body: IDataObject = { const body: IDataObject = {
id: playlistId, id: playlistId,
snippet: { snippet: {
} title,
},
status: {
},
}; };
if (updateFields.tags) { if (updateFields.tags) {
@ -465,9 +516,9 @@ export class YouTube implements INodeType {
body.snippet.tags = (updateFields.tags as string).split(',') as string[]; body.snippet.tags = (updateFields.tags as string).split(',') as string[];
} }
if (updateFields.title) { if (updateFields.privacyStatus) {
//@ts-ignore //@ts-ignore
body.snippet.title = updateFields.title as string body.status.privacyStatus = updateFields.privacyStatus as string;
} }
if (updateFields.description) { if (updateFields.description) {
@ -529,6 +580,10 @@ export class YouTube implements INodeType {
Object.assign(qs, options, filters); Object.assign(qs, options, filters);
if (qs.myRating) {
delete qs.chart;
}
if (returnAll) { if (returnAll) {
responseData = await googleApiRequestAllItems.call( responseData = await googleApiRequestAllItems.call(
this, this,
@ -689,7 +744,8 @@ export class YouTube implements INodeType {
//https://developers.google.com/youtube/v3/docs/playlists/update //https://developers.google.com/youtube/v3/docs/playlists/update
if (operation === 'update') { if (operation === 'update') {
const id = this.getNodeParameter('videoId', i) as string; const id = this.getNodeParameter('videoId', i) as string;
//const categoryId = this.getNodeParameter('categoryId', i) as string; const title = this.getNodeParameter('title', i) as string;
const categoryId = this.getNodeParameter('categoryId', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
qs.part = 'snippet, status, recordingDetails'; qs.part = 'snippet, status, recordingDetails';
@ -697,7 +753,8 @@ export class YouTube implements INodeType {
const body = { const body = {
id, id,
snippet: { snippet: {
//categoryId, title,
categoryId,
}, },
status: { status: {
}, },
@ -707,59 +764,56 @@ export class YouTube implements INodeType {
if (updateFields.description) { if (updateFields.description) {
//@ts-ignore //@ts-ignore
data.snippet.description = updateFields.description as string; body.snippet.description = updateFields.description as string;
} }
if (updateFields.privacyStatus) { if (updateFields.privacyStatus) {
//@ts-ignore //@ts-ignore
data.status.privacyStatus = updateFields.privacyStatus as string; body.status.privacyStatus = updateFields.privacyStatus as string;
} }
if (updateFields.tags) { if (updateFields.tags) {
//@ts-ignore //@ts-ignore
data.snippet.tags = (updateFields.tags as string).split(',') as string[]; body.snippet.tags = (updateFields.tags as string).split(',') as string[];
}
if (updateFields.description) {
//@ts-ignore
data.snippet.title = updateFields.title as string;
} }
if (updateFields.embeddable) { if (updateFields.embeddable) {
//@ts-ignore //@ts-ignore
data.status.embeddable = updateFields.embeddable as boolean; body.status.embeddable = updateFields.embeddable as boolean;
} }
if (updateFields.publicStatsViewable) { if (updateFields.publicStatsViewable) {
//@ts-ignore //@ts-ignore
data.status.publicStatsViewable = updateFields.publicStatsViewable as boolean; body.status.publicStatsViewable = updateFields.publicStatsViewable as boolean;
} }
if (updateFields.publishAt) { if (updateFields.publishAt) {
//@ts-ignore //@ts-ignore
data.status.publishAt = updateFields.publishAt as string; body.status.publishAt = updateFields.publishAt as string;
}
if (updateFields.recordingDate) {
//@ts-ignore
data.recordingDetails.recordingDate = updateFields.recordingDate as string;
} }
if (updateFields.selfDeclaredMadeForKids) { if (updateFields.selfDeclaredMadeForKids) {
//@ts-ignore //@ts-ignore
data.status.selfDeclaredMadeForKids = updateFields.selfDeclaredMadeForKids as boolean; body.status.selfDeclaredMadeForKids = updateFields.selfDeclaredMadeForKids as boolean;
}
if (updateFields.recordingDate) {
//@ts-ignore
body.recordingDetails.recordingDate = updateFields.recordingDate as string;
} }
if (updateFields.license) { if (updateFields.license) {
//@ts-ignore //@ts-ignore
data.status.license = options.license as string; body.status.license = updateFields.license as string;
} }
if (updateFields.defaultLanguage) { if (updateFields.defaultLanguage) {
//@ts-ignore //@ts-ignore
data.snippet.defaultLanguage = updateFields.defaultLanguage as string; body.snippet.defaultLanguage = updateFields.defaultLanguage as string;
} }
console.log(body)
responseData = await googleApiRequest.call( responseData = await googleApiRequest.call(
this, this,
'PUT', 'PUT',
@ -810,6 +864,31 @@ export class YouTube implements INodeType {
responseData = { success: true }; responseData = { success: true };
} }
} }
if (resource === 'videoCategory') {
//https://developers.google.com/youtube/v3/docs/videoCategories/list
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const regionCode = this.getNodeParameter('regionCode', i) as string;
qs.regionCode = regionCode;
qs.part = 'snippet';
responseData = await googleApiRequest.call(
this,
'GET',
`/youtube/v3/videoCategories`,
{},
qs
);
responseData = responseData.items;
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
responseData = responseData.splice(0, limit);
}
}
}
} }
if (Array.isArray(responseData)) { if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]); returnData.push.apply(returnData, responseData as IDataObject[]);