本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.GetQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.GetQueryString方法的具体用法?C# NameValueCollection.GetQueryString怎么用?C# NameValueCollection.GetQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.GetQueryString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
NameValueCollection qParams = new NameValueCollection();
qParams.Add("cata", "yes");
qParams.Add("sec", "jax");
List<string> catList = MapTorznabCapsToTrackers(query);
foreach (string cat in catList)
{
qParams.Add("c" + cat, "1");
}
if (!string.IsNullOrEmpty(query.SanitizedSearchTerm))
{
qParams.Add("search", query.GetQueryString());
}
string torrentSearchUrl = $"{SearchUrl}?{qParams.GetQueryString()}";
var results = await RequestStringWithCookiesAndRetry(torrentSearchUrl);
List<ReleaseInfo> releases = ParseResponse(results.Content);
return releases;
}
示例2: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = APIUrl;
var queryCollection = new NameValueCollection();
queryCollection.Add("action", "browse");
//queryCollection.Add("group_results", "0"); # results won't include all information
queryCollection.Add("order_by", "time");
queryCollection.Add("order_way", "desc");
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("searchstr", searchString);
}
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add("filter_cat[" + cat + "]", "1");
}
searchUrl += "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(searchUrl);
if (response.IsRedirect || query.IsTest)
{
// re-login
await ApplyConfiguration(null);
response = await RequestStringWithCookiesAndRetry(searchUrl);
}
try
{
var json = JObject.Parse(response.Content);
foreach (JObject r in json["response"]["results"])
{
var groupTime = DateTimeUtil.UnixTimestampToDateTime(long.Parse((string)r["groupTime"]));
var groupName = HttpUtility.HtmlDecode((string)r["groupName"]);
var artist = (string)r["artist"];
var cover = (string)r["cover"];
var tags = r["tags"].ToList();
var groupYear = (string)r["groupYear"];
var releaseType = (string)r["releaseType"];
var release = new ReleaseInfo();
release.PublishDate = groupTime;
if (!string.IsNullOrEmpty(cover))
release.BannerUrl = new Uri(cover);
release.Title = "";
if (!string.IsNullOrEmpty(artist))
release.Title += artist + " - ";
release.Title += groupName;
if (!string.IsNullOrEmpty(groupYear))
release.Title += " [" + groupYear + "]";
if (!string.IsNullOrEmpty(releaseType))
release.Title += " [" + releaseType + "]";
release.Description = "";
if (tags != null)
release.Description += "Tags: " + string.Join(", ", tags) + "\n";
if (r["torrents"] is JArray)
{
foreach (JObject torrent in r["torrents"])
{
ReleaseInfo release2 = (ReleaseInfo)release.Clone();
FillReleaseInfoFromJson(release2, torrent);
releases.Add(release2);
}
}
else
{
FillReleaseInfoFromJson(release, r);
releases.Add(release);
}
}
}
catch (Exception ex)
{
OnParseError(response.Content, ex);
}
return releases;
}
示例3: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var queryCollection = new NameValueCollection();
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
var searchUrl = SearchUrl + queryCollection.GetQueryString();
var trackerCats = MapTorznabCapsToTrackers(query, mapChildrenCatsToParent: true);
var results = await RequestStringWithCookiesAndRetry(searchUrl);
try
{
CQ dom = results.Content;
dom["#needseed"].Remove();
var rows = dom["table[width='750'] > tbody"].Children();
foreach (var row in rows.Skip(1))
{
var release = new ReleaseInfo();
var qRow = row.Cq();
var qLink = qRow.Children().ElementAt(2).Cq().Children("a").First();
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
release.Title = qLink.Attr("title");
release.Description = release.Title;
release.Guid = new Uri(SiteLink + qLink.Attr("href").TrimStart('/'));
release.Comments = release.Guid;
release.Link = new Uri(string.Format(DownloadUrl, qLink.Attr("href").Split('=')[1]));
var catUrl = qRow.Children().ElementAt(1).FirstElementChild.Cq().Attr("href");
var catNum = catUrl.Split(new char[] { '=', '&' })[1];
release.Category = MapTrackerCatToNewznab(catNum);
// This tracker cannot search multiple cats at a time, so search all cats then filter out results from different cats
if (trackerCats.Count > 0 && !trackerCats.Contains(catNum))
continue;
var dateString = qRow.Children().ElementAt(5).Cq().Text().Trim();
var pubDate = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
release.PublishDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Local);
var sizeStr = qRow.Children().ElementAt(6).Cq().Text();
release.Size = ReleaseInfo.GetBytes(sizeStr);
release.Seeders = ParseUtil.CoerceInt(qRow.Children().ElementAt(8).Cq().Text().Trim());
release.Peers = ParseUtil.CoerceInt(qRow.Children().ElementAt(9).Cq().Text().Trim()) + release.Seeders;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results.Content, ex);
}
return releases;
}
示例4: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var loggedInCheck = await RequestStringWithCookies(SearchUrl);
if (!loggedInCheck.Content.Contains("/logout.php"))
{
//Cookie appears to expire after a period of time or logging in to the site via browser
await DoLogin();
}
var releases = new List<ReleaseInfo>();
NameValueCollection qParams = new NameValueCollection();
if (!string.IsNullOrEmpty(query.GetQueryString()))
{
qParams.Add("search", query.GetQueryString());
}
List<string> catList = MapTorznabCapsToTrackers(query);
foreach (string cat in catList)
{
qParams.Add("c" + cat, "1");
}
string urlSearch = SearchUrl;
if (qParams.Count > 0)
{
urlSearch += $"?{qParams.GetQueryString()}";
}
var response = await RequestStringWithCookiesAndRetry(urlSearch);
try
{
CQ dom = response.Content;
var rows = dom["div[id='torrentTable'] > div[class='box torrentBox'] > div[class='boxContent'] > table > tbody > tr"];
foreach (IDomObject row in rows)
{
CQ torrentData = row.OuterHTML;
CQ cells = row.Cq().Find("td");
string title = torrentData.Find("a[class='torrent']").First().Text().Trim();
Uri link = new Uri(SiteLink + torrentData.Find("img[class='icos save']").First().Parent().Attr("href").Trim());
Uri guid = new Uri(SiteLink + torrentData.Find("a[class='torrent']").First().Attr("href").Trim().TrimStart('/'));
long size = ReleaseInfo.GetBytes(cells.Elements.ElementAt(4).Cq().Text());
int seeders = ParseUtil.CoerceInt(cells.Elements.ElementAt(5).Cq().Text());
int leechers = ParseUtil.CoerceInt(cells.Elements.ElementAt(6).Cq().Text());
string pubDateStr = torrentData.Find("span[class^='elapsedDate']").First().Attr("title").Trim().Replace(" at", "");
DateTime publishDate = DateTime.ParseExact(pubDateStr, "dddd, MMMM d, yyyy h:mmtt", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime();
long category = 0;
string cat = torrentData.Find("a[class='cat']").First().Attr("id").Trim();
long.TryParse(cat, out category);
var release = new ReleaseInfo();
release.Title = title;
release.Guid = guid;
release.Link = link;
release.PublishDate = publishDate;
release.Size = size;
release.Description = release.Title;
release.Seeders = seeders;
release.Peers = seeders + leechers;
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
release.Category = MapTrackerCatToNewznab(category.ToString());
release.Comments = guid;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(response.Content, ex);
}
return releases;
}
示例5: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = BrowseUrl;
var trackerCats = MapTorznabCapsToTrackers(query);
var queryCollection = new NameValueCollection();
// Tracker can only search OR return things in categories
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
queryCollection.Add("cat", "0");
queryCollection.Add("sc", "1");
}
else
{
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add("c" + cat, "1");
}
queryCollection.Add("incldead", "0");
}
searchUrl += "?" + queryCollection.GetQueryString();
// 15 results per page - really don't want to call the server twice but only 15 results per page is a bit crap!
await ProcessPage(releases, searchUrl);
await ProcessPage(releases, searchUrl + "&page=1");
return releases;
}
示例6: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
TimeZoneInfo.TransitionTime startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 3, 0, 0), 3, 5, DayOfWeek.Sunday);
TimeZoneInfo.TransitionTime endTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 4, 0, 0), 10, 5, DayOfWeek.Sunday);
TimeSpan delta = new TimeSpan(1, 0, 0);
TimeZoneInfo.AdjustmentRule adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1999, 10, 1), DateTime.MaxValue.Date, delta, startTransition, endTransition);
TimeZoneInfo.AdjustmentRule[] adjustments = { adjustment };
TimeZoneInfo germanyTz = TimeZoneInfo.CreateCustomTimeZone("W. Europe Standard Time", new TimeSpan(1, 0, 0), "(GMT+01:00) W. Europe Standard Time", "W. Europe Standard Time", "W. Europe DST Time", adjustments);
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = BrowseUrl;
var queryCollection = new NameValueCollection();
queryCollection.Add("showsearch", "1");
queryCollection.Add("incldead", "1");
queryCollection.Add("blah", "0");
queryCollection.Add("orderby", "added");
queryCollection.Add("sort", "desc");
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add("c" + cat, "1");
}
searchUrl += "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
var results = response.Content;
try
{
CQ dom = results;
var rows = dom["table.tableinborder > tbody > tr:has(td.tableb)"];
foreach (var row in rows)
{
var release = new ReleaseInfo();
release.MinimumRatio = 0.75;
release.MinimumSeedTime = 0;
var qRow = row.Cq();
var qDetailsLink = qRow.Find("a[href^=details.php?id=]").First();
release.Title = qDetailsLink.Attr("title");
if (!query.MatchQueryStringAND(release.Title))
continue;
var qCatLink = qRow.Find("a[href^=browse.php?cat=]").First();
// use negative indexes as if a user has "Wartezeit" there's an extra column after the title
var qSeeders = qRow.Find("td:nth-last-child(4)");
var qLeechers = qRow.Find("td:nth-last-child(3)");
var qDateStr = qRow.Find("td:nth-last-child(7)");
var qSize = qRow.Find("td:nth-last-child(6)");
var torrentId = qDetailsLink.Attr("href").Replace("&hit=1", "").Split('=')[1];
var catStr = qCatLink.Attr("href").Split('=')[1];
release.Category = MapTrackerCatToNewznab(catStr);
release.Link = new Uri(SiteLink + "download.php?torrent="+torrentId);
release.Comments = new Uri(SiteLink + qDetailsLink.Attr("href"));
release.Guid = release.Link;
var sizeStr = qSize.Text();
release.Size = ReleaseInfo.GetBytes(sizeStr.Replace(",", "."));
release.Seeders = ParseUtil.CoerceInt(qSeeders.Text());
release.Peers = ParseUtil.CoerceInt(qLeechers.Text()) + release.Seeders;
var dateStr = qDateStr.Text();
var dateGerman = DateTime.SpecifyKind(DateTime.ParseExact(dateStr, "dd.MM.yyyyHH:mm:ss", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);
DateTime pubDateUtc = TimeZoneInfo.ConvertTimeToUtc(dateGerman, germanyTz);
release.PublishDate = pubDateUtc;
var files = qRow.Find("td:nth-last-child(9)").Text();
release.Files = ParseUtil.CoerceInt(files);
var grabs = qRow.Find("td:nth-last-child(5)").Text();
release.Grabs = ParseUtil.CoerceInt(grabs);
if (qRow.Find("font[color=\"red\"]:contains(OnlyUp)").Length >= 1)
release.DownloadVolumeFactor = 0;
else
release.DownloadVolumeFactor = 1;
release.UploadVolumeFactor = 1;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results, ex);
}
//.........这里部分代码省略.........
示例7: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchurls = new List<string>();
var searchUrl = SearchUrl;// string.Format(SearchUrl, HttpUtility.UrlEncode()));
var queryCollection = new NameValueCollection();
var searchString = query.GetQueryString();
foreach (var cat in MapTorznabCapsToTrackers(query))
{
searchUrl += "category%5B%5D=" + cat + "&";
}
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
queryCollection.Add("active", "0");
queryCollection.Add("options", "0");
searchUrl += queryCollection.GetQueryString().Replace("(", "%28").Replace(")", "%29"); // maually url encode brackets to prevent "hacking" detection
var results = await RequestStringWithCookiesAndRetry(searchUrl);
try
{
CQ dom = results.Content;
ReleaseInfo release;
var rows = dom[".mainblockcontenttt > tbody > tr:has(a[href^=\"details.php?id=\"])"];
foreach (var row in rows)
{
CQ qRow = row.Cq();
release = new ReleaseInfo();
release.Title = qRow.Find("td.mainblockcontent b a").Text();
release.Description = qRow.Find("td:nth-child(3) > span").Text();
if (0 != qRow.Find("td.mainblockcontent u").Length)
{
var imdbStr = qRow.Find("td.mainblockcontent u").Parent().First().Attr("href").Replace("http://www.imdb.com/title/tt", "").Replace("/", "");
long imdb;
if (ParseUtil.TryCoerceLong(imdbStr, out imdb))
{
release.Imdb = imdb;
}
}
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
int seeders, peers;
if (ParseUtil.TryCoerceInt(qRow.Find("td").Get(9).FirstChild.FirstChild.InnerText, out seeders))
{
release.Seeders = seeders;
if (ParseUtil.TryCoerceInt(qRow.Find("td").Get(10).FirstChild.FirstChild.InnerText, out peers))
{
release.Peers = peers + release.Seeders;
}
}
release.Grabs = ParseUtil.CoerceLong(qRow.Find("td:nth-child(12)").Text());
string fullSize = qRow.Find("td.mainblockcontent").Get(6).InnerText;
release.Size = ReleaseInfo.GetBytes(fullSize);
release.Guid = new Uri(SiteLink + qRow.Find("td.mainblockcontent b a").Attr("href"));
release.Link = new Uri(SiteLink + qRow.Find("td.mainblockcontent").Get(3).FirstChild.GetAttribute("href"));
release.Comments = new Uri(SiteLink + qRow.Find("td.mainblockcontent b a").Attr("href"));
string[] dateSplit = qRow.Find("td.mainblockcontent").Get(5).InnerHTML.Split(',');
string dateString = dateSplit[1].Substring(0, dateSplit[1].IndexOf('>'));
release.PublishDate = DateTime.Parse(dateString, CultureInfo.InvariantCulture);
string category = qRow.Find("td:eq(0) a").Attr("href").Replace("torrents.php?category=", "");
release.Category = MapTrackerCatToNewznab(category);
release.UploadVolumeFactor = 1;
if (qRow.Find("img[alt=\"Free Torrent\"]").Length >= 1)
{
release.DownloadVolumeFactor = 0;
release.UploadVolumeFactor = 0;
}
else if (qRow.Find("img[alt=\"Silver Torrent\"]").Length >= 1)
release.DownloadVolumeFactor = 0.5;
else if (qRow.Find("img[alt=\"Bronze Torrent\"]").Length >= 1)
release.DownloadVolumeFactor = 0.75;
else if (qRow.Find("img[alt=\"Blue Torrent\"]").Length >= 1)
release.DownloadVolumeFactor = 0.25;
else
release.DownloadVolumeFactor = 1;
//.........这里部分代码省略.........
示例8: buildQuery
/// <summary>
/// Build query to process
/// </summary>
/// <param name="term">Term to search</param>
/// <param name="query">Torznab Query for categories mapping</param>
/// <param name="url">Search url for provider</param>
/// <param name="page">Page number to request</param>
/// <returns>URL to query for parsing and processing results</returns>
private string buildQuery(string term, TorznabQuery query, string url, int page = 0)
{
var parameters = new NameValueCollection();
List<string> categoriesList = MapTorznabCapsToTrackers(query);
// If search term provided
if (!string.IsNullOrWhiteSpace(term))
{
// Add search term
parameters.Add("q", term);
}
else
{
parameters.Add("q", string.Empty);
// Showing all torrents (just for output function)
term = "all";
}
// Default parameters
parameters.Add("exact", "0");
parameters.Add("sort", "normal");
parameters.Add("order", "desc");
// Check if we are processing a new page
if (page > 0)
{
// Adding page number to query
parameters.Add("page", page.ToString());
}
// Loop on Categories needed
foreach (string category in categoriesList)
{
// Add categories
parameters.Add("c" + category, "1");
}
// Building our query
url += "?" + parameters.GetQueryString();
output("\nBuilded query for \"" + term + "\"... " + url);
// Return our search url
return url;
}
示例9: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = SearchUrl;
var queryCollection = new NameValueCollection();
queryCollection.Add("total", "146"); // Not sure what this is about but its required!
var cat = "0";
var queryCats = MapTorznabCapsToTrackers(query);
if (queryCats.Count == 1)
{
cat = queryCats.First().ToString();
}
queryCollection.Add("cat", cat);
queryCollection.Add("dlable", "1");
queryCollection.Add("searchin", "filename");
queryCollection.Add("search", searchString);
queryCollection.Add("page", "1");
searchUrl += "?" + queryCollection.GetQueryString();
var extraHeaders = new Dictionary<string, string>()
{
{ "X-Requested-With", "XMLHttpRequest" }
};
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, SearchUrlReferer, extraHeaders);
var results = response.Content;
if (!string.IsNullOrWhiteSpace(results))
{
try
{
CQ dom = results;
var rows = dom["tr"];
foreach (var row in rows.Skip(1))
{
var release = new ReleaseInfo();
var qRow = row.Cq();
var qTitleLink = qRow.Find("td:eq(1) a:eq(0)").First();
release.Title = qTitleLink.Find("strong").Text().Trim();
// If we search an get no results, we still get a table just with no info.
if (string.IsNullOrWhiteSpace(release.Title))
{
break;
}
release.Description = release.Title;
release.Guid = new Uri(qTitleLink.Attr("href"));
release.Comments = release.Guid;
var dateString = qRow.Find("td:eq(4)").Text();
release.PublishDate = DateTime.ParseExact(dateString, "dd MMM yy", CultureInfo.InvariantCulture);
var qLink = qRow.Find("td:eq(2) a");
release.Link = new Uri(qLink.Attr("href"));
var sizeStr = qRow.Find("td:eq(5)").Text();
release.Size = ReleaseInfo.GetBytes(sizeStr);
var connections = qRow.Find("td:eq(7)").Text().Trim().Split("/".ToCharArray(),StringSplitOptions.RemoveEmptyEntries);
release.Seeders = ParseUtil.CoerceInt(connections[0].Trim());
release.Peers = ParseUtil.CoerceInt(connections[1].Trim()) + release.Seeders;
var rCat = row.Cq().Find("td:eq(0) a").First().Attr("href");
var rCatIdx = rCat.IndexOf("cat=");
if (rCatIdx > -1)
{
rCat = rCat.Substring(rCatIdx + 4);
}
release.Category = MapTrackerCatToNewznab(rCat);
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results, ex);
}
}
return releases;
}
示例10: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var queryCollection = new NameValueCollection();
queryCollection.Add("view", "0");
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add(string.Format("c{0}", cat), "1");
}
var searchUrl = SearchUrl + "?" + queryCollection.GetQueryString();
var results = await RequestStringWithCookiesAndRetry(searchUrl, CookieHeader);
try
{
CQ dom = results.Content;
var rows = dom["#torrentBrowse > table > tbody > tr"];
foreach (var row in rows.Skip(1))
{
var release = new ReleaseInfo();
CQ qRow = row.Cq();
//CQ qLink = qRow.Children().ElementAt(1).Cq().Children("a").ElementAt(1).Cq();
CQ qLink;
CQ qTmp = qRow.Children().ElementAt(1).Cq().Find("a");
if (qTmp.Length < 2) {
qLink = qRow.Children().ElementAt(1).Cq().Find("a").ElementAt(0).Cq();
} else {
qLink = qRow.Children().ElementAt(1).Cq().Find("a").ElementAt(1).Cq();
}
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
release.Title = qLink.Attr("title");
release.Description = release.Title;
release.Guid = new Uri(SiteLink + qLink.Attr("href").TrimStart('/'));
release.Comments = release.Guid;
qLink = qRow.Children().ElementAt(3).Cq().Children("a").First();
release.Link = new Uri(string.Format("{0}{1}", SiteLink, qLink.Attr("href")));
var catUrl = qRow.Children().ElementAt(0).FirstElementChild.Cq().Attr("href");
var catNum = catUrl.Split(new char[] { '=', '&' })[2].Replace("c", "");
release.Category = MapTrackerCatToNewznab(catNum);
var dateString = qRow.Children().ElementAt(6).Cq().Text().Trim();
//var pubDate = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
release.PublishDate = Jackett.Utils.DateTimeUtil.FromTimeAgo(dateString);
var sizeStr = qRow.Children().ElementAt(7).Cq().Text().Split(new char[] { '/' })[0];
release.Size = ReleaseInfo.GetBytes(sizeStr);
release.Seeders = ParseUtil.CoerceInt(qRow.Children().ElementAt(8).Cq().Text().Split(new char[] { '/' })[0].Trim());
release.Peers = ParseUtil.CoerceInt(qRow.Children().ElementAt(8).Cq().Text().Split(new char[] { '/' })[1].Trim()) + release.Seeders;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results.Content, ex);
}
return releases;
}
示例11: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
TimeZoneInfo.TransitionTime startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 3, 0, 0), 3, 5, DayOfWeek.Sunday);
TimeZoneInfo.TransitionTime endTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 4, 0, 0), 10, 5, DayOfWeek.Sunday);
TimeSpan delta = new TimeSpan(1, 0, 0);
TimeZoneInfo.AdjustmentRule adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1999, 10, 1), DateTime.MaxValue.Date, delta, startTransition, endTransition);
TimeZoneInfo.AdjustmentRule[] adjustments = { adjustment };
TimeZoneInfo germanyTz = TimeZoneInfo.CreateCustomTimeZone("W. Europe Standard Time", new TimeSpan(1, 0, 0), "(GMT+01:00) W. Europe Standard Time", "W. Europe Standard Time", "W. Europe DST Time", adjustments);
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = BrowseUrl;
var queryCollection = new NameValueCollection();
queryCollection.Add("showsearch", "1");
queryCollection.Add("incldead", "1");
queryCollection.Add("orderby", "added");
queryCollection.Add("sort", "desc");
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
var cats = MapTorznabCapsToTrackers(query);
string cat = "0";
if (cats.Count == 1)
{
cat = cats[0];
}
queryCollection.Add("cat", cat);
searchUrl += "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookies(searchUrl);
var results = response.Content;
try
{
CQ dom = results;
var rows = dom["table.testtable> tbody > tr:has(td.tableb)"];
foreach (var row in rows)
{
var release = new ReleaseInfo();
release.MinimumRatio = 0.75;
release.MinimumSeedTime = 0;
var qRow = row.Cq();
var qDetailsLink = qRow.Find("a[href^=details.php?id=]").First();
release.Title = qDetailsLink.Text();
if (!query.MatchQueryStringAND(release.Title))
continue;
var qCatLink = qRow.Find("a[href^=browse.php?cat=]").First();
var qSeeders = qRow.Find("td > table.testtable > tbody > tr > td > strong:eq(3)");
var qLeechers = qRow.Find("td > table.testtable > tbody > tr > td > strong:eq(4)");
var qDateStr = qRow.Find("td > table.testtable > tbody > tr > td:eq(6)");
var qSize = qRow.Find("td > table.testtable > tbody > tr > td > strong:eq(1)");
var qDownloadLink = qRow.Find("a[href*=download]").First();
var catStr = qCatLink.Attr("href").Split('=')[1];
release.Category = MapTrackerCatToNewznab(catStr);
var dlLink = qDownloadLink.Attr("href");
if(dlLink.Contains("javascript")) // depending on the user agent the DL link is a javascript call
{
var dlLinkParts = dlLink.Split(new char[] { '\'', ',' });
dlLink = SiteLink + "download/" + dlLinkParts[3] + "/" + dlLinkParts[5];
}
release.Link = new Uri(dlLink);
release.Comments = new Uri(SiteLink + qDetailsLink.Attr("href"));
release.Guid = release.Link;
var sizeStr = qSize.Text();
release.Size = ReleaseInfo.GetBytes(sizeStr.Replace(".", "").Replace(",", "."));
release.Seeders = ParseUtil.CoerceInt(qSeeders.Text());
release.Peers = ParseUtil.CoerceInt(qLeechers.Text()) + release.Seeders;
var dateStr = qDateStr.Text().Replace('\xA0', ' ');
var dateGerman = DateTime.SpecifyKind(DateTime.ParseExact(dateStr, "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);
DateTime pubDateUtc = TimeZoneInfo.ConvertTimeToUtc(dateGerman, germanyTz);
release.PublishDate = pubDateUtc;
var files = qRow.Find("td:contains(Datei) > strong ~ strong").Text();
release.Files = ParseUtil.CoerceInt(files);
if (qRow.Find("img[title=\"OnlyUpload\"]").Length >= 1)
release.DownloadVolumeFactor = 0;
else
release.DownloadVolumeFactor = 1;
release.UploadVolumeFactor = 1;
releases.Add(release);
}
}
catch (Exception ex)
{
//.........这里部分代码省略.........
示例12: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = SearchUrl;
var queryCollection = new NameValueCollection();
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
var cats = new List<string>();
foreach (var cat in MapTorznabCapsToTrackers(query))
{
cats.AddRange(cat.Split(','));
}
foreach (var cat in cats.Distinct())
{
queryCollection.Add("c" + cat, "1");
}
searchUrl += queryCollection.GetQueryString();
var results = await RequestStringWithCookiesAndRetry(searchUrl);
await FollowIfRedirect(results);
try
{
CQ dom = results.Content;
var rows = dom["table.torrenttable > tbody > tr.browse_color"];
foreach (var row in rows)
{
var release = new ReleaseInfo();
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
var qRow = row.Cq();
var catStr = row.ChildElements.ElementAt(0).FirstElementChild.GetAttribute("href").Split('=')[1];
release.Category = MapTrackerCatToNewznab(catStr);
var qLink = row.ChildElements.ElementAt(2).FirstChild.Cq();
release.Link = new Uri(SiteLink + "/" + qLink.Attr("href"));
var torrentID = qLink.Attr("href").Split('=').Last();
var descCol = row.ChildElements.ElementAt(3);
var qCommentLink = descCol.FirstChild.Cq();
release.Title = qCommentLink.Text();
release.Description = release.Title;
release.Comments = new Uri(SiteLink + "/" + qCommentLink.Attr("href"));
release.Guid = release.Comments;
var dateStr = descCol.ChildElements.Last().Cq().Text().Split('|').Last().ToLowerInvariant().Replace("ago.", "").Trim();
release.PublishDate = DateTimeUtil.FromTimeAgo(dateStr);
var sizeStr = row.ChildElements.ElementAt(7).Cq().Text();
release.Size = ReleaseInfo.GetBytes(sizeStr);
release.Seeders = ParseUtil.CoerceInt(row.ChildElements.ElementAt(9).Cq().Text());
release.Peers = ParseUtil.CoerceInt(row.ChildElements.ElementAt(10).Cq().Text()) + release.Seeders;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results.Content, ex);
}
return releases;
}
示例13: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var searchUrl = BrowseUrl;
var queryCollection = new NameValueCollection();
queryCollection.Add("showsearch", "0");
queryCollection.Add("incldead", "1");
queryCollection.Add("blah", "0");
queryCollection.Add("team", "0");
queryCollection.Add("orderby", "added");
queryCollection.Add("sort", "desc");
if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString);
}
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add("c" + cat, "1");
}
searchUrl += "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
var results = response.Content;
try
{
CQ dom = results;
var rows = dom["table.tableinborder[cellpadding=0] > tbody > tr"];
foreach (var row in rows)
{
var release = new ReleaseInfo();
release.MinimumRatio = 0.7;
release.MinimumSeedTime = 48 * 60 * 60;
var qRow = row.Cq();
var flagImgs = qRow.Find("table tbody tr: eq(0) td > img");
List<string> flags = new List<string>();
flagImgs.Each(flagImg => {
flags.Add(flagImg.GetAttribute("src").Replace("pic/torrent_", "").Replace(".gif", "").ToUpper());
});
var titleLink = qRow.Find("table tbody tr:eq(0) td a:has(b)").First();
var DLLink = qRow.Find("td.tableb > a:has(img[title=\"Torrent herunterladen\"])").First();
release.Comments = new Uri(SiteLink + titleLink.Attr("href").Replace("&hit=1", ""));
release.Link = new Uri(SiteLink + DLLink.Attr("href"));
release.Title = titleLink.Text().Trim();
if (!query.MatchQueryStringAND(release.Title))
continue;
release.Description = String.Join(", ", flags);
release.Guid = release.Link;
var dateStr = qRow.Find("table tbody tr:eq(1) td:eq(4)").Html().Replace(" ", " ").Trim();
var dateGerman = DateTime.SpecifyKind(DateTime.ParseExact(dateStr, "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);
DateTime pubDateUtc = TimeZoneInfo.ConvertTimeToUtc(dateGerman, germanyTz);
release.PublishDate = pubDateUtc.ToLocalTime();
var sizeStr = qRow.Find("table tbody tr:eq(1) td b").First().Text().Trim();
release.Size = ReleaseInfo.GetBytes(sizeStr.Replace(",", "."));
release.Seeders = ParseUtil.CoerceInt(qRow.Find("table tbody tr:eq(1) td:eq(1) b:eq(0) font").Text().Trim());
release.Peers = ParseUtil.CoerceInt(qRow.Find("table tbody tr:eq(1) td:eq(1) b:eq(1) font").Text().Trim()) + release.Seeders;
var catId = qRow.Find("td:eq(0) a").First().Attr("href").Split('=')[1];
release.Category = MapTrackerCatToNewznab(catId);
var cat = qRow.Find("td:eq(0) a").First().Attr("href").Substring(1);
release.Category = MapTrackerCatToNewznab(cat);
var files = qRow.Find("td:has(a[href*=\"&filelist=1\"])> b:nth-child(2)").Text();
release.Files = ParseUtil.CoerceInt(files);
var grabs = qRow.Find("td:has(a[href*=\"&tosnatchers=1\"])> b:nth-child(1)").Text();
release.Grabs = ParseUtil.CoerceInt(grabs);
if (qRow.Find("img[src=\"pic/torrent_ou.gif\"]").Length >= 1)
release.DownloadVolumeFactor = 0;
else
release.DownloadVolumeFactor = 1;
release.UploadVolumeFactor = 1;
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results, ex);
}
return releases;
}
示例14: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
// if the search string is empty use the "last 24h torrents" view
if (string.IsNullOrWhiteSpace(searchString))
{
var results = await RequestStringWithCookies(TodayUrl);
try
{
string RowsSelector = "table.torrent_table > tbody > tr:not(tr.colhead)";
var SearchResultParser = new HtmlParser();
var SearchResultDocument = SearchResultParser.Parse(results.Content);
var Rows = SearchResultDocument.QuerySelectorAll(RowsSelector);
foreach (var Row in Rows)
{
try
{
var release = new ReleaseInfo();
release.MinimumRatio = 1;
release.MinimumSeedTime = 0;
var qDetailsLink = Row.QuerySelector("a.BJinfoBox");
var qTitle = qDetailsLink.QuerySelector("font");
release.Title = qTitle.TextContent;
var qBJinfoBox = qDetailsLink.QuerySelector("span");
var qCatLink = Row.QuerySelector("a[href^=\"/torrents.php?filter_cat\"]");
var qDLLink = Row.QuerySelector("a[href^=\"torrents.php?action=download\"]");
var qSeeders = Row.QuerySelector("td:nth-child(4)");
var qLeechers = Row.QuerySelector("td:nth-child(5)");
var qFreeLeech = Row.QuerySelector("font[color=\"green\"]:contains(Free)");
release.Description = "";
foreach (var Child in qBJinfoBox.ChildNodes)
{
var type = Child.NodeType;
if (type != NodeType.Text)
continue;
var line = Child.TextContent;
if (line.StartsWith("Tamanho:"))
{
string Size = line.Substring("Tamanho: ".Length); ;
release.Size = ReleaseInfo.GetBytes(Size);
}
else if (line.StartsWith("Lançado em: "))
{
string PublishDateStr = line.Substring("Lançado em: ".Length).Replace("às ", "");
PublishDateStr += " +0";
var PublishDate = DateTime.SpecifyKind(DateTime.ParseExact(PublishDateStr, "dd/MM/yyyy HH:mm z", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);
release.PublishDate = PublishDate.ToLocalTime();
}
else
{
release.Description += line + "\n";
}
}
var catStr = qCatLink.GetAttribute("href").Split('=')[1];
release.Category = MapTrackerCatToNewznab(catStr);
release.Link = new Uri(SiteLink + qDLLink.GetAttribute("href"));
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
release.Guid = release.Link;
release.Seeders = ParseUtil.CoerceInt(qSeeders.TextContent);
release.Peers = ParseUtil.CoerceInt(qLeechers.TextContent) + release.Seeders;
if (qFreeLeech != null)
release.DownloadVolumeFactor = 0;
else
release.DownloadVolumeFactor = 1;
release.UploadVolumeFactor = 1;
releases.Add(release);
}
catch (Exception ex)
{
logger.Error(string.Format("{0}: Error while parsing row '{1}': {2}", ID, Row.OuterHtml, ex.Message));
}
}
}
catch (Exception ex)
{
OnParseError(results.Content, ex);
}
}
else // use search
{
var searchUrl = BrowseUrl;
var queryCollection = new NameValueCollection();
//.........这里部分代码省略.........
示例15: PerformQuery
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>(); // Create new variable to hold release info list
var releasesAppend = new List<ReleaseInfo>(); // Create new list to hold release info to be appended
var searchString = query.GetQueryString(); // Get the query string
var searchUrl = SearchUrl; // Get the search url
var qParams = new NameValueCollection(); // Greate a new variable to hold query string parameters
int i = 1; // Creaate new variable to control loop limit
CQ csquery; // Create new csquery object for html selections
// If exists then add the search parameter to the query string parameters
if (!string.IsNullOrWhiteSpace(searchString))
{
qParams.Add("search", searchString);
}
// Add category parameters to the query string parameters
foreach (var cat in MapTorznabCapsToTrackers(query))
{
qParams.Add("c" + cat, "1");
}
// Append the query string parameters to the search url
if (qParams.Count > 0)
{
searchUrl += qParams.GetQueryString();
}
// Begin loop (if looped 10 times (10 page requests, each containing 25 torrents) or torrent with zero seeds is found then exist loop)
while (i <= 10 && !releases.Exists(x => x.Seeders == 0))
{
// Execute web request to Speed.cd
var response = await RequestStringWithCookiesAndRetry(searchUrl + "&p=" + i);
try
{
// Populate the csquery wiht the web request response content
csquery = response.Content;
// Query the cs object for the rows of the torrent table
var rows = csquery["#torrentTable > div > div.boxContent > table > tbody > tr"];
// Populate append variable with release info to append
releasesAppend = rows.Select(r => {
try {
string id = r.Attributes["id"].Remove(0, 2); // Get ID
int seeders = 0; int.TryParse(r.ChildNodes[5].Cq().Text(), out seeders); // Get seeders
int leechers = 0; int.TryParse(r.ChildNodes[6].Cq().Text(), out leechers); // Get leechers
long category; long.TryParse(csquery["a.cat", r].Attr("id").Trim(), out category); // Get category code
// Create release info
ReleaseInfo info = new ReleaseInfo()
{
Guid = new Uri(string.Format(CommentsUrl, id)),
Title = csquery["a.torrent", r].Text(),
Description = csquery["a.torrent", r].Text(),
Comments = new Uri(string.Format(CommentsUrl, id)),
Link = new Uri(string.Format(DownloadUrl, id)),
PublishDate = DateTime.ParseExact(csquery["span.elapsedDate", r].FirstOrDefault().Attributes["title"].Replace(" at", ""), "dddd, MMMM d, yyyy h:mmtt", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(),
Size = ReleaseInfo.GetBytes(r.ChildNodes[4].InnerText),
Seeders = seeders,
Peers = seeders + leechers,
Category = MapTrackerCatToNewznab(category.ToString()),
MinimumSeedTime = 172800,
MinimumRatio = 1
};
// Return release info
return info;
} catch(Exception ex) {
// Log error if individual row parsing fails
logger.Error("Speed.cd row parsing error", ex, new { searchUrl, r.OuterHTML });
return null;
}
})
.Where(x => x != null) // Ensure that failed rows are not appended
.ToList<ReleaseInfo>(); // Convert results to list of release info
// Add the rows to the append to the releases list
releases.AddRange(releasesAppend);
// Increment to next page
i++;
}
catch (Exception ex)
{
// Log parser error is entire routine fails
OnParseError(response.Content, ex);
}
}
// Return the releases
return releases;
}