Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Getting videos from Youtube official Channels

$
0
0

There are some Youtube official channels like Music, Games, News, etc. I'm trying to get the information of this channels like if it's a normal channel but it's sending me null responses. It might be because the channel videos are not owned by the channel even if it shows you them as "uploaded videos". This is my code which works with "normal" channels: (String ids means the id of each video comma separated)

This method gives the videos of the channel videos and it's working with "normal" channels.

public static ArrayList<VideoYoutube> getVideos (String ids) throws IOException{    try    {        YouTube.Videos.List videos = youtube.videos().list("id,snippet,statistics");        videos.setKey(API_KEY);        //Setting all the video ids we want to get back        videos.setId(ids);        videos.setMaxResults(RETURN_NUMBER);        //Setting all the fields we want to be called from the api. Its such an        videos.setFields("items(id,snippet/publishedAt,snippet/title,snippet/description," +"snippet/thumbnails/default/url,snippet/thumbnails/medium/url,snippet/thumbnails/high/url," +"snippet/channelId,snippet/channelTitle,statistics/viewCount,statistics/likeCount,statistics/dislikeCount," +"statistics/favoriteCount,statistics/commentCount)");        VideoListResponse videoResponse = videos.execute();        List<Video> videoResultList = videoResponse.getItems();}

And this is the method that is supposed to retrieve the video ids from the channel I want. It's giving null for this exact channel but it's working with "normal" channels.

public static String getChannelVideosIds(String channelId) throws IOException{    YouTube.Search.List search = youtube.search().list("id");    //Define the search key    search.setKey(API_KEY);    search.setChannelId(channelId);    //Give the type (video, playlist or channel)    search.setType("video");    //Giving the params we want to be returned comma separated (for example if we had chosen the snipped before, we could choose snipped fields like snipped/publishedAt)    search.setFields("items(id)");    //Set the max return number    search.setMaxResults(RETURN_NUMBER);    //Execute the search query    SearchListResponse searchResponse = search.execute();    List<SearchResult> searchResultList = searchResponse.getItems();    //Check if the result is null    return retrieveIds(searchResultList);}

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>