コード例 #1
0
        public static async Task <ClipResponse> GetPlaylistClipsAndHeaders(string playlistId)
        {
            var clips = await MakeApiCallGet(String.Format(ServiceAccessor.URL_SERVICE_GET_CLIPS, playlistId, "0"), true);

            if (!string.IsNullOrEmpty(clips) && clips != NO_CONNECTION)
            {
                try
                {
                    var obj = JsonConvert.DeserializeObject <ClipResponseDTO>(clips);
                    BindableCollection <Clip> clipCollection = new BindableCollection <Clip>();
                    foreach (ClipDTO clipDTO in obj.ClipsList.Clips)
                    {
                        Clip c = Clip.FromDTO(clipDTO, obj.DisplayColumns);
                        if (c != null)
                        {
                            clipCollection.Add(c);
                        }
                    }
                    return(new ClipResponse {
                        status = SERVICE_RESPONSE.SUCCESS, clips = clipCollection, DisplayColumns = obj.DisplayColumns
                    });
                }
                catch (Exception e)
                {
                    return(new ClipResponse {
                        status = SERVICE_RESPONSE.DESERIALIZATION
                    });
                }
            }
            else if (clips == NO_CONNECTION)
            {
                return(new ClipResponse {
                    status = SERVICE_RESPONSE.NO_CONNECTION
                });
            }
            else
            {
                return(new ClipResponse {
                    status = SERVICE_RESPONSE.NULL_RESPONSE
                });
            }
        }
コード例 #2
0
        public static async Task <List <Clip> > GetAdditionalPlaylistClips(string playlistID, int startIndex)
        {
            var clips = await MakeApiCallGet(String.Format(ServiceAccessor.URL_SERVICE_GET_CLIPS, playlistID, startIndex.ToString()), false);

            if (clips != NO_CONNECTION)
            {
                var         clipResponseDTO = JsonConvert.DeserializeObject <ClipResponseDTO>(clips);
                List <Clip> clipCollection  = new List <Clip>();
                if (clipResponseDTO.ClipsList.Clips.Count == 100)
                {
                    foreach (ClipDTO clipDTO in clipResponseDTO.ClipsList.Clips)
                    {
                        Clip c = Clip.FromDTO(clipDTO, clipResponseDTO.DisplayColumns);
                        if (c != null)
                        {
                            clipCollection.Add(c);
                        }
                    }
                    var additionalClips = await GetAdditionalPlaylistClips(playlistID, startIndex + 100);

                    foreach (Clip c in additionalClips)
                    {
                        clipCollection.Add(c);
                    }
                    return(clipCollection);
                }
                else
                {
                    foreach (ClipDTO clipDTO in clipResponseDTO.ClipsList.Clips)
                    {
                        Clip c = Clip.FromDTO(clipDTO, clipResponseDTO.DisplayColumns);
                        if (c != null)
                        {
                            clipCollection.Add(c);
                        }
                    }
                    return(clipCollection);
                }
            }
            return(new List <Clip>());
        }