private static string GetVideoTitle(string pageSource) { string videoTitle = null; try { const string videoTitlePattern = @"\<meta name=""title"" content=""(?<title>.*)""\>"; var videoTitleRegex = new Regex(videoTitlePattern, RegexOptions.IgnoreCase); Match videoTitleMatch = videoTitleRegex.Match(pageSource); if (videoTitleMatch.Success) { videoTitle = videoTitleMatch.Groups["title"].Value; videoTitle = HttpHelper.HtmlDecode(videoTitle); // Remove the invalid characters in file names // In Windows they are: \ / : * ? " < > | videoTitle = Regex.Replace(videoTitle, @"[:\*\?""\<\>\|]", String.Empty); videoTitle = videoTitle.Replace("\\", "-").Replace("/", "-").Trim(); } } catch (Exception) { videoTitle = null; } return(videoTitle); }