【问题标题】:How can I get Category of video in YouTube Data API V3?如何在 YouTube Data API V3 中获取视频类别?
【发布时间】:2022-11-04 00:30:06
【问题描述】:

我想获得一些类别的视频。但我找不到它的文档。

我得到这样的视频 ID 和标题:

resp = requests.get('https://www.googleapis.com/youtube/v3/search', 
                    params= {
                        "key":"My Key",
                        "part":"snippet",
                        "q":"IT",
                        "maxResults":1,
                        "order":"rating",
                        "regionCode":"KR"
                        }

我找到了2个小时,但找不到。 对不起我的英语不好。习惯英语需要很长时间

【问题讨论】:

    标签: python-3.x youtube-data-api


    【解决方案1】:

    您必须向videos:list 端点发出另一个请求以获取视频详细信息。

    这是example

    样本结果——简化

    {
      "kind": "youtube#videoListResponse",
      "etag": "hlTiav1mjsf38WLGrSZ2Jh4x6f8",
      "items": [
        {
          "kind": "youtube#video",
          "etag": "RL6Bx_x6UPInYVSFI020RU4UT3Q",
          "id": "ouf0ozwnU84",
          "snippet": {
            "publishedAt": "2022-02-25T23:00:16Z",
            "channelId": "UCYzHwra_yDr-QGFiopiOPnw",
            "title": "Cards to Consider: Blindly Loyal Goblin (Not Great, but Interesting)",
            "description": "#Shorts
    Why is Blindly Loyal Goblin Interesting? Well it might be a design limiting card, strangely enough.",
            "thumbnails": {
              "default": {
                "url": "https://i.ytimg.com/vi/ouf0ozwnU84/default.jpg",
                "width": 120,
                "height": 90
              },
              [...]
            },
            "channelTitle": "TCGTheory",
            "tags": [
              "TCGTheory",
              "Card Game Analysis",
              "Card Game Theory",
              "Yugioh",
              "Yu-gi-oh!",
              "Cards to Consider",
              [...]
            ],
            "categoryId": "20", // <= Video category "Gaming".
            "liveBroadcastContent": "none",
            [...]
            "defaultAudioLanguage": "en-US"
          },
          "contentDetails": {
            "duration": "PT48S",
            "dimension": "2d",
            "definition": "hd",
            "caption": "false",
            "licensedContent": true,
            "contentRating": {},
            "projection": "rectangular"
          },
          "status": {
            "uploadStatus": "processed",
            "privacyStatus": "public",
            "license": "youtube",
            "embeddable": true,
            "publicStatsViewable": true,
            "madeForKids": false
          },
          "statistics": {
            "viewCount": "81792",
            "likeCount": "3297",
            "favoriteCount": "0",
            "commentCount": "138"
          },
          "topicDetails": {
            "topicCategories": [
              "https://en.wikipedia.org/wiki/Video_game_culture"
            ]
          }
        }
      ],
      "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 1
      }
    }
    

    在本例中,categoryId 是 20 - Gaming。

    您可以查看视频类别here

    【讨论】:

      猜你喜欢
      • 2015-06-27
      • 2013-06-30
      • 2019-07-27
      • 2015-03-15
      • 2014-01-26
      • 2014-06-05
      • 1970-01-01
      • 2016-01-17
      • 2018-08-24
      相关资源
      最近更新 更多