Search in sources :

Example 1 with VideoFavoritesResponse

use of com.zype.fire.api.Model.VideoFavoritesResponse in project zype-firebuilder by zype.

the class ZypeDataDownloaderHelper method loadFavoriteVideos.

public static VideosResult loadFavoriteVideos(String favoritesPlaylistId, String consumerId, String accessToken, int page) {
    Log.d(TAG, "loadFavoriteVideos(): consumerId=" + consumerId);
    VideosResult result = new VideosResult();
    result.nextPage = page;
    boolean loadNext = true;
    while (loadNext) {
        VideoFavoritesResponse response = ZypeApi.getInstance().getVideoFavorites(consumerId, accessToken, result.nextPage);
        if (response != null) {
            Log.d(TAG, "loadFavoriteVideos(): size=" + response.videoFavorites.size());
            if (result.videos == null) {
                result.videos = new ArrayList<>();
            }
            if (response.pagination.current >= response.pagination.pages) {
                result.nextPage = -1;
            } else {
                result.nextPage = response.pagination.next;
            }
            for (VideoFavoriteData data : response.videoFavorites) {
                VideoResponse responseVideo = ZypeApi.getInstance().getVideo(data.videoId);
                if (responseVideo != null) {
                    VideoData videoData = responseVideo.videoData;
                    if (TextUtils.isEmpty(videoData.description) || videoData.description.equals("null")) {
                        videoData.description = " ";
                    }
                    videoData.playlistId = favoritesPlaylistId;
                    videoData.playerUrl = "null";
                    videoData.videoFavoriteId = data.id;
                    result.videos.add(videoData);
                } else {
                    Log.e(TAG, "loadFavoriteVideos(): error loading video, id=" + data.videoId);
                }
            }
        } else {
            Log.e(TAG, "loadFavoriteVideos(): failed");
            return null;
        }
        // Load all favorites
        loadNext = !(result.nextPage == -1);
    }
    return result;
}
Also used : VideoFavoriteData(com.zype.fire.api.Model.VideoFavoriteData) VideoFavoritesResponse(com.zype.fire.api.Model.VideoFavoritesResponse) VideoResponse(com.zype.fire.api.Model.VideoResponse) VideoData(com.zype.fire.api.Model.VideoData)

Example 2 with VideoFavoritesResponse

use of com.zype.fire.api.Model.VideoFavoritesResponse in project zype-firebuilder by zype.

the class ZypeApi method getVideoFavorites.

public VideoFavoritesResponse getVideoFavorites(String consumerId, String accessToken, int page) {
    try {
        HashMap<String, String> params = new HashMap<>();
        params.put(ACCESS_TOKEN, accessToken);
        params.put(PAGE, String.valueOf(page));
        params.put(PER_PAGE, String.valueOf(PER_PAGE_DEFAULT));
        params.put("sort", "created_at");
        params.put("order", "desc");
        Response response = apiImpl.getVideoFavorites(consumerId, params).execute();
        if (response.isSuccessful()) {
            return (VideoFavoritesResponse) response.body();
        } else {
            return null;
        }
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Response(retrofit2.Response) VideoFavoritesResponse(com.zype.fire.api.Model.VideoFavoritesResponse) ChannelResponse(com.zype.fire.api.Model.ChannelResponse) DevicePinResponse(com.zype.fire.api.Model.DevicePinResponse) VideosResponse(com.zype.fire.api.Model.VideosResponse) AppResponse(com.zype.fire.api.Model.AppResponse) VideoResponse(com.zype.fire.api.Model.VideoResponse) VideoEntitlementsResponse(com.zype.fire.api.Model.VideoEntitlementsResponse) PlaylistsResponse(com.zype.fire.api.Model.PlaylistsResponse) ProgramResponse(com.zype.fire.api.Model.ProgramResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse) ZobjectContentResponse(com.zype.fire.api.Model.ZobjectContentResponse) PlanResponse(com.zype.fire.api.Model.PlanResponse) PlaylistResponse(com.zype.fire.api.Model.PlaylistResponse) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ZobjectTopPlaylistResponse(com.zype.fire.api.Model.ZobjectTopPlaylistResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) VideoFavoritesResponse(com.zype.fire.api.Model.VideoFavoritesResponse) HashMap(java.util.HashMap) IOException(java.io.IOException)

Aggregations

VideoFavoritesResponse (com.zype.fire.api.Model.VideoFavoritesResponse)2 VideoResponse (com.zype.fire.api.Model.VideoResponse)2 AccessTokenInfoResponse (com.zype.fire.api.Model.AccessTokenInfoResponse)1 AccessTokenResponse (com.zype.fire.api.Model.AccessTokenResponse)1 AppResponse (com.zype.fire.api.Model.AppResponse)1 ChannelResponse (com.zype.fire.api.Model.ChannelResponse)1 ConsumerResponse (com.zype.fire.api.Model.ConsumerResponse)1 DevicePinResponse (com.zype.fire.api.Model.DevicePinResponse)1 PlanResponse (com.zype.fire.api.Model.PlanResponse)1 PlaylistResponse (com.zype.fire.api.Model.PlaylistResponse)1 PlaylistsResponse (com.zype.fire.api.Model.PlaylistsResponse)1 ProgramResponse (com.zype.fire.api.Model.ProgramResponse)1 VideoData (com.zype.fire.api.Model.VideoData)1 VideoEntitlementsResponse (com.zype.fire.api.Model.VideoEntitlementsResponse)1 VideoFavoriteData (com.zype.fire.api.Model.VideoFavoriteData)1 VideosResponse (com.zype.fire.api.Model.VideosResponse)1 ZobjectContentResponse (com.zype.fire.api.Model.ZobjectContentResponse)1 ZobjectTopPlaylistResponse (com.zype.fire.api.Model.ZobjectTopPlaylistResponse)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1