public async Task <IActionResult> DeleteVideo(string videoId)
        {
            await videoDb.Connection.OpenAsync();

            var query  = new VideoQuery(videoDb);
            var result = await query.FindVideoAsync(videoId);

            if (result is null)
            {
                return(new NotFoundResult());
            }
            try
            {
                //Delet physical binary
                var filePath = "videos/" + result.ServerId + "/" + videoId;
                System.IO.File.Delete(filePath);
                //Delet in data base
                await result.DeleteAsync();
            }
            catch (System.Exception)
            {
                return(new NotFoundResult());
            }
            return(new OkResult());
        }
Example #2
0
        public async Task <SearchResponse> GetResults()
        {
            SearchResponse      response = new SearchResponse();
            List <SearchResult> result   = await LoadItems();

            List <string> videosId    = new List <string>();
            List <string> channelsId  = new List <string>();
            List <string> playlistsId = new List <string>();

            result.ForEach(item =>
            {
                switch (item.Id.Kind)
                {
                case "youtube#video":
                    videosId.Add(item.Id.VideoId);
                    break;

                case "youtube#channel":
                    channelsId.Add(item.Id.ChannelId);
                    break;

                case "youtube#playlist":
                    playlistsId.Add(item.Id.PlaylistId);
                    break;
                }
            });

            VideoQuery videoQuery = new VideoQuery
            {
                Part       = "snippet,contentDetails",
                Id         = string.Join(",", videosId),
                MaxResults = this.Query.MaxResults
            };
            VideoListResponse videoResponse = await service.GetVideoInfo(videoQuery);

            response.Videos.AddRange(videoResponse.Items);

            ChannelQuery channelQuery = new ChannelQuery
            {
                Part       = "snippet,statistics",
                Id         = string.Join(",", channelsId),
                MaxResults = this.Query.MaxResults
            };
            ChannelListResponse channelResponse = await service.GetChannelInfo(channelQuery);

            response.Channels.AddRange(channelResponse.Items);

            PlaylistQuery playlistQuery = new PlaylistQuery
            {
                Part       = "snippet,status,contentDetails",
                Id         = string.Join(",", playlistsId),
                MaxResults = this.Query.MaxResults
            };
            PlaylistListResponse playlistResponse = await service.GetPlaylistInfo(playlistQuery);

            response.Playlists.AddRange(playlistResponse.Items);

            return(response);
        }
        public async Task <IActionResult> GetVideo(string videoId)
        {
            await videoDb.Connection.OpenAsync();

            var query  = new VideoQuery(videoDb);
            var result = await query.FindVideoAsync(videoId);

            if (result is null)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
        public async Task <IActionResult> GetAllVideo(string id)
        {
            await videoDb.Connection.OpenAsync();

            var query  = new VideoQuery(videoDb);
            var result = await query.ReadAllVideosAsync(id);

            if (result is null || result.Count == 0)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
        public async Task <IActionResult> GetVideoBinary(string videoId)
        {
            await videoDb.Connection.OpenAsync();

            var query  = new VideoQuery(videoDb);
            var result = await query.FindVideoAsync(videoId);

            if (result is null)
            {
                return(new NotFoundResult());
            }

            // Open binary video
            byte[] fileBytes = System.IO.File.ReadAllBytes($"videos/{result.ServerId}/{videoId}");
            string fileName  = videoId;

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
Example #6
0
    private void Filter()
    {
        var catalog = m_Scripting.GetVideoCatalogService();

        VideoQuery query = new VideoQuery();

        VideoFileEntry[] videos = catalog.SearchVideos(query);

        long bin_id = CreateBin();

        foreach (VideoFileEntry entry in videos)
        {
            if (IsVideoPassingFilter(entry))
            {
                catalog.AddVideoToBin(entry.ID, bin_id);
            }
        }
    }
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            WebQuery   webQuery   = new WebQuery(tbxSearch.Text);
            ImageQuery imageQuery = new ImageQuery(tbxSearch.Text);
            VideoQuery videoQuery = new VideoQuery(tbxSearch.Text);


            webQuery.ResultSetSize.Value   = ResultSetSize.large;
            imageQuery.ResultSetSize.Value = ResultSetSize.large;
            videoQuery.ResultSetSize.Value = ResultSetSize.large;


            IGoogleResultSet <GoogleWebResult>   resultSet_Web   = GoogleService.Instance.Search <GoogleWebResult>(webQuery);
            IGoogleResultSet <GoogleImageResult> resultSet_Image = GoogleService.Instance.Search <GoogleImageResult>(imageQuery);
            IGoogleResultSet <GoogleVideoResult> resultSet_Video = GoogleService.Instance.Search <GoogleVideoResult>(videoQuery);

            lstResultsWeb.ItemsSource   = resultSet_Web.Results;
            lstResultsImage.ItemsSource = resultSet_Image.Results;
            lstResultsVideo.ItemsSource = resultSet_Video.Results;
        }
 public Results SearchVideos(VideoQuery query)
 {
     return _searcher.Search(query);
 }