Exemplo n.º 1
0
        public async void UpdateFeaturedChannels()
        {
            var service = await YoutubeMethodsStatic.GetServiceAsync();


            try
            {
                var methods = new YoutubeMethods();

                string FeaturedChannelIds = "";
                foreach (var Id in channel.BrandingSettings.Channel.FeaturedChannelsUrls)
                {
                    FeaturedChannelIds += Id + ",";
                }

                var getChannels = service.Channels.List("snippet,statistics");
                getChannels.Id = FeaturedChannelIds.Remove(FeaturedChannelIds.Length - 1, 1);
                var featuredChannelsResponse = getChannels.Execute();

                foreach (var featuredChannel in featuredChannelsResponse.Items)
                {
                    featuredChannelsTemp.Add(methods.ChannelToYoutubeChannel(featuredChannel));
                }
            }
            catch (Exception ex)
            {
                Log.Error("Featured channels failed to load");
                Log.Error(JsonConvert.SerializeObject(channel));
                Log.Error(ex.Message);
            }
        }
        private async void SearchAddMore()
        {
            var youtubeService = await YoutubeMethodsStatic.GetServiceAsync();

            if (addingVideos == true)
            {
                return;
            }

            addingVideos = true;

            var searchListRequest = youtubeService.Search.List("snippet");

            searchListRequest.Q          = Constants.MainPageRef.SearchBox.Text;
            searchListRequest.PageToken  = nextPageToken;
            searchListRequest.MaxResults = 25;

            // Call the search.list method to retrieve results matching the specified query term.
            var searchListResponse = await searchListRequest.ExecuteAsync();

            nextPageToken = searchListResponse.NextPageToken;

            ObservableCollection <YoutubeItemDataType> tempList = new ObservableCollection <YoutubeItemDataType>();

            var methods = new YoutubeMethods();

            foreach (var searchResult in searchListResponse.Items)
            {
                if (searchResult.Id.Kind == "youtube#video")
                {
                    var data = methods.VideoToYoutubeItem(searchResult);
                    tempList.Add(data);
                    SearchResultsList.Add(data);
                }
                else if (searchResult.Id.Kind == "youtube#channel")
                {
                    var data = methods.ChannelToYoutubeChannel(searchResult, youtubeService);
                    SearchResultsList.Add(data);
                }
            }

            methods.FillInViews(tempList, youtubeService);

            foreach (var item in tempList)
            {
                SearchResultsList.Add(item);
            }

            addingVideos = false;
        }