Esempio n. 1
0
        public async Task AddCommentAsync(VideoMetadataModel videoMetadata, CancellationToken cancellationToken)
        {
            _logger.LogTrace($"{GetType()} - BEGIN {nameof(AddVideoAsync)}");

            try
            {
                YouTubeService ytService = await _ytServiceProvider.CreateServiceAsync(cancellationToken);

                CommentThread commentThread = new CommentThread()
                {
                    Snippet = new CommentThreadSnippet
                    {
                        ChannelId       = _configuration.ChannelId,
                        VideoId         = GetVideoIdFromUrl(videoMetadata.VideoUrl),
                        TopLevelComment = new Comment
                        {
                            Snippet = new CommentSnippet
                            {
                                TextOriginal = videoMetadata.PinnedComment
                            }
                        }
                    }
                };

                CommentThreadsResource.InsertRequest req = ytService.CommentThreads.Insert(commentThread, SNIPPET_PART_PARAM);
                CommentThread res = await req.ExecuteAsync();
            }
            catch (Exception e)
            {
                _logger.LogError("An error occurred while adding comment to video", e);
                throw;
            }
        }
Esempio n. 2
0
        private async void UpdateAirtableForLiveDataBtn_Click(object sender, EventArgs e)
        {
            _logger.LogTrace($"{GetType()} - BEGIN {nameof(UpdateAirtableForLiveDataBtn_Click)}");
            if (!CheckSelectedRow())
            {
                return;
            }

            VideoMetadataModel res = await _videoService.GetUpcomingLiveAsync(CancellationToken.None);

            if (res != null && !string.IsNullOrEmpty(res.VideoUrl))
            {
                foreach (DataGridViewRow row in VideoDGV.SelectedRows)
                {
                    PublicationModel model = row.DataBoundItem as PublicationModel;
                    //model.LiveVideo.Identifier = res.Identifier;
                    model.LiveVideo.VideoUrl = res.VideoUrl;

                    //if (await _dataService.UpdateLiveVideoRecord(model.Id, model.LiveVideo))
                    //{
                    //    MessageBox.Show("Airtable a été mis à jour");
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Problème pendant la mise à jour de Airtable");

                    //}
                }
            }
            else
            {
                MessageBox.Show("¯\\(°_o)/¯ Attention, vidéo du live non trouvée. Airtable ne sera pas mis à jour.", "Live non trouvé");
            }
        }
Esempio n. 3
0
 public static void HydrateFromVideoModel(this Video video, VideoMetadataModel metadata)
 {
     video.Snippet             = video.Snippet is null ? new VideoSnippet() : video.Snippet;
     video.Snippet.Title       = metadata.VideoTitle;
     video.Snippet.Description = metadata.VideoDescription;
     video.Snippet.Tags        = metadata.Tags;
     video.Status = new VideoStatus {
         SelfDeclaredMadeForKids = false
     };
 }
Esempio n. 4
0
        public async Task <bool> UpdateMainVideoRecord(string recordId, VideoMetadataModel videoMetadata)
        {
            Dictionary <string, object> values = new Dictionary <string, object>();

            values.Add("[youtube] Titre", videoMetadata.VideoTitle);
            values.Add("[youtube] Description", videoMetadata.VideoDescription);
            values.Add("[youtube] URL", videoMetadata.VideoUrl);

            return(await _repository.UpdateRecord(recordId, values));
        }
Esempio n. 5
0
        public async Task <bool> UpdateLiveVideoRecord(string recordId, VideoMetadataModel videoMetadata)
        {
            _logger.LogTrace($"{GetType()} - BEGIN {nameof(UpdateLiveVideoRecord)}");

            Dictionary <string, object> values = new Dictionary <string, object>();

            values.Add("[live bonus] Titre", videoMetadata.VideoTitle);
            values.Add("[LIVE BONUS] Description", videoMetadata.VideoDescription);
            values.Add("[live bonus] URL", videoMetadata.VideoUrl);

            return(await _repository.UpdateRecord(recordId, values));
        }
Esempio n. 6
0
        public async Task <VideoMetadataModel> GetUpcomingLiveAsync(CancellationToken cancellationToken)
        {
            _logger.LogTrace($"{GetType()} - BEGIN {nameof(GetUpcomingLiveAsync)}");

            LiveBroadcast res = await GetUpcomingLiveInternalAsync(cancellationToken);

            if (res != null)
            {
                VideoMetadataModel metadata = _mapper.Map <VideoMetadataModel>(res);
                metadata.VideoUrl = BuildVideoUrl(res.Id);

                return(metadata);
            }

            return(null);
        }
Esempio n. 7
0
        public async Task UpdateVideoMetadataAsync(VideoMetadataModel videoMetadataModel, string chatMessage, CancellationToken cancellationToken)
        {
            _logger.LogTrace($"{GetType()} - BEGIN {nameof(UpdateVideoMetadataAsync)}");

            try
            {
                YouTubeService ytService = await _ytServiceProvider.CreateServiceAsync(cancellationToken);

                string videoId = GetVideoIdFromUrl(videoMetadataModel.VideoUrl);
                if (!string.IsNullOrEmpty(videoId))
                {
                    IEnumerable <VideoCategory> categories = await GetCategoriesAsync(cancellationToken);

                    VideoCategory category = categories.FirstOrDefault(c => c.Snippet.Title == videoMetadataModel.Category);

                    Video video = await GetVideoMetadataInternalAsync(videoId, cancellationToken);

                    video.HydrateFromVideoModel(videoMetadataModel);
                    video.Snippet.CategoryId = category.Id;

                    VideosResource.UpdateRequest req = ytService.Videos.Update(video, new string[] { "snippet", "status" });
                    await req.ExecuteAsync(cancellationToken);

                    if (!string.IsNullOrEmpty(chatMessage))
                    {
                        LiveChatMessage msg = new LiveChatMessage {
                            Snippet = new LiveChatMessageSnippet {
                                LiveChatId         = video.LiveStreamingDetails.ActiveLiveChatId,
                                Type               = "textMessageEvent",
                                TextMessageDetails = new LiveChatTextMessageDetails {
                                    MessageText = chatMessage
                                }
                            }
                        };
                        ytService.LiveChatMessages.Insert(msg, SNIPPET_PART_PARAM);
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError("An error occurred while updating video", e);
                throw;
            }
        }
Esempio n. 8
0
        internal Video(VideoMetadataModel videoMetadataModel, IDispatcher dispatcher)
        {
            Model = videoMetadataModel;

            this.dispatcher = dispatcher;
        }
Esempio n. 9
0
 public UploadStatusModel(VideoMetadataModel metadata) => Metadata = metadata;
Esempio n. 10
0
 public async Task CommentVideoAsync(VideoMetadataModel videoMetadata, CancellationToken cancellationToken) =>
 await _videoAdapter.AddCommentAsync(videoMetadata, cancellationToken);
Esempio n. 11
0
 public async Task UpdateVideoMetadataAsync(VideoMetadataModel videoMetadata, CancellationToken cancellationToken) =>
 await _videoAdapter.UpdateVideoMetadataAsync(videoMetadata, null, cancellationToken);
Esempio n. 12
0
 public static void DeleteVideoMetadata(this IDbConnection dbConnection, VideoMetadataModel model)
 {
     dbConnection.Delete(model);
 }
Esempio n. 13
0
 public static void InsertVideoMetadata(this IDbConnection dbConnection, VideoMetadataModel model)
 {
     dbConnection.Insert(model);
 }
Esempio n. 14
0
 private Video Video(VideoMetadataModel model)
 {
     return(new Video(model, dispatcher));
 }