October 5, 2015

Get YouTube Video Name by Video ID

public string GetVideoName(string VideoID)
        {
            RestRequest request = new RestRequest(Method.GET)
            {
                Resource = "youtube/v3/videos?id=" + VideoID + "&key="+ API_KEY + "&part=snippet,recordingDetails",
                RequestFormat = DataFormat.Json
            };

            var response = _client.Execute(request) as RestResponse;

            JObject joResponse = JObject.Parse(response.Content.ToString());
            string VideoName = (string)joResponse["items"][0]["snippet"]["title"];

            return VideoName;
        }

Just pass Video ID in above method you will get Video Name as response.

No comments:

Post a Comment