S
S
staushev2021-06-13 09:02:18
YouTube
staushev, 2021-06-13 09:02:18

How to get parameter value from response?

request = youtube.liveBroadcasts().list(
        part="snippet",
        broadcastStatus="active",
        broadcastType="all"
    )
    response = request.execute()

the following response comes from the above code:
{
  "kind": "...",
  "etag": "...",
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#liveBroadcast",
      "etag": "...",
      "id": "...",
      "snippet": {
        "publishedAt": "2021-06-13T05:08:05Z",
        "channelId": "...",
        "title": "Прямая трансляция пользователя Ориварива Пэйн",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/g37TQVf7Uv4/default_live.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/g37TQVf7Uv4/mqdefault_live.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/g37TQVf7Uv4/hqdefault_live.jpg",
            "width": 480,
            "height": 360
          },
          "standard": {
            "url": "https://i.ytimg.com/vi/g37TQVf7Uv4/sddefault_live.jpg",
            "width": 640,
            "height": 480
          },
          "maxres": {
            "url": "https://i.ytimg.com/vi/g37TQVf7Uv4/maxresdefault_live.jpg",
            "width": 1280,
            "height": 720
          }
        },
        "actualStartTime": "2021-06-13T05:08:36Z",
        "isDefaultBroadcast": false,
        "liveChatId": "..."
      }
    }
  ]
}


How to get livechatid from this answer? I'm a complete teapot if anything, and I don't even know where to turn.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
staushev, 2021-06-13
@staushev

The response was of the json type, all that was needed was to get each array separately

lb_request = youtube.liveBroadcasts().list(  #LiveBroadcast request. Get LiveChatID
        part="snippet",
        broadcastStatus="active",
        broadcastType="all"
)
    lb_response = lb_request.execute()
    lci = lb_response["items"][0]["snippet"]["liveChatId"]  #LiveChatID

S
Sergey Sokolov, 2021-06-13
@sergiks

Tryresponse.items[0].snippet.liveChatId

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question