当前位置: 首页>>代码示例>>C#>>正文


C# ReleaseInfo.Clone方法代码示例

本文整理汇总了C#中Jackett.Models.ReleaseInfo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# ReleaseInfo.Clone方法的具体用法?C# ReleaseInfo.Clone怎么用?C# ReleaseInfo.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jackett.Models.ReleaseInfo的用法示例。


在下文中一共展示了ReleaseInfo.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:Jackett,项目名称:Jackett,代码行数:90,代码来源:GazelleTracker.cs


注:本文中的Jackett.Models.ReleaseInfo.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。