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

[Usability Audit] Youtube Data API #15695

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
...common,
key: "youtube_data_api-add-playlist-items",
name: "Add Playlist Items",
description: "Adds resources to a playlist. [See the docs](https://developers.google.com/youtube/v3/docs/playlistItems/insert) for more information",
version: "0.0.1",
description: "Adds resources to a playlist. [See the documentation](https://developers.google.com/youtube/v3/docs/playlistItems/insert) for more information",
version: "0.0.2",
type: "action",
props: {
youtubeDataApi,
Expand All @@ -18,8 +18,8 @@ export default {
},
videoIds: {
type: "string[]",
label: "Video Ids",
description: "Array of identifiers of the videos to be added to the playlist",
label: "Video IDs",
description: "Array of identifiers of the videos to be added to the playlist. E.g. `o_U1CQn68VM` The video ID will be located in the URL of the video page, right after the v= URL parameter",
},
onBehalfOfContentOwner: {
propDefinition: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
...common,
key: "youtube_data_api-channel-statistics",
name: "Channel Statistics",
description: "Returns statistics from my YouTube Channel or by id. [See the docs](https://developers.google.com/youtube/v3/docs/channels/list) for more information",
version: "0.0.3",
description: "Returns statistics from my YouTube Channel or by id. [See the documentation](https://developers.google.com/youtube/v3/docs/channels/list) for more information",
version: "0.0.4",
type: "action",
props: {
youtubeDataApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ export default {
const managedByMe = this.useCase === "managedByMe" ?
true :
undefined;
const channels = (await this.youtubeDataApi.listChannels({
const { data: channels } = await this.youtubeDataApi.listChannels({
id,
mine,
managedByMe,
part,
onBehalfOfContentOwner,
maxResults,
hl,
})).data;
$.export("$summary", `Successfully fetched ${channels.items.length} channel(s)`);
});
$.export("$summary", `Successfully fetched ${channels.items.length} channel${channels.items.length === 1
? ""
: "s"}`);
return channels;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
...common,
key: "youtube_data_api-create-comment-thread",
name: "Create Comment Thread",
description: "Creates a new top-level comment in a video. [See the docs](https://developers.google.com/youtube/v3/docs/commentThreads/insert) for more information",
version: "0.0.1",
description: "Creates a new top-level comment in a video. [See the documentation](https://developers.google.com/youtube/v3/docs/commentThreads/insert) for more information",
version: "0.0.2",
type: "action",
props: {
youtubeDataApi,
Expand All @@ -21,7 +21,7 @@ export default {
youtubeDataApi,
"userOwnedVideo",
],
description: "Select the video to add comment to. Leave blank to post comment to channel.",
description: "Select the video to add comment to. E.g. `wslno0wDSFQ`. Leave blank to post comment to channel.",
},
text: {
type: "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
...common,
key: "youtube_data_api-create-playlist",
name: "Create Playlist",
description: "Creates a playlist. [See the docs](https://developers.google.com/youtube/v3/docs/playlists/insert) for more information",
version: "0.0.2",
description: "Creates a playlist. [See the documentation](https://developers.google.com/youtube/v3/docs/playlists/insert) for more information",
version: "0.0.3",
type: "action",
props: {
youtubeDataApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export default {
onBehalfOfContentOwner: this.onBehalfOfContentOwner,
};
const youtube = await this.youtubeDataApi.youtube();
const responses = [];
for (const videoId of this.videoIds) {
params.id = videoId;
const { data } = await youtube.playlistItems.delete(params);
responses.push(data);
await youtube.playlistItems.delete(params);
}
$.export("$summary", `Successfully deleted ${this.videoIds.length} item(s) from playlist with ID ${this.playlistId}`);
$.export("$summary", `Successfully deleted ${this.videoIds.length} item${this.videoIds.length === 1
? ""
: "s"} from playlist with ID ${this.playlistId}`);
// nothing to return
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
...common,
key: "youtube_data_api-delete-playlist-items",
name: "Delete Playlist Items",
description: "Deletes a playlist item. [See the docs](https://developers.google.com/youtube/v3/docs/playlistItems/delete) for more information",
version: "0.0.1",
description: "Deletes a playlist item. [See the documentation](https://developers.google.com/youtube/v3/docs/playlistItems/delete) for more information",
version: "0.0.2",
type: "action",
props: {
youtubeDataApi,
Expand All @@ -17,19 +17,13 @@ export default {
],
},
videoIds: {
type: "string[]",
label: "Video Ids",
description: "Array of identifiers of the videos to be removed from the playlist",
async options() {
const { data } = await this.youtubeDataApi.getPlaylistItems({
part: "contentDetails,id,snippet,status",
playlistId: this.playlistId,
});
return data?.items?.map((item) => ({
label: item.snippet.title,
value: item.id,
})) || [];
},
propDefinition: [
youtubeDataApi,
"playlistItemIds",
(c) => ({
playlistId: c.playlistId,
}),
],
},
onBehalfOfContentOwner: {
propDefinition: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
...common,
key: "youtube_data_api-delete-playlist",
name: "Delete Playlist",
description: "Deletes a playlist. [See the docs](https://developers.google.com/youtube/v3/docs/playlists/delete) for more information",
version: "0.0.1",
description: "Deletes a playlist. [See the documentation](https://developers.google.com/youtube/v3/docs/playlists/delete) for more information",
version: "0.0.2",
type: "action",
props: {
youtubeDataApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export default {
const mine = this.useCase === "mine" ?
true :
undefined;
const activities = (await this.youtubeDataApi.listActivities({
const { data: activities } = await this.youtubeDataApi.listActivities({
channelId,
mine,
part,
regionCode,
maxResults,
publishedBefore,
publishedAfter,
})).data;
});
$.export("$summary", `Successfully fetched ${activities.items.length} ${activities.items.length === 1
? "activity"
: "activities"}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
...common,
key: "youtube_data_api-list-activities",
name: "List Activities",
description: "Returns a list of channel activity events that match the request criteria. [See the docs](https://developers.google.com/youtube/v3/docs/channels/list) for more information",
version: "0.0.3",
description: "Returns a list of channel activity events that match the request criteria. [See the documentation](https://developers.google.com/youtube/v3/docs/activities/list) for more information",
version: "0.0.4",
type: "action",
props: {
youtubeDataApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import youtubeDataApi from "../../youtube_data_api.app.mjs";
export default {
key: "youtube_data_api-list-playlist-videos",
name: "List Playlist Videos",
description: "List videos in a playlist. [See the docs](https://developers.google.com/youtube/v3/docs/playlistItems/list) for more information",
version: "0.0.1",
description: "List videos in a playlist. [See the documentation](https://developers.google.com/youtube/v3/docs/playlistItems/list) for more information",
version: "0.0.2",
type: "action",
props: {
youtubeDataApi,
Expand All @@ -13,18 +13,13 @@ export default {
youtubeDataApi,
"userOwnedPlaylist",
],
description: "Select a **Playlist** or provide a custom *Playlist ID*.",
description: "Select a **Playlist** or provide a custom *Playlist ID*. E.g. `PLJswo-CV0rmlwxKysf33cUnyBp8JztH0k`",
},
maxResults: {
propDefinition: [
youtubeDataApi,
"maxResults",
],
description: "The maximum number of results to return.",
min: 1,
max: 50,
default: 5,
optional: true,
},
},
async run({ $ }) {
Expand Down
13 changes: 8 additions & 5 deletions components/youtube_data_api/actions/list-playlists/common.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import consts from "../../common/consts.mjs";

export default {
async run({ $ }) {
const {
useCase,
id,
channelId,
part,
hl,
maxResults,
onBehalfOfContentOwner,
Expand All @@ -15,17 +16,19 @@ export default {
true :
undefined;

const playlists = (await this.youtubeDataApi.listPlaylists({
part,
const { data: playlists } = await this.youtubeDataApi.listPlaylists({
part: consts.LIST_PLAYLISTS_PART_OPTS,
id,
mine,
channelId,
hl,
onBehalfOfContentOwner,
onBehalfOfContentOwnerChannel,
maxResults,
})).data;
$.export("$summary", `Successfully fetched ${playlists.items.length} playlist(s)`);
});
$.export("$summary", `Successfully fetched ${playlists.items.length} playlist${playlists.items.length === 1
? ""
: "s"}`);
return playlists;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
...common,
key: "youtube_data_api-list-playlists",
name: "List Playlists",
description: "Returns a collection of playlists that match the API request parameters. [See the docs](https://developers.google.com/youtube/v3/docs/playlists/list) for more information",
version: "0.0.3",
description: "Returns a collection of playlists that match the API request parameters. [See the documentation](https://developers.google.com/youtube/v3/docs/playlists/list) for more information",
version: "0.0.4",
type: "action",
props: {
youtubeDataApi,
Expand All @@ -34,10 +34,6 @@ export default {
}
return {
...dynamicProps,
part: {
...youtubeDataApi.propDefinitions.part,
options: consts.LIST_PLAYLISTS_PART_OPTS,
},
hl: {
...youtubeDataApi.propDefinitions.hl,
options: async () => {
Expand Down
10 changes: 6 additions & 4 deletions components/youtube_data_api/actions/list-videos/common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default {
"mostPopular" :
undefined;

const videos = (await this.youtubeDataApi.listVideos({
const { data: videos } = await this.youtubeDataApi.listVideos({
part,
id,
id: id && id.join(),
chart,
myRating,
hl,
Expand All @@ -28,8 +28,10 @@ export default {
maxResults,
videoCategoryId,
regionCode,
})).data;
$.export("$summary", `Successfully fetched ${videos.items.length} video(s)`);
});
$.export("$summary", `Successfully fetched ${videos.items.length} video${videos.items.length === 1
? ""
: "s"}`);
return videos;
},
};
29 changes: 15 additions & 14 deletions components/youtube_data_api/actions/list-videos/list-videos.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
...common,
key: "youtube_data_api-list-videos",
name: "List Videos",
description: "Returns a list of videos that match the API request parameters. [See the docs](https://developers.google.com/youtube/v3/docs/videos/list) for more information",
version: "0.0.3",
description: "Returns a list of videos that match the API request parameters. [See the documentation](https://developers.google.com/youtube/v3/docs/videos/list) for more information",
version: "0.0.4",
type: "action",
props: {
youtubeDataApi,
Expand All @@ -24,7 +24,7 @@ export default {
const dynamicProps = {};
if (this.useCase === "id") {
dynamicProps.id = {
...youtubeDataApi.propDefinitions.channelId,
...youtubeDataApi.propDefinitions.videoIds,
};
}
else if (this.useCase === "myRating") {
Expand All @@ -38,18 +38,19 @@ export default {
else if (this.useCase === "chart") {
dynamicProps.regionCode = {
...youtubeDataApi.propDefinitions.regionCode,
reloadProps: true,
};
dynamicProps.videoCategoryId = {
type: "string",
label: "Video Category ID",
description: "The videoCategoryId parameter identifies the video category for which the chart should be retrieved. By default, charts are not restricted to a particular category.",
optional: true,
options: async () => {
return this.regionCode?.length === 2
? await this.youtubeDataApi.listVideoCategoriesOpts(this.regionCode)
: [];
},
};
if (this.regionCode && this.regionCode.length === 2) {
dynamicProps.videoCategoryId = {
label: "Video Category Id",
description: "The videoCategoryId parameter identifies the video category for which the chart should be retrieved. By default, charts are not restricted to a particular category.",
type: "string",
optional: true,
options: async () => {
return await this.youtubeDataApi.listVideoCategoriesOpts(this.regionCode);
},
};
}
}
return {
...dynamicProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
...common,
key: "youtube_data_api-reply-to-comment",
name: "Reply To Comment",
description: "Creates a reply to an existing comment. [See the docs](https://developers.google.com/youtube/v3/docs/comments/insert) for more information",
version: "0.0.1",
description: "Creates a reply to an existing comment. [See the documentation](https://developers.google.com/youtube/v3/docs/comments/insert) for more information",
version: "0.0.2",
type: "action",
props: {
youtubeDataApi,
Expand Down
Loading
Loading