public override ISource Create(Uri uri, string pageData) { Match m = PathAndQueryRegex.Match(uri.PathAndQuery); int id = int.Parse(m.Groups["id"].Value); string showIcon = pageData.GetStringBetween("<div id=\"ShowIcon\">", " src=\"", "\""); string showTitle = pageData.GetStringBetween("<div id=\"ShowTitle\">", ">", "<"); int index = 0; string showInfoLinks = pageData.GetStringBetween("<div id=\"ShowInfoLinks\">", "</div>"); string showHref = showInfoLinks.GetStringBetween(ref index, "href=\"", "\""); string showArchiveHref = showInfoLinks.GetStringBetween(ref index, "href=\"", "\""); string title = pageData.GetStringBetween("player.setPostsTitle(\"", "\""); string description = pageData.GetStringBetween("<meta name=\"description\" content=\"", "\""); string thumbnail = pageData.GetStringBetween("<link rel=\"videothumbnail\" href=\"", "\""); ParameterList parameters = new ParameterList(); parameters.AddValue(VideoDownloadSourceCreator.IdParameterName, id.ToString()); parameters.AddValue(VideoDownloadSourceCreator.TitleParameterName, title); parameters.AddValue(VideoDownloadSourceCreator.DescriptionParameterName, description); parameters.AddValue(VideoDownloadSourceCreator.ThumbnailParameterName, thumbnail); parameters.AddValue(ShowParameterName, showTitle); parameters.AddValue(ShowHrefParameterName, showHref); parameters.AddValue(ShowArchiveHrefParameterName, showArchiveHref); parameters.AddValue(ShowThumbnailParameterName, showIcon); VideoDownloadSource downloadSource = new VideoDownloadSource(uri, this, parameters); string formatOptionStart = String.Format("<option value=\"/file/{0}?filename=", id); int currentPosition = 0; while (true) { string fileName = pageData.GetStringBetween(ref currentPosition, formatOptionStart, "\""); if (string.IsNullOrEmpty(fileName)) break; currentPosition += fileName.Length; string formatName = pageData.GetStringBetween(ref currentPosition, ">", "</option>"); currentPosition += formatName.Length; formatName = formatName.HtmlDecode(); Uri fileUri = new Uri(String.Format("http://blip.tv/file/get/{0}", fileName)); ParameterList specParameters = new ParameterList(); specParameters.AddValue(BlipVideoDownloadSpecifier.FormatNameParameterName, formatName); DownloadSpecifier ds = new BlipVideoDownloadSpecifier(fileUri, downloadSource, specParameters); downloadSource.Add(ds); } return downloadSource; }
private IEnumerable<IDownloadSource> ParseDownloadSources(string pageData, VideoChannelSource channelSource) { List<IDownloadSource> downloadSources = new List<IDownloadSource>(); DownloadSourceCreator downloadSourceCreator = null; string videoStart = "<div class=\"ArchiveEpisodeWrapper\">"; int currentPosition = 0; while (true) { string testStart = pageData.GetStringBetween(ref currentPosition, videoStart, null); if (String.IsNullOrEmpty(testStart)) break; string videoUri = pageData.GetStringBetween(ref currentPosition, "<a href=\"", "\""); string videoThumb = pageData.GetStringBetween(ref currentPosition, " src=\"", "\""); string videoTitle = pageData.GetStringBetween(ref currentPosition, " alt=\"", "\""); string videoId = videoUri.GetStringBetween("/file/", "/"); Uri absoluteUri = new Uri(channelSource.Uri, videoUri); if (downloadSourceCreator == null) downloadSourceCreator = (DownloadSourceCreator)Factory.Context.FindFactoryByCreatorType(typeof(DownloadSourceCreator)).GetCreator(absoluteUri); ParameterList videoParameters = new ParameterList(); videoParameters.AddValue(VideoDownloadSourceCreator.IdParameterName, videoId); videoParameters.AddValue(VideoDownloadSourceCreator.TitleParameterName, videoTitle); videoParameters.AddValue(VideoDownloadSourceCreator.ThumbnailParameterName, videoThumb); VideoDownloadSource ds = new VideoDownloadSource(absoluteUri, downloadSourceCreator, videoParameters); downloadSources.Add(ds); } return downloadSources; }