protected static bool ValidateYouTubeVideoAddressOptional(DataItemBase item) { string message = null; var value = item.DataControl.GetValue(); if (!IsNullOrWhiteSpace(value)) { if (value.IsValidYouTubeVideoUrl()) { var id = value.GetYouTubeVideoId(); var info = YouTubeVideoUtility.GetVideoInfo(id, true, 1); if (!info.IsValid) { message = YouTubeVideoInfo.VideoIdNotFoundMessage; } else if (!info.IsPublic) { message = YouTubeVideoInfo.VideoNotPublicMessage; } } else { message = "The URL is not a valid YouTube video URL"; } } if (IsNullOrWhiteSpace(message)) { item.DataControl.SetValue( Validation.StripWebProtocol(value)); } else { item.Feedback.PostValidationError(item.DataControl, message); } return(IsNullOrWhiteSpace(message)); }
protected static bool ValidateYouTubeAddressOptional(DataItemBase item) { string message = null; var value = item.DataControl.GetValue(); if (!IsNullOrWhiteSpace(value)) { if (value.IsValidYouTubeVideoUrl()) { var id = value.GetYouTubeVideoId(); var info = YouTubeVideoUtility.GetVideoInfo(id, true, 1); if (!info.IsValid) { message = YouTubeVideoInfo.VideoIdNotFoundMessage; } else if (!info.IsPublic) { message = YouTubeVideoInfo.VideoNotPublicMessage; } } else if (value.IsValidYouTubePlaylistUrl()) { var id = value.GetYouTubePlaylistId(); var info = YouTubeVideoUtility.GetPlaylistInfo(id, true, 1); if (!info.IsValid) { message = YouTubeVideoInfo.PlaylistIdNotFoundMessage; } else if (!info.IsPublic) { message = YouTubeVideoInfo.PlaylistNotPublicMessage; } } else if (value.IsValidYouTubeChannelUrl() || value.IsValidYouTubeCustomChannelUrl() || value.IsValidYouTubeUserChannelUrl()) { var id = YouTubeVideoUtility.LookupChannelId(value, 1); if (IsNullOrWhiteSpace(id)) { message = YouTubeVideoInfo.ChannelIdNotFoundMessage; } else { var info = YouTubeVideoUtility.GetChannelInfo(id, true, 1); if (!info.IsValid) { message = YouTubeVideoInfo.ChannelIdNotFoundMessage; } else if (!info.IsPublic) { message = YouTubeVideoInfo.ChannelNotPublicMessage; } } } else { message = "The URL is not a valid YouTube channel, playlist or video URL"; } } if (IsNullOrWhiteSpace(message)) { item.DataControl.SetValue( Validation.StripWebProtocol(value)); } else { item.Feedback.PostValidationError(item.DataControl, message); } return(IsNullOrWhiteSpace(message)); }