示例#1
0
        public IHttpActionResult Indexers()
        {
            var jsonReply = new JObject();

            try
            {
                jsonReply["result"] = "success";
                JArray items = new JArray();

                foreach (var indexer in indexerService.GetAllIndexers())
                {
                    var item = new JObject();
                    item["id"]            = indexer.ID;
                    item["name"]          = indexer.DisplayName;
                    item["description"]   = indexer.DisplayDescription;
                    item["type"]          = indexer.Type;
                    item["configured"]    = indexer.IsConfigured;
                    item["site_link"]     = indexer.SiteLink;
                    item["language"]      = indexer.Language;
                    item["last_error"]    = indexer.LastError;
                    item["potatoenabled"] = indexer.TorznabCaps.Categories.Select(c => c.ID).Any(i => PotatoController.MOVIE_CATS.Contains(i));

                    var caps = new JObject();
                    foreach (var cap in indexer.TorznabCaps.Categories)
                    {
                        caps[cap.ID.ToString()] = cap.Name;
                    }
                    item["caps"] = caps;
                    items.Add(item);
                }
                jsonReply["items"] = items;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in get_indexers");
                jsonReply["result"] = "error";
                jsonReply["error"]  = ex.Message;
            }
            return(Json(jsonReply));
        }