c# - searching video from Youtube channel which are uploaded only in that channel depending on the video Name -
i trying search video present in channel based upon video name of particular video. when tried following code, seeing videos present in youtube related search keyword. want fetch videos present in channel. using required latest library
code here
private async task run() { var youtubeservice = new youtubeservice(new baseclientservice.initializer() { apikey = "my api key ",//"replace_me", applicationname = this.gettype().tostring() }); var searchlistrequest = youtubeservice.search.list("snippet"); searchlistrequest.q = "myvid"; // replace search term. searchlistrequest.maxresults = 50; // call search.list method retrieve results matching specified query term. var searchlistresponse = await searchlistrequest.executeasync(); list<string> videos = new list<string>(); list<string> channels = new list<string>(); list<string> playlists = new list<string>(); // add each result appropriate list, , display lists of // matching videos, channels, , playlists. foreach (var searchresult in searchlistresponse.items) { switch (searchresult.id.kind) { case "youtube#video": videos.add(string.format("{0} ({1})", searchresult.snippet.title, searchresult.id.videoid)); break; case "youtube#channel": channels.add(string.format("{0} ({1})", searchresult.snippet.title, searchresult.id.channelid)); break; case "youtube#playlist": playlists.add(string.format("{0} ({1})", searchresult.snippet.title, searchresult.id.playlistid)); break; } } console.writeline(string.format("videos:\n{0}\n", string.join("\n", videos))); console.writeline(string.format("channels:\n{0}\n", string.join("\n", channels))); console.writeline(string.format("playlists:\n{0}\n", string.join("\n", playlists))); } } }
according documentation, can use 'channelid' parameter in search request.
searchlistrequest.channelid = {your_channel_id};
(i'm not c# person. please check attribute name)
Comments
Post a Comment