/// <summary>
        /// Pulls a list of video shows
        /// </summary>
        /// <param name="apiKey">API key unique to the user</param>
        /// <returns></returns>
        public static async Task <VideoGroupingsResponse> GetVideoShowsAsync(string apiKey)
        {
            VideoGroupingsResponse response = null;

            try
            {
                var uri = new Uri("https://www.giantbomb.com/api/video_shows/?format=json&api_key=" + apiKey);
                response = await Utilities.HttpRequestAgent.GetDeserializedResponseAsync <VideoGroupingsResponse>(uri);
            }
            catch (Exception e)
            {
                Serilog.Log.Error(e, "Error pulling video shows");
            }

            return(response);
        }
Ejemplo n.º 2
0
        public async Task InitializeAsync()
        {
            IsLoading = true;

            _apiKey = Services.ApiKeyManager.GetInstance().GetSavedApiKey();

            VideoGroupingsResponse response = null;

            switch (_pageType)
            {
            case GroupingType.Category:
                response = await GiantBombApi.Services.VideoRetrievalAgent.GetVideoCategoriesAsync(_apiKey);

                break;

            case GroupingType.Show:
            default:
                response = await GiantBombApi.Services.VideoRetrievalAgent.GetVideoShowsAsync(_apiKey);

                break;
            }

            if ((response != null) && (response.Status == StatusCode.OK) && (response.Results != null))
            {
                var viewModels = new List <VideoGroupViewModel>();

                foreach (var group in response.Results)
                {
                    Uri imageLocation = null;
                    group.GroupingType = _pageType;
                    if (group.Image == null)
                    {
                        imageLocation = Services.VideoGroupImageProvider.GetImageForGroupName(group.Title);
                    }
                    else
                    {
                        // Get the override image if we're using one. Otherwise, use the image that's provided.
                        imageLocation = Services.VideoGroupImageProvider.GetOverrideImageForGroupName(group.Title);

                        if (imageLocation == null)
                        {
                            if (!String.IsNullOrWhiteSpace(group.Image.SuperUrl))
                            {
                                imageLocation = new Uri(group.Image.SuperUrl);
                            }
                            else if (!String.IsNullOrWhiteSpace(group.Image.MediumUrl))
                            {
                                imageLocation = new Uri(group.Image.MediumUrl);
                            }
                            else if (!String.IsNullOrWhiteSpace(group.Image.SmallUrl))
                            {
                                imageLocation = new Uri(group.Image.SmallUrl);
                            }
                        }
                    }

                    var cat = new VideoGroupViewModel
                    {
                        Title         = group.Title,
                        Description   = group.Deck,
                        Id            = group.Id,
                        ImageLocation = imageLocation,
                        Order         = group.Position,
                        Source        = group
                    };

                    viewModels.Add(cat);
                }

                // Now time to order the list
                var orderedList = viewModels.OrderBy(x => x.Order);
                foreach (var group in orderedList)
                {
                    _groups.Add(group);
                }
            }

            IsLoading = false;
        }