YouTube API V3 - Get Featured Video for New Channel

Like YouTube’s official documentation on implementing and immigrating to API V3, they said:

YouTube Data API Functionality (v2): Get Video Recommendations
API v3 does not retrieve a list containing only videos recommended for the current API user. However, you can use the API v3 to search for recommended videos by calling the activity.list method and setting the value of the home parameter to true.

But now the parameter is also outdated. Currently, when I set the option to , I only get the recently uploaded video in the channel: Popular YouTube video . No videos from at all. homehometruesnippet.type=recommendation

I need to show the recommended video of an authenticated user in a new channel, but it seems that this feature is not fully recommended by YouTube. Does anyone have a solution for this?
Thanks first!

+6
source share
3 answers

Unfortunately, I cannot find any documentation or example about this function. It looks like it's out of date. However, you can check this documentation with a sample JSON structure that shows the format of an action resource, such as recommendation :

"recommendation": {
      "resourceId": {
        "kind": string,
        "videoId": string,
        "channelId": string,
},

Hope this helps!

+1
source

api . , "" .

youtube

Android. . setmine = true channelList ( ). , .

Android:

 YouTube youtube = new YouTube.Builder(transport, jsonFactory,
                    credential).setApplicationName(getString(R.string.app_name))
                    .build();

            YouTube.Activities.List activities;
            ActivityListResponse activityListResponse = null;
            List<ActivityData> activitiesData = new ArrayList<ActivityData>();

            try {
                /*
                 * Now that the user is authenticated, the app makes a
                 * channels list request to get the authenticated user's
                 * channel. Returned with that data is the playlist id for
                 * the uploaded videos.
                 * https://developers.google.com/youtube
                 * /v3/docs/channels/list
                 */

                ChannelListResponse clr = youtube.channels().list("contentDetails")
                        .setMine(true).execute();


               activities  = youtube.activities().list("id,snippet,subscriberSnippet");
                activities.setChannelId(clr.getItems().get(0).getId());

                activities.setMaxResults((long) 50);
                activityListResponse = activities.execute();

                ArrayList<String> subscriptionListIdentifier = new ArrayList<String>()
                        ,listTitles = new ArrayList<String>()
                        ,listThumbnails = new ArrayList<String>();

                List<Activity> results = activityListResponse.getItems();

                for (Activity activity : results) {
                    listTitles.add(activity.getSnippet().getTitle());
                    listThumbnails.add(activity.getSnippet().getThumbnails().getDefault().getUrl());
                    subscriptionListIdentifier.add(activity.getId());
                    //if ("public".equals(playlist.getStatus()
                    //        .getPrivacyStatus())) {
                    ActivityData data = new ActivityData();
                    data.setActivity(activity);
                    activitiesData.add(data);
                    //}
                }

                return activitiesData;
0

You can get them using the following API call:

GET https://www.googleapis.com/youtube/v3/activitiespart=snippet%2CcontentDetails&channelId={channel—_Id}&maxResults=25&regionCode=tw&key={YOUR_API_KEY}
0
source

Source: https://habr.com/ru/post/1016075/


All Articles