import type { UnifapiOperationDefinition } from "../operations.ts";

export const youtubeOperations: readonly UnifapiOperationDefinition[] = [
  {
    name: "list_youtube_channel_community_posts",
    operationId: "getYoutubeChannelsByChannelIdCommunity",
    description: "List a YouTube channel's community posts.",
    method: "GET",
    path: "/youtube/channels/{channel_id}/community",
    pathFields: ["channel_id"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        channel_id: {
          type: "string",
          minLength: 1,
          description: "The channel_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List a YouTube channel's community posts.",
      required: ["channel_id"],
    },
    paginated: true,
  },
  {
    name: "list_youtube_channel_playlists",
    operationId: "getYoutubeChannelsByChannelIdPlaylists",
    description: "List playlists created by a YouTube channel.",
    method: "GET",
    path: "/youtube/channels/{channel_id}/playlists",
    pathFields: ["channel_id"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        channel_id: {
          type: "string",
          minLength: 1,
          description: "The channel_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List playlists created by a YouTube channel.",
      required: ["channel_id"],
    },
    paginated: true,
  },
  {
    name: "get_youtube_channel",
    operationId: "getYoutubeChannelsByChannelId",
    description: "Get a YouTube channel by id.",
    method: "GET",
    path: "/youtube/channels/{channel_id}",
    pathFields: ["channel_id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        channel_id: {
          type: "string",
          minLength: 1,
          description: "YouTube channel id (`UCxxx...`).",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a YouTube channel by id.",
      required: ["channel_id"],
    },
    paginated: false,
  },
  {
    name: "search_youtube_channel",
    operationId: "getYoutubeChannelsByChannelIdSearch",
    description: "Search within a YouTube channel.",
    method: "GET",
    path: "/youtube/channels/{channel_id}/search",
    pathFields: ["channel_id"],
    queryFields: ["cursor", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        channel_id: {
          type: "string",
          minLength: 1,
          description: "The channel_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search within a YouTube channel.",
      required: ["channel_id", "q"],
    },
    paginated: true,
  },
  {
    name: "list_youtube_channel_shorts",
    operationId: "getYoutubeChannelsByChannelIdShorts",
    description: "List Shorts uploaded by a YouTube channel.",
    method: "GET",
    path: "/youtube/channels/{channel_id}/shorts",
    pathFields: ["channel_id"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        channel_id: {
          type: "string",
          minLength: 1,
          description: "The channel_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List Shorts uploaded by a YouTube channel.",
      required: ["channel_id"],
    },
    paginated: true,
  },
  {
    name: "list_youtube_channel_videos",
    operationId: "getYoutubeChannelsByChannelIdVideos",
    description: "List videos uploaded by a YouTube channel.",
    method: "GET",
    path: "/youtube/channels/{channel_id}/videos",
    pathFields: ["channel_id"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        channel_id: {
          type: "string",
          minLength: 1,
          description: "The channel_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos uploaded by a YouTube channel.",
      required: ["channel_id"],
    },
    paginated: true,
  },
  {
    name: "list_youtube_hashtag_videos",
    operationId: "getYoutubeHashtagsByTagVideos",
    description: "List videos for a YouTube hashtag.",
    method: "GET",
    path: "/youtube/hashtags/{tag}/videos",
    pathFields: ["tag"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        tag: {
          type: "string",
          minLength: 1,
          description: "Hashtag, with or without a leading `#`, e.g. `lofi`.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos for a YouTube hashtag.",
      required: ["tag"],
    },
    paginated: true,
  },
  {
    name: "get_youtube_playlist",
    operationId: "getYoutubePlaylistsByPlaylistId",
    description: "Get a YouTube playlist by id.",
    method: "GET",
    path: "/youtube/playlists/{playlist_id}",
    pathFields: ["playlist_id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        playlist_id: {
          type: "string",
          minLength: 1,
          description: "YouTube playlist id (`PL...`).",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a YouTube playlist by id.",
      required: ["playlist_id"],
    },
    paginated: false,
  },
  {
    name: "list_youtube_playlist_videos",
    operationId: "getYoutubePlaylistsByPlaylistIdVideos",
    description: "List videos in a YouTube playlist.",
    method: "GET",
    path: "/youtube/playlists/{playlist_id}/videos",
    pathFields: ["playlist_id"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        playlist_id: {
          type: "string",
          minLength: 1,
          description: "The playlist_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos in a YouTube playlist.",
      required: ["playlist_id"],
    },
    paginated: true,
  },
  {
    name: "resolve_youtube_channel_id",
    operationId: "getYoutubeResolveChannelId",
    description: "Resolve a YouTube channel URL to its UC... channel id.",
    method: "GET",
    path: "/youtube/resolve/channel-id",
    pathFields: [],
    queryFields: ["url"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        url: {
          type: "string",
          format: "uri",
          description: "Full channel URL - supports `youtube.com/@handle`, `/channel/UC...`, `/c/name`.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Resolve a YouTube channel URL to its UC... channel id.",
      required: ["url"],
    },
    paginated: false,
  },
  {
    name: "search_youtube_channels",
    operationId: "getYoutubeSearchChannels",
    description: "Search YouTube channels by keyword.",
    method: "GET",
    path: "/youtube/search/channels",
    pathFields: [],
    queryFields: ["cursor", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search YouTube channels by keyword.",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "search_youtube_playlists",
    operationId: "getYoutubeSearchPlaylists",
    description: "Search YouTube playlists by keyword.",
    method: "GET",
    path: "/youtube/search/playlists",
    pathFields: [],
    queryFields: ["cursor", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search YouTube playlists by keyword.",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "search_youtube_videos",
    operationId: "getYoutubeSearch",
    description: "Search YouTube videos by keyword.",
    method: "GET",
    path: "/youtube/search",
    pathFields: [],
    queryFields: ["cursor", "q", "sort_by", "upload_date", "duration", "region", "language"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword.",
        },
        sort_by: {
          type: "string",
          enum: ["relevance", "date", "views", "rating"],
          description: "Result ordering (default `relevance`).",
        },
        upload_date: {
          type: "string",
          enum: ["hour", "today", "week", "month", "year"],
          description: "Restrict to videos uploaded within this window.",
        },
        duration: {
          type: "string",
          enum: ["short", "medium", "long"],
          description: "Restrict by video length bucket.",
        },
        region: {
          type: "string",
          minLength: 2,
          maxLength: 2,
          description: "ISO 3166 country code, e.g. `US`.",
        },
        language: {
          type: "string",
          description: "Language code, e.g. `en`.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search YouTube videos by keyword.",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "browse_youtube_trending",
    operationId: "getYoutubeTrending",
    description: "Browse YouTube's trending videos.",
    method: "GET",
    path: "/youtube/trending",
    pathFields: [],
    queryFields: ["country", "type", "language_code"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        country: {
          type: "string",
          minLength: 2,
          maxLength: 2,
          description: "Optional ISO 3166 country code, e.g. `US` (default), `GB`.",
        },
        type: {
          type: "string",
          enum: ["now", "music", "gaming", "movies"],
          description: "Optional trending section (default `now`).",
        },
        language_code: {
          type: "string",
          description: "Optional language code, e.g. `en`.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Browse YouTube's trending videos.",
    },
    paginated: false,
  },
  {
    name: "list_youtube_video_captions",
    operationId: "getYoutubeVideosByVideoIdCaptions",
    description: "List a YouTube video's caption tracks.",
    method: "GET",
    path: "/youtube/videos/{video_id}/captions",
    pathFields: ["video_id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        video_id: {
          type: "string",
          minLength: 1,
          description: "The video_id value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List a YouTube video's caption tracks.",
      required: ["video_id"],
    },
    paginated: false,
  },
  {
    name: "list_youtube_video_comments",
    operationId: "getYoutubeVideosByVideoIdComments",
    description: "List comments on a YouTube video.",
    method: "GET",
    path: "/youtube/videos/{video_id}/comments",
    pathFields: ["video_id"],
    queryFields: ["cursor", "sort_by"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        video_id: {
          type: "string",
          minLength: 1,
          description: "The video_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        sort_by: {
          type: "string",
          enum: ["top", "newest"],
          description: "Comment ordering: `top` (default) or `newest`.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List comments on a YouTube video.",
      required: ["video_id"],
    },
    paginated: true,
  },
  {
    name: "list_youtube_related_videos",
    operationId: "getYoutubeVideosByVideoIdRelated",
    description: "List YouTube videos related to a given video.",
    method: "GET",
    path: "/youtube/videos/{video_id}/related",
    pathFields: ["video_id"],
    queryFields: ["cursor"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        video_id: {
          type: "string",
          minLength: 1,
          description: "The video_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List YouTube videos related to a given video.",
      required: ["video_id"],
    },
    paginated: true,
  },
  {
    name: "get_youtube_video",
    operationId: "getYoutubeVideosByVideoId",
    description: "Get a YouTube video by id.",
    method: "GET",
    path: "/youtube/videos/{video_id}",
    pathFields: ["video_id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        video_id: {
          type: "string",
          minLength: 1,
          description: "YouTube video id, e.g. `oaSNBz4qMQY`.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a YouTube video by id.",
      required: ["video_id"],
    },
    paginated: false,
  },
  {
    name: "get_youtube_video_transcript",
    operationId: "getYoutubeVideosByVideoIdTranscript",
    description: "Get a YouTube video's transcript.",
    method: "GET",
    path: "/youtube/videos/{video_id}/transcript",
    pathFields: ["video_id"],
    queryFields: ["lang"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        video_id: {
          type: "string",
          minLength: 1,
          description: "The video_id value.",
        },
        lang: {
          type: "string",
          minLength: 2,
          maxLength: 35,
          description: "Caption language code to transcribe, e.g. `en` or `es`. Defaults to English.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a YouTube video's transcript.",
      required: ["video_id"],
    },
    paginated: false,
  },
];
