Exemple #1
0
        public Google.Apis.YouTube.v3.YouTubeService GetApi(Account user)
        {
            var api = new Google.Apis.YouTube.v3.YouTubeService(new BaseClientService.Initializer()
            {
                ApplicationName = "Area",
                ApiKey          = "473291186491-5tiqjh1gb7uoiv717utbf8ibjgcvfbj0",
            });

            return(api);
        }
Exemple #2
0
 public YoutubeFeed()
 {
     _youtubeService =
         new YouTubeService(
             new BaseClientService.Initializer
     {
         ApiKey          = "AIzaSyD0E4ozDor6cgdyQKHvOgLCrrQMEX226Qc",
         ApplicationName = "YouCast2",
     });
 }
Exemple #3
0
 public YoutubeFeed(string applicationName, string apiKey)
 {
     _youtubeClient  = new YoutubeClient();
     _youtubeService =
         new YouTubeService(
             new BaseClientService.Initializer
     {
         ApiKey          = apiKey,
         ApplicationName = applicationName
     });
 }
Exemple #4
0
 public YoutubeFeed()
 {
     _youtubeService =
         new YouTubeService(
             new BaseClientService.Initializer
     {
         ApiKey          = "AIzaSyD0E4ozDor6cgdyQKHvOgLCrrQMEX226Qc",
         ApplicationName = "YouCast2",
     });
     _converter  = new VideoConverter();
     _downloader = new YoutubeVideoDownloader(_youtubeService);
 }
        public YoutubeFeed()
        {
            _youtubeClient  = new YoutubeClient();
            _youtubeService =
                new YouTubeService(
                    new BaseClientService.Initializer
            {
                ApiKey          = "AIzaSyD0E4ozDor6cgdyQKHvOgLCrrQMEX226Qc",
                ApplicationName = "YouCast2",
            });

            Logger.Info($"{nameof(YoutubeFeed)} created");
        }
Exemple #6
0
        public YoutubeFeed()
        {
            _feedCache    = new Cache <Arguments, SyndicationFeedFormatter>(15.Minutes());
            _contentCache = new Cache <(string videoId, string encoding), string>(2.Hours());

            _youtubeClient  = new YoutubeClient();
            _youtubeService =
                new YouTubeService(
                    new BaseClientService.Initializer
            {
                ApiKey          = "AIzaSyD0E4ozDor6cgdyQKHvOgLCrrQMEX226Qc",
                ApplicationName = "YouCast2",
            });
        }
Exemple #7
0
        private async Task <IEnumerable <Google.Apis.YouTube.v3.Data.Video> > GetVideoInformation(string parts, string ids)
        {
            var service = new Google.Apis.YouTube.v3.YouTubeService(new BaseClientService.Initializer
            {
                ApplicationName = _appName,
                ApiKey          = _apiKey,
            });
            var videosRequest = service.Videos.List(parts);

            videosRequest.Id = ids;
            var videos = await videosRequest.ExecuteAsync();

            return(videos.Items.AsEnumerable());
        }
Exemple #8
0
        private async Task <IEnumerable <Channel> > GetChannelInformation(string parts, string ids)
        {
            var service = new Google.Apis.YouTube.v3.YouTubeService(new BaseClientService.Initializer
            {
                ApplicationName = _appName,
                ApiKey          = _apiKey,
            });
            var channelsRequest = service.Channels.List(parts);

            channelsRequest.Id = ids;
            var channels = await channelsRequest.ExecuteAsync();

            return(channels.Items.AsEnumerable());
        }
Exemple #9
0
        public YoutubeFeed(string applicationName, string apiKey)
        {
            _feedCache    = new Cache <Arguments, SyndicationFeedFormatter>(15.Minutes());
            _contentCache = new Cache <(string videoId, string encoding), string>(2.Hours());

            _youtubeClient  = new YoutubeClient();
            _youtubeService =
                new YouTubeService(
                    new BaseClientService.Initializer
            {
                ApiKey          = apiKey,
                ApplicationName = applicationName
            });
        }
Exemple #10
0
        private async Task <IEnumerable <Google.Apis.YouTube.v3.Data.Video> > GetPlaylistVideos(string playlistId)
        {
            var service = new Google.Apis.YouTube.v3.YouTubeService(new BaseClientService.Initializer
            {
                ApplicationName = _appName,
                ApiKey          = _apiKey,
            });
            var playlistVideos = service.PlaylistItems.List("contentDetails");

            playlistVideos.Id = playlistId;
            var results = await playlistVideos.ExecuteAsync();

            var videoIds = results.Items.Select(x => x.ContentDetails.VideoId);
            var idString = StringifyIds(videoIds);

            if (string.IsNullOrEmpty(idString))
            {
                return(Enumerable.Empty <Google.Apis.YouTube.v3.Data.Video>());
            }
            var videos = await GetVideoInformation("", idString);

            return(videos);
        }
Exemple #11
0
        public static string GetYTURLForMovie(Movie movie)
        {
            // https://www.youtube.com/embed/6vQgHBugHxA?autoplay=0
            string url = "";

            if (movie.Videos.Results.Count > 0)
            {
                foreach (var result in movie.Videos.Results)
                {
                    if (result.Site == "YouTube")
                    {
                        url = "https://www.youtube.com/embed/" + result.Key + "?autoplay=0";
                    }
                }
            }
            if (url == "")
            {
                var youtubeService = new Google.Apis.YouTube.v3.YouTubeService(new BaseClientService.Initializer()
                {
                    ApiKey          = ConfigurationManager.AppSettings["APIKey"],
                    ApplicationName = "DruMreLab1"
                });

                var searchListRequest = youtubeService.Search.List("id, snippet");
                searchListRequest.Q          = movie.Title; // Replace with your search term.
                searchListRequest.MaxResults = 1;

                //you need to create the service object earlier
                var request = youtubeService.Videos.List("statistics,snippet");

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

                List <string> videos = new List <string>();
                //List<string> channels = new List<string>();
                //List<string> playlists = new List<string>();

                // Add each result to the appropriate list, and then display the lists of
                // matching videos, channels, and playlists.
                foreach (var searchResult in searchListResponse.Items)
                {
                    switch (searchResult.Id.Kind)
                    {
                    case "youtube#video":
                        request.Id = searchResult.Id.VideoId;
                        var response = request.Execute();
                        foreach (var video in response.Items)
                        {
                            if (video.Statistics != null)
                            {
                                var count = video.Statistics.ViewCount;
                            }
                        }
                        videos.Add("https://www.youtube.com/embed/" + searchResult.Id.VideoId + "?autoplay=0");
                        break;

                    case "youtube#channel":
                        //channels.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.ChannelId));
                        break;

                    case "youtube#playlist":
                        //playlists.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.PlaylistId));
                        break;
                    }

                    //Console.WriteLine(String.Format("Videos:\n{0}\n", string.Join("\n", videos)));
                    //Console.WriteLine(String.Format("Channels:\n{0}\n", string.Join("\n", channels)));
                    //Console.WriteLine(String.Format("Playlists:\n{0}\n", string.Join("\n", playlists)));
                    return(videos[0]);
                }
            }
            return(url);
        }