Esempio n. 1
0
        protected override void SetProperties(Comment response)
        {
            if (response == null)
            {
                return;
            }

            _rawData = response;
            _id      = response.Id;
            _kind    = response.Kind;

            if (response.Snippet == null)
            {
                return;
            }

            _publishedAt           = response.Snippet.PublishedAt.GetValueOrDefault();
            _authorChannelId       = response.Snippet.AuthorChannelId?.Value;
            _authorChannelUrl      = response.Snippet.AuthorChannelUrl;
            _authorDisplayName     = response.Snippet.AuthorDisplayName;
            _authorProfileImageUrl = response.Snippet.AuthorProfileImageUrl;
            _channelId             = response.Snippet.ChannelId;
            _likeCount             = response.Snippet.LikeCount.GetValueOrDefault();
            _parentId    = response.Snippet.ParentId;
            _textDisplay = response.Snippet.TextDisplay;
            _updatedAt   = response.Snippet.UpdatedAt.GetValueOrDefault();
            _videoId     = response.Snippet.VideoId;

            _url       = GetUrl(_videoId, _id);
            _parentUrl = GetUrl(_videoId, _parentId);
            _videoUrl  = YoutubeVideo.GetUrl(_videoId);
        }
Esempio n. 2
0
        public static string GetUrl(string videoId, string id)
        {
            if (string.IsNullOrEmpty(videoId))
            {
                return(null);
            }
            var lc = string.IsNullOrEmpty(id) ? string.Empty : string.Format(_commentUrl, id);

            return(YoutubeVideo.GetUrl(videoId) + lc);
        }
        public YoutubePlaylistItem(PlaylistItem response)
        {
            if (response == null)
            {
                return;
            }

            RawData = response;
            Id      = response.Id;
            Kind    = response.Kind;

            if (response.Snippet == null)
            {
                return;
            }

            ItemKind     = (response.Snippet.ResourceId?.Kind).GetValueOrDefault();
            ItemId       = response.Snippet.ResourceId?.Id();
            PublishedAt  = response.Snippet.PublishedAt.GetValueOrDefault();
            ChannelId    = response.Snippet.ChannelId;
            Title        = response.Snippet.Title;
            Description  = response.Snippet.Description;
            ChannelTitle = response.Snippet.ChannelTitle;
            PlaylistId   = response.Snippet.PlaylistId;
            Position     = response.Snippet.Position;
            Thumbnails   = response.Snippet.Thumbnails?.Clone();

            Thumbnail defaultThumbnail = null;

            Thumbnails?.TryGetValue(ThumbnailSize.Default, out defaultThumbnail);
            DefaultThumbnail = defaultThumbnail;

            switch (ItemKind)
            {
            case ResourceKind.Channel: Url = YoutubeChannel.GetUrl(Id); break;

            case ResourceKind.Playlist: Url = YoutubePlaylist.GetUrl(Id); break;

            case ResourceKind.Video: Url = YoutubeVideo.GetUrl(Id); break;

            default: throw new InvalidOperationException();
            }
        }
Esempio n. 4
0
        public YoutubeSearchResult(SearchResult response)
        {
            if (response == null)
            {
                return;
            }

            RawData    = response;
            Kind       = response.Kind;
            ResultKind = response.Id.Kind;
            Id         = response.Id.Id();

            switch (ResultKind)
            {
            case ResourceKind.Channel: Url = YoutubeChannel.GetUrl(Id); break;

            case ResourceKind.Playlist: Url = YoutubePlaylist.GetUrl(Id); break;

            case ResourceKind.Video: Url = YoutubeVideo.GetUrl(Id); break;

            default: throw new InvalidOperationException();
            }

            if (response.Snippet == null)
            {
                return;
            }

            PublishedAt  = response.Snippet.PublishedAt.GetValueOrDefault();
            ChannelId    = response.Snippet.ChannelId;
            Title        = response.Snippet.Title;
            Description  = response.Snippet.Description;
            ChannelTitle = response.Snippet.ChannelTitle;
            Thumbnails   = response.Snippet.Thumbnails?.Clone();

            Thumbnail defaultThumbnail = null;

            Thumbnails?.TryGetValue(ThumbnailSize.Default, out defaultThumbnail);
            DefaultThumbnail = defaultThumbnail;
        }