{
"kind": "youtube#commentThreadListResponse",
"etag": "tSw5WSiFS4IMMytcgoYXJ9zpu6I",
"nextPageToken": "QURTSl9pMDFKVnZtTFl0NFZOdnhaZFpXaFBOcWU5aDA0QWM5bDVpYk5oVTd1WDQwSDY1cU11OVBOZHNnWFNOTmNJby1Db1JpWno2Qnd5bw==",
"pageInfo": {
"totalResults": 5,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#commentThread",
"etag": "An3zz04lgE7jUVO7VXXmqfdwFjk",
"id": "UgwDY44NUll4uiZXqqx4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"topLevelComment": {
"kind": "youtube#comment",
"etag": "Kty1w2F4dTbXmakl-ywdK28vLEg",
"id": "UgwDY44NUll4uiZXqqx4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"textDisplay": "SO gooood",
"textOriginal": "SO gooood",
"authorDisplayName": "fatt musiek",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwngpQ-20jVq0c-9aC-wDJ87aTKi2QvPLTRN2GXGRaw=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCl3ha3zwY9p6CemIZZXIdXQ",
"authorChannelId": {
"value": "UCl3ha3zwY9p6CemIZZXIdXQ"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-22T18:48:34Z",
"updatedAt": "2021-05-22T18:48:34Z"
}
},
"canReply": true,
"totalReplyCount": 0,
"isPublic": true
}
},
{
"kind": "youtube#commentThread",
"etag": "QVJH5RHTNij1fN5jRj_mNcDscHA",
"id": "Ugx8sUuwqKqPVG9eSuJ4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"topLevelComment": {
"kind": "youtube#comment",
"etag": "Y_SsBrGGxQoLpcztQqND9wGarUc",
"id": "Ugx8sUuwqKqPVG9eSuJ4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"textDisplay": "so what if really yuffie have met johnny hehe",
"textOriginal": "so what if really yuffie have met johnny hehe",
"authorDisplayName": "GregOrio Barachina",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnjgJE6zBYksYQWt8TmKlMDYOyG0t-BHPNWWmvUUPQ=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCUs2OJ4-KqYGS2EPJCDj7tQ",
"authorChannelId": {
"value": "UCUs2OJ4-KqYGS2EPJCDj7tQ"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-21T13:42:45Z",
"updatedAt": "2021-05-21T13:42:45Z"
}
},
"canReply": true,
"totalReplyCount": 0,
"isPublic": true
}
},
{
"kind": "youtube#commentThread",
"etag": "ggLtp9jtNyrqb3JSvzkvUDon7gg",
"id": "UgwP-4ucsrWh_iXJQMN4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"topLevelComment": {
"kind": "youtube#comment",
"etag": "Raxyf3_Zw3ksZyGeWDt7_HHW8SA",
"id": "UgwP-4ucsrWh_iXJQMN4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"textDisplay": "The Aerith and Cloud scene is much more meaningful than the one with Tifa. Still a good scene but come on...Aerith just appearing amongst the flowers and getting to see her again...priceless",
"textOriginal": "The Aerith and Cloud scene is much more meaningful than the one with Tifa. Still a good scene but come on...Aerith just appearing amongst the flowers and getting to see her again...priceless",
"authorDisplayName": "Maxx Doran",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnixfMDBxLt_TfUEjlpHhU-OvwE1vjCgpFBAVIMxjg=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCXcLTX_9fNHLVAMr_plxeqQ",
"authorChannelId": {
"value": "UCXcLTX_9fNHLVAMr_plxeqQ"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-18T01:50:04Z",
"updatedAt": "2021-05-18T01:50:04Z"
}
},
"canReply": true,
"totalReplyCount": 0,
"isPublic": true
}
},
{
"kind": "youtube#commentThread",
"etag": "ptUVfOGBkZDnUXKFoDaGnQ9Y-gw",
"id": "UgzTN_4ek7syWNNbCrB4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"topLevelComment": {
"kind": "youtube#comment",
"etag": "L3vDroBKOAklgIqKSkcX_JvLn_g",
"id": "UgzTN_4ek7syWNNbCrB4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"textDisplay": "You caught on to the magnify barrier idea so early. I was part way into hard mode before I thought of that.",
"textOriginal": "You caught on to the magnify barrier idea so early. I was part way into hard mode before I thought of that.",
"authorDisplayName": "Justin Edwards",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwngz1mU5zD3QHSRVU3jXTEZApnkYsmAzCKFXxUyD1w=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCO-oPQJCpNw87M6YbcuuFMw",
"authorChannelId": {
"value": "UCO-oPQJCpNw87M6YbcuuFMw"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-10T07:25:36Z",
"updatedAt": "2021-05-10T07:25:36Z"
}
},
"canReply": true,
"totalReplyCount": 0,
"isPublic": true
}
},
{
"kind": "youtube#commentThread",
"etag": "vfaqu09YbjpC_akz6riq0_XpSCw",
"id": "UgygOOysmSAraKnx81h4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"topLevelComment": {
"kind": "youtube#comment",
"etag": "k8vIS0anrGkqCcFfyj0gnrUwXQI",
"id": "UgygOOysmSAraKnx81h4AaABAg",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"textDisplay": "Y'know Max, you COULD have just run 5k steps in Aerith's garden, checked what the Materia did, and moved on. Or, maybe, look up an online guide, since by now I'm sure SOMEONE has posted one.",
"textOriginal": "Y'know Max, you COULD have just run 5k steps in Aerith's garden, checked what the Materia did, and moved on. Or, maybe, look up an online guide, since by now I'm sure SOMEONE has posted one.",
"authorDisplayName": "Soma Cruz the Demigod of Balance",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnilg2dkOBvJqeTbW34CBoxURHLWv78fnbCRkArv=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCNaiemmWvNbzfaQm5e3hyqA",
"authorChannelId": {
"value": "UCNaiemmWvNbzfaQm5e3hyqA"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-07T02:21:29Z",
"updatedAt": "2021-05-07T02:21:29Z"
}
},
"canReply": true,
"totalReplyCount": 1,
"isPublic": true
},
"replies": {
"comments": [
{
"kind": "youtube#comment",
"etag": "oMSJ1drDJreTmguX72NWydzfbcY",
"id": "UgygOOysmSAraKnx81h4AaABAg.9N10GKEX1209N2h_vQGc9Y",
"snippet": {
"videoId": "fdsaZ8EMR2U",
"textDisplay": "\u003ca href=\"https://www.youtube.com/watch?v=fdsaZ8EMR2U&t=38m03s\"\u003e38:03\u003c/a\u003e These things don't stagger? But each time they clone, they lose health, and the clones are much weaker. Damn, I see why you had trouble with these, Max.",
"textOriginal": "38:03 These things don't stagger? But each time they clone, they lose health, and the clones are much weaker. Damn, I see why you had trouble with these, Max.",
"parentId": "UgygOOysmSAraKnx81h4AaABAg",
"authorDisplayName": "Soma Cruz the Demigod of Balance",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnilg2dkOBvJqeTbW34CBoxURHLWv78fnbCRkArv=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCNaiemmWvNbzfaQm5e3hyqA",
"authorChannelId": {
"value": "UCNaiemmWvNbzfaQm5e3hyqA"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-07T18:08:01Z",
"updatedAt": "2021-05-07T18:08:01Z"
}
}
]
}
}
]
}
Comments
Comments ではコメント ID を直接指定してデータを取得します。上の例で取得した 5 つのコメント ID を「id」に指定してデータを取得してみます。
# -*- coding: utf-8 -*-
# Sample Python code for youtube.comments.list
# See instructions for running these code samples locally:
# https://developers.google.com/explorer-help/guides/code_samples#python
import os
import googleapiclient.discovery
def main():
# Disable OAuthlib's HTTPS verification when running locally.
# *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
api_service_name = "youtube"
api_version = "v3"
DEVELOPER_KEY = "YOUR_API_KEY"
youtube = googleapiclient.discovery.build(
api_service_name, api_version, developerKey = DEVELOPER_KEY)
request = youtube.comments().list(
part="id,snippet",
id="UgwDY44NUll4uiZXqqx4AaABAg,Ugx8sUuwqKqPVG9eSuJ4AaABAg,UgwP-4ucsrWh_iXJQMN4AaABAg,UgzTN_4ek7syWNNbCrB4AaABAg,UgygOOysmSAraKnx81h4AaABAg"
)
response = request.execute()
print(response)
if __name__ == "__main__":
main()
下記の様な JSON が返ってきます。CommentThreads の方ではコメントが投稿された動画の ID や、コメントに対する返信も含まれていましたが、Comments の方には含まれません。
{
"kind": "youtube#commentListResponse",
"etag": "vwaB3KAa_Snb_GuTkkMYrlL7Jrg",
"items": [
{
"kind": "youtube#comment",
"etag": "E9ovRZPTGOUQzHb0AEiKA26EJxY",
"id": "UgwDY44NUll4uiZXqqx4AaABAg",
"snippet": {
"textDisplay": "SO gooood",
"textOriginal": "SO gooood",
"authorDisplayName": "fatt musiek",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwngpQ-20jVq0c-9aC-wDJ87aTKi2QvPLTRN2GXGRaw=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCl3ha3zwY9p6CemIZZXIdXQ",
"authorChannelId": {
"value": "UCl3ha3zwY9p6CemIZZXIdXQ"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-22T18:48:34Z",
"updatedAt": "2021-05-22T18:48:34Z"
}
},
{
"kind": "youtube#comment",
"etag": "FG5oWvmMF39kDNl_rlnzb0bsSWM",
"id": "Ugx8sUuwqKqPVG9eSuJ4AaABAg",
"snippet": {
"textDisplay": "so what if really yuffie have met johnny hehe",
"textOriginal": "so what if really yuffie have met johnny hehe",
"authorDisplayName": "GregOrio Barachina",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnjgJE6zBYksYQWt8TmKlMDYOyG0t-BHPNWWmvUUPQ=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCUs2OJ4-KqYGS2EPJCDj7tQ",
"authorChannelId": {
"value": "UCUs2OJ4-KqYGS2EPJCDj7tQ"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-21T13:42:45Z",
"updatedAt": "2021-05-21T13:42:45Z"
}
},
{
"kind": "youtube#comment",
"etag": "WQw2UyILXAhkYOAl-AKScZi1pCY",
"id": "UgwP-4ucsrWh_iXJQMN4AaABAg",
"snippet": {
"textDisplay": "The Aerith and Cloud scene is much more meaningful than the one with Tifa. Still a good scene but come on...Aerith just appearing amongst the flowers and getting to see her again...priceless",
"textOriginal": "The Aerith and Cloud scene is much more meaningful than the one with Tifa. Still a good scene but come on...Aerith just appearing amongst the flowers and getting to see her again...priceless",
"authorDisplayName": "Maxx Doran",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnixfMDBxLt_TfUEjlpHhU-OvwE1vjCgpFBAVIMxjg=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCXcLTX_9fNHLVAMr_plxeqQ",
"authorChannelId": {
"value": "UCXcLTX_9fNHLVAMr_plxeqQ"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-18T01:50:04Z",
"updatedAt": "2021-05-18T01:50:04Z"
}
},
{
"kind": "youtube#comment",
"etag": "Vchl7kutnRgZb-uKYjMNMrJQ2qQ",
"id": "UgzTN_4ek7syWNNbCrB4AaABAg",
"snippet": {
"textDisplay": "You caught on to the magnify barrier idea so early. I was part way into hard mode before I thought of that.",
"textOriginal": "You caught on to the magnify barrier idea so early. I was part way into hard mode before I thought of that.",
"authorDisplayName": "Justin Edwards",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwngz1mU5zD3QHSRVU3jXTEZApnkYsmAzCKFXxUyD1w=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCO-oPQJCpNw87M6YbcuuFMw",
"authorChannelId": {
"value": "UCO-oPQJCpNw87M6YbcuuFMw"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-10T07:25:36Z",
"updatedAt": "2021-05-10T07:25:36Z"
}
},
{
"kind": "youtube#comment",
"etag": "pbfhdpIgB5QCKnr4Inkm_U2wbjQ",
"id": "UgygOOysmSAraKnx81h4AaABAg",
"snippet": {
"textDisplay": "Y'know Max, you COULD have just run 5k steps in Aerith's garden, checked what the Materia did, and moved on. Or, maybe, look up an online guide, since by now I'm sure SOMEONE has posted one.",
"textOriginal": "Y'know Max, you COULD have just run 5k steps in Aerith's garden, checked what the Materia did, and moved on. Or, maybe, look up an online guide, since by now I'm sure SOMEONE has posted one.",
"authorDisplayName": "Soma Cruz the Demigod of Balance",
"authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnilg2dkOBvJqeTbW34CBoxURHLWv78fnbCRkArv=s48-c-k-c0x00ffffff-no-rj",
"authorChannelUrl": "http://www.youtube.com/channel/UCNaiemmWvNbzfaQm5e3hyqA",
"authorChannelId": {
"value": "UCNaiemmWvNbzfaQm5e3hyqA"
},
"canRate": true,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2021-05-07T02:21:29Z",
"updatedAt": "2021-05-07T02:21:29Z"
}
}
]
}