使用 Apps 脚本高级 YouTube 服务列出我喜欢的所有 YouTube 视频
List all my liked YouTube videos with the Apps Script Advanced YouTube Service
我正在尝试获取我喜欢的 YouTube 视频列表。它们不归我所有,所以我无法搜索归我所有的视频。
“试试这个 API”中的 curl 信息是:
curl \
'h_ttps://youtube.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics
&myRating=like&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
我正在使用高级服务,所以我认为我不需要包含我的 API 密钥,因为它是请求中的内置密钥。
我尝试过的:
function getMyLikedVideos() {
var results;
results = YouTube.Search.list('snippet', {myRating: 'like', maxResults: 1});
Logger.log('results: ' + results);
}
它运行没有错误,但它 returns 我绝对不“喜欢”的视频。
结果:
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 1
},
"etag": "99999999999999999",
"items": [
{
"snippet": {
"description": "abcde",
"liveBroadcastContent": "none",
"publishTime": "2021-03-27T02:57:44Z",
"thumbnails": {
"default": {
"height": 90,
"url": "https://",
"width": 120
},
"high": {
"url": "https:",
"height": 360,
"width": 480
},
"medium": {
"height": 180,
"url": "h",
"width": 320
}
},
"publishedAt": "2021-03-27T02:57:44Z",
"channelTitle": "99999",
"title": "title here",
"channelId": "some ID"
},
"etag": "abcde",
"kind": "youtube#searchResult",
"id": {
"videoId": "999999",
"kind": "youtube#video"
}
}
],
"kind": "youtube#searchListResponse",
"regionCode": "ZZ",
"nextPageToken": "CAEQAA"
}
这是我用来获取我喜欢的视频的功能。
function getMyLikedVideos(maxNmbrToGet,dataToGet) {
var results;
maxNmbrToGet = maxNmbrToGet ? maxNmbrToGet : 10;
dataToGet = dataToGet ? dataToGet : "id";
//YouTube.Videos.list.list()
results = YouTube.Videos.list(dataToGet, {myRating: 'like', maxResults: maxNmbrToGet});
//Logger.log('results: ' + results);
Logger.log('results.items[0].id: ' + results.items[0].id);
return results.items;
}
我正在尝试获取我喜欢的 YouTube 视频列表。它们不归我所有,所以我无法搜索归我所有的视频。
“试试这个 API”中的 curl 信息是:
curl \
'h_ttps://youtube.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics
&myRating=like&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
我正在使用高级服务,所以我认为我不需要包含我的 API 密钥,因为它是请求中的内置密钥。
我尝试过的:
function getMyLikedVideos() {
var results;
results = YouTube.Search.list('snippet', {myRating: 'like', maxResults: 1});
Logger.log('results: ' + results);
}
它运行没有错误,但它 returns 我绝对不“喜欢”的视频。
结果:
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 1
},
"etag": "99999999999999999",
"items": [
{
"snippet": {
"description": "abcde",
"liveBroadcastContent": "none",
"publishTime": "2021-03-27T02:57:44Z",
"thumbnails": {
"default": {
"height": 90,
"url": "https://",
"width": 120
},
"high": {
"url": "https:",
"height": 360,
"width": 480
},
"medium": {
"height": 180,
"url": "h",
"width": 320
}
},
"publishedAt": "2021-03-27T02:57:44Z",
"channelTitle": "99999",
"title": "title here",
"channelId": "some ID"
},
"etag": "abcde",
"kind": "youtube#searchResult",
"id": {
"videoId": "999999",
"kind": "youtube#video"
}
}
],
"kind": "youtube#searchListResponse",
"regionCode": "ZZ",
"nextPageToken": "CAEQAA"
}
这是我用来获取我喜欢的视频的功能。
function getMyLikedVideos(maxNmbrToGet,dataToGet) {
var results;
maxNmbrToGet = maxNmbrToGet ? maxNmbrToGet : 10;
dataToGet = dataToGet ? dataToGet : "id";
//YouTube.Videos.list.list()
results = YouTube.Videos.list(dataToGet, {myRating: 'like', maxResults: maxNmbrToGet});
//Logger.log('results: ' + results);
Logger.log('results.items[0].id: ' + results.items[0].id);
return results.items;
}