Find country of channel in youtube api v3

前端 未结 5 726
萌比男神i
萌比男神i 2020-12-20 16:24

In v2 of the youtube api, I could get the country of a channel by getting it\'s user information (https://gdata.youtube.com/feeds/api/users/userId) and looking at the Locati

5条回答
  •  时光说笑
    2020-12-20 17:18

    If you want to know country info of a channel where it is located , it can be get via channel list API by using following code you can get a channel's country if it has mentioned in its ABOUT Section . id = 'Enter_your_channel_id_here' url = 'https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&id=' + str(id) channel_url = url + '&key=' + str(key) raw_json = requests.get(channel_url).text dataa = json.loads(raw_json) channel_country = dataa['items'][0]['snippet']['country']

    this code will return country code of a specific channel, and by doing some google research you can obtain country names easily for country code. Thanks!

提交回复
热议问题