Esempio n. 1
0
        private async Task GetAllVideo()
        {
            var youtubeService = await YoutubeServices.GetService();

            var searchVideo = youtubeService.PlaylistItems.List("snippet,contentDetails");

            searchVideo.PlaylistId = currentPlaylistID;
            searchVideo.MaxResults = 50;
            // Call the search.list method to retrieve results matching the specified query term.
            var searchListResponse = await searchVideo.ExecuteAsync();

            // Add each result to the appropriate list, and then display the lists of
            // matching videos, channels, and playlists.
            DateTime yesterday = DateTime.Now.AddDays(-1);

            foreach (var searchResult in searchListResponse.Items)
            {
                if (searchResult.Snippet.PublishedAt.Value.CompareTo(yesterday) > 0 && searchResult.Snippet.Title.Equals("Default Video Title"))
                {
                    Console.WriteLine("------------------------------------");
                    Console.WriteLine(searchResult.Snippet.Title);
                    Console.WriteLine(searchResult.Snippet.ResourceId.VideoId);
                    Console.WriteLine(searchResult.Snippet.PublishedAt);
                    videos.Add(searchResult.Snippet.ResourceId.VideoId);
                    Console.WriteLine("------------------------------------");
                }
            }
        }
Esempio n. 2
0
        private async Task RemoveVideo(string videoID)
        {
            try
            {
                var youtubeService = await YoutubeServices.GetService();

                var deleteVideo = youtubeService.Videos.Delete(videoID);
                // call the delete video
                var deleteResponse = await deleteVideo.ExecuteAsync();

                Console.WriteLine(deleteResponse);
            }catch (Exception ex)
            {
                throw new Exception("Failed to delete video \n ex = " + ex.Message);
            }
        }
Esempio n. 3
0
        private async Task GetPlaylistID()
        {
            String result = "";

            try
            {
                var youtubeService = await YoutubeServices.GetService();

                var searchPlaylist = youtubeService.Channels.List("snippet,contentDetails,statistics");
                searchPlaylist.Mine = true;

                var searchPlaylistResponse = await searchPlaylist.ExecuteAsync();

                foreach (var searchResult in searchPlaylistResponse.Items)
                {
                    result = (searchResult.ContentDetails.RelatedPlaylists.Uploads);
                }
            }catch (Exception ex)
            {
                throw new Exception("Failed to get the channel \n ex = " + ex.Message);
            }

            currentPlaylistID = result;
        }