按标题获取 Youtube 播放列表 [英] Get Youtube playlist by Title

查看:32
本文介绍了按标题获取 Youtube 播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个名为我非常独特的标题"的私人 YouTube 播放列表.我能够创建私人播放列表.但我只想在它还不存在的情况下创建它.所以我接下来要做的是获取私人播放列表.我可以使用以下查询检索授权用户的私人播放列表:

I'd like to create a private youtube playlist with the title 'my very unique title'. I'm able to create private playlists. But I'd like to create it only if it doesn't exists yet. So next thing I've done is getting the private playlists. I can retrieve the private playlists of an authorized user with the following query:

var q = 'my very unique title';

var request = gapi.client.youtube.playlists.list({
 // mine: true indicates that we want to retrieve the channel for the authenticated user.
   mine: 'true',
   part: 'snippet',
   maxResults: 10,
   //q : q //it was worth a try, no? :-) 
 });
request.execute(function(response) {
   playlistId = response.result.items[0].id;
   console.log("playlistid: "+playlistId);
 });

我的问题是:如何在 youtube api 中查询带有标题的播放列表 ID,例如我非常独特的标题"?我必须自己循环结果吗?我已阅读文档 https://developers.google.com/youtube/v3/docs/playlists/list但还没有找到任何关于按标题过滤的信息.

My question is: how can I query the youtube api for a playlistId with title e.g "my very unique title"? Do I have to loop the results myself? I've read the documentation https://developers.google.com/youtube/v3/docs/playlists/list but haven't found anything about filtering by title.

感谢您的帮助

推荐答案

进行直接词搜索的唯一方法是使用搜索"参数(信息找到 此处).
但这将返回所有 youtube,每次搜索的配额成本为 100.

Only way to do a direct word search is with the "search" parameter ( info found HERE).
But this will return for ALL of youtube and has a 100 Quota cost per search.

我建议使用playlists.list"进行搜索.
然后你可以查看每一个你的标题".

I would recommend to use the "playlists.list" to do your search.
Then you can look at each one for your "title".

[items] => Array
    (
        [0] => Array
            (
                [kind] => youtube#playlist
                [etag] => "uQc-MPTsstrHkQcRXL3IWLmeNsM/26W6-xxxxxxxx"
                [id] => PLsxxxxxxxxxxxxxxxxxxxxxx
                [snippet] => Array
                    (
                        [publishedAt] => some date
                        [channelId] => channelId
                        [title] => title you are looking for
                        [description] => Some description
                        [thumbnails] => Array

首先将是 [0] 个节点,如果有那么多,则直到节点 [49].
是的,您需要一次遍历每个节点的结果.

First will be [0] node, up to node [49] if that many.
And yes you will need to loop through the results each node at a time.

这篇关于按标题获取 Youtube 播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆