本文整理汇总了C#中ParameterList.AddValue方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterList.AddValue方法的具体用法?C# ParameterList.AddValue怎么用?C# ParameterList.AddValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterList
的用法示例。
在下文中一共展示了ParameterList.AddValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
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;
}
示例2: Create
public override ISource Create(Uri uri, string pageData)
{
string userHref = pageData.GetStringBetween("<link rel=\"canonical\"", " href=\"", "\"");
string username = userHref.GetStringBetween("/user/", null);
string title = pageData.GetStringBetween("<meta name=\"title\" content=\"", "\"");
string description = pageData.GetStringBetween("<meta name=\"description\" content=\"", "\"");
string thumbnail = pageData.GetStringBetween("<meta property=\"og:image\" content=\"", "\"");
// thumbnail format changed (no http/s)
// //i1.ytimg.com/i/dbL-i29FDPYok8X8yIynNQ/1.jpg?v=9aee31
string ajaxSessionInfo = pageData.GetStringBetween("window.ajax_session_info", "'", "'");
var parameters = new ParameterList();
parameters.AddValue(UserParameterName, username);
parameters.AddValue(UserHrefParameterName, userHref);
parameters.AddValue(TitleParameterName, title);
parameters.AddValue(DescriptionParameterName, description);
parameters.AddValue(ThumbnailParameterName, thumbnail);
parameters.AddValue(AjaxSessionInfoParameterName, ajaxSessionInfo);
var channelSource = new YoutubeVideoChannelSource(uri, this, parameters);
var downloadSources = ParseDownloadSources(pageData, channelSource);
foreach (var downloadSource in downloadSources)
channelSource.Add(downloadSource);
return channelSource;
}
示例3: Create
public override ISource Create(Uri uri, string pageData)
{
string userHref = uri.Host;
string username = userHref.Split('.')[0];
string title = pageData.GetStringBetween("<title>", "</title>").Trim();
string currentPageStr = pageData.GetStringBetween("<span id=\"pagination_current_page\"", ">", "<");
string totalPagesStr = pageData.GetStringBetween("<span id=\"pagination_total_pages\"", ">", "<");
string pagingUrl = pageData.GetStringBetween("<div class=\"view_pages_page\"", " href=\"", "\"");
string pagingUrlFormat = Regex.Replace(pagingUrl, @"page=\d+", "page={0}");
ParameterList parameters = new ParameterList();
parameters.AddValue(VideoChannelSourceCreator.UserParameterName, username);
parameters.AddValue(VideoChannelSourceCreator.UserHrefParameterName, userHref);
parameters.AddValue(VideoChannelSourceCreator.TitleParameterName, title);
parameters.AddValue(CurrentPageParameterName, int.Parse(currentPageStr));
parameters.AddValue(TotalPagesParameterName, int.Parse(totalPagesStr));
parameters.AddValue(PagingUrlFormatParameterName, pagingUrlFormat);
BlipVideoChannelSource channelSource = new BlipVideoChannelSource(uri, this, parameters);
var downloadSources = ParseDownloadSources(pageData, channelSource);
foreach (var downloadSource in downloadSources)
channelSource.Add(downloadSource);
return channelSource;
}
示例4: ParseDownloadSources
private IEnumerable<IDownloadSource> ParseDownloadSources(string pageData, YoutubeVideoChannelSource channelSource)
{
var sources = new List<IDownloadSource>();
DownloadSourceCreator downloadSourceCreator = null;
int currentPosition = 0;
while (true)
{
string videoId = pageData.GetStringBetween(ref currentPosition, "\"encryptedVideoId\">", "<");
if (string.IsNullOrEmpty(videoId))
break;
videoId = videoId.Trim();
string videoUri = pageData.GetStringBetween(ref currentPosition, "<div class=\"playnav-video-thumb\"", " href=\"", "\"");
string videoThumb = pageData.GetStringBetween(ref currentPosition, " src=\"", "\"");
string videoTitle = pageData.GetStringBetween(ref currentPosition, "title=\"", "\"").HtmlDecode();
string videoTime = pageData.GetStringBetween(ref currentPosition, "<span class=\"video-time\">", "<");
string videoViews = pageData.GetStringBetween(ref currentPosition, "<div class=\"metadata\">", ">", " views");
videoThumb = new Uri(channelSource.Uri, videoThumb).AbsoluteUri;
int parsedViews = int.Parse(videoViews, System.Globalization.NumberStyles.AllowThousands);
var absoluteUri = new Uri(channelSource.Uri, videoUri);
if (downloadSourceCreator == null)
downloadSourceCreator = (DownloadSourceCreator)Factory.Context.FindFactoryByCreatorType(typeof(DownloadSourceCreator)).GetCreator(absoluteUri);
var videoParameters = new ParameterList();
videoParameters.AddValue(VideoDownloadSourceCreator.IdParameterName, videoId);
videoParameters.AddValue(VideoDownloadSourceCreator.TitleParameterName, videoTitle);
videoParameters.AddValue(VideoDownloadSourceCreator.DescriptionParameterName, channelSource.Description);
videoParameters.AddValue(VideoDownloadSourceCreator.ThumbnailParameterName, videoThumb);
videoParameters.AddValue(YoutubeVideoDownloadSourceCreator.UserParameterName, channelSource.User);
videoParameters.AddValue(YoutubeVideoDownloadSourceCreator.UserHrefParameterName, channelSource.UserHref);
videoParameters.AddValue(YoutubeVideoDownloadSourceCreator.TimeParameterName, videoTime);
videoParameters.AddValue(YoutubeVideoDownloadSourceCreator.ViewCountParameterName, parsedViews);
var ds = new YoutubeVideoDownloadSource(absoluteUri, downloadSourceCreator, videoParameters);
sources.Add(ds);
}
return sources;
}
示例5: ParseDownloadSources
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;
}
示例6: Create
public override ISource Create(Uri uri, string pageData)
{
string title = pageData.GetStringBetween("<meta name=\"title\" content=\"", "\"");
string description = pageData.GetStringBetween("<meta name=\"description\" content=\"", "\"");
string thumbnail = pageData.GetStringBetween("<meta property=\"og:image\" content=\"", "\"");
string viewsRegion = pageData.GetStringBetween("<span class=\"watch-view-count\"", ">", "</span>");
string views = viewsRegion.GetStringBetween("<strong>", "</strong>");
int viewCount = int.Parse(views, System.Globalization.NumberStyles.AllowThousands);
string userRegion = pageData.GetStringBetween("<a class=\"watch-description-username\"", "</a>");
string userHref = userRegion.GetStringBetween("href=\"", "\"");
string user = userRegion.GetStringBetween("<strong>", "</strong>");
string dateRegion = pageData.GetStringBetween("<span id=\"eow-date-short\"", ">", "</span>").Trim();
DateTime date = DateTime.Parse(dateRegion);
string flashVarsValue = pageData.GetStringBetween("<param name=\\\"flashvars\\\" value=\\\"", "\\\"");
string[] flashVarsSplit = flashVarsValue.Split('&');
SortedList<string, string> flashVars = new SortedList<string, string>(flashVarsSplit.Length);
foreach (string chunk in flashVarsSplit)
{
string[] chunkSplit = chunk.Split('=');
flashVars.Add(chunkSplit[0], Uri.UnescapeDataString(chunkSplit[1]));
}
string fmt_map = flashVars["fmt_map"];
string[] fmtSplit = fmt_map.Split(',');
Dictionary<int, int[]> qualityLevels = new Dictionary<int, int[]>();
foreach (string chunk in fmtSplit)
{
string[] fmt = chunk.Split('/');
string[] res = fmt[1].Split('x');
qualityLevels.Add(int.Parse(fmt[0]), new int[] { int.Parse(res[0]), int.Parse(res[1]) });
}
string id = flashVars["video_id"];
ParameterList parameters = new ParameterList();
parameters.AddValue(VideoDownloadSourceCreator.IdParameterName, id);
parameters.AddValue(VideoDownloadSourceCreator.TitleParameterName, title);
parameters.AddValue(VideoDownloadSourceCreator.DescriptionParameterName, description);
parameters.AddValue(VideoDownloadSourceCreator.ThumbnailParameterName, thumbnail);
parameters.AddValue(UserParameterName, user);
parameters.AddValue(UserHrefParameterName, userHref);
parameters.AddValue(DateParameterName, date);
parameters.AddValue(ViewCountParameterName, viewCount);
VideoDownloadSource downloadSource = new YoutubeVideoDownloadSource(uri, this, parameters);
string fmt_url_map = flashVars["fmt_url_map"];
string[] urlSplit = fmt_url_map.Split(',');
foreach (string chunk in urlSplit)
{
string[] fmt_url = chunk.Split('|');
Uri fmt_uri = new Uri(fmt_url[1]);
int qualityLevel = int.Parse(fmt_url[0]);
int[] res = qualityLevels[qualityLevel];
string resolution = String.Format("{0}x{1}", res[0], res[1]);
ParameterList specParameters = new ParameterList();
specParameters.AddValue(YoutubeVideoDownloadSpecifier.FmtParameterName, qualityLevel);
specParameters.AddValue(YoutubeVideoDownloadSpecifier.ResolutionParameterName, resolution);
specParameters.AddValue(YoutubeVideoDownloadSpecifier.MaxPixelHeightParameterName, res[1]);
DownloadSpecifier ds = new YoutubeVideoDownloadSpecifier(fmt_uri, downloadSource, specParameters);
downloadSource.Add(ds);
}
return downloadSource;
}