예제 #1
0
        protected List <NetflixCategory> setCategory(Dictionary <int, int> partnerMap)
        {
            List <NetflixCategory> notificationCategory = new List <NetflixCategory>();

            foreach (int ownerId in partnerMap.Keys)
            {
                Employe employee = (from p in _context.Employe
                                    where p.Id == ownerId
                                    select p).FirstOrDefault();

                NetflixCategory category = new NetflixCategory();
                category.id   = employee.IdSAP;
                category.Name = employee.Name;

                notificationCategory.Add(category);
            }
            return(notificationCategory);
        }
예제 #2
0
        private List<Category> GetSubCategories(Category parentCategory, string categoryType, uint startIndex, bool getSubGenres = false)
        {
            List<Category> cats = new List<Category>();
            string id = (parentCategory as RssLink).Url;
            string data;
            JObject json;
            if (getSubGenres)
            {
                Category subgenreCat = new Category() {Name = Translate("Subgenres"), SubCategories = new List<Category>(), ParentCategory = parentCategory, HasSubCategories = true, SubCategoriesDiscovered = true};
                data = MyGetWebData(ShaktiApi + "/" + BuildId + "/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=SLW32",
                    postData: @"{""paths"":[[""genres""," + id + @",""subgenres"",{""from"":0,""to"":20},""summary""]],""authURL"":""" + latestAuthUrl + @"""}",
                    contentType: "application/json");
                json = (JObject)JsonConvert.DeserializeObject(data);
                foreach (JToken token in json["value"]["genres"].Where(t => t.Values().Count() > 1 && t.First()["summary"] != null))
                {
                    JToken summary = token.First()["summary"];
                    RssLink subCat = new RssLink() { Name = summary["menuName"].Value<string>(), Url = summary["id"].Value<UInt32>().ToString(), HasSubCategories = true, ParentCategory = subgenreCat};
                    subCat.Other = (Func<List<Category>>)(() => GetSubCategories(subCat, categoryType, 0));
                    subgenreCat.SubCategories.Add(subCat);
                }
                if (subgenreCat.SubCategories.Count > 0)
                {
                    cats.Add(subgenreCat);
                }
            }

            data = MyGetWebData(ShaktiApi + "/" + BuildId + "/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=SLW32",
                postData: @"{""paths"":[[""" + categoryType + @"""," + id + @",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},[""summary"",""title"",""synopsis"",""queue"",""userRating"",""runtime"",""releaseYear""]],[""" + categoryType + @"""," + id + @",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},""boxarts"",""_342x192"",""jpg""]],""authURL"":""" + latestAuthUrl + @"""}",
                contentType: "application/json");
            json = (JObject)JsonConvert.DeserializeObject(data);
            if (json["value"] != null && json["value"]["videos"] != null)
            {
                foreach (JToken token in json["value"]["videos"].Where(t => t.Values().Count() > 1 && t.First()["title"] != null))
                {
                    JToken item = token.First();
                    JToken summary = item["summary"];
                    JToken userRating = item["userRating"];
                    NetflixCategory cat = new NetflixCategory() { ParentCategory = parentCategory, Name = item["title"].Value<string>(), HasSubCategories = true, InQueue = item["queue"]["inQueue"].Value<bool>(), IsShow = summary["type"].Value<string>() == "show" };
                    cat.Description = item["synopsis"].Value<string>() + "\r\n " + item["releaseYear"].Value<string>();
                    if (!string.IsNullOrWhiteSpace(userRating["userRating"].ToString()))
                        cat.Description += "\r\n" + Translate("User rating") + ": " + userRating["userRating"].ToString();
                    else if (!string.IsNullOrWhiteSpace(userRating["predicted"].ToString()))
                        cat.Description += "\r\n" + string.Format(Translate("Predicted rating for {0}"), ProfileName) + ": " + userRating["predicted"].ToString();
                    if (!string.IsNullOrWhiteSpace(userRating["average"].ToString()))
                        cat.Description += "\r\n" + Translate("Avg. rating") + ": " + userRating["average"].ToString();
                    cat.Runtime = cat.IsShow ? 0 : item["runtime"].Value<int>();
                    cat.Thumb = item["boxarts"]["_342x192"]["jpg"]["url"].Value<string>();
                    cat.Url = summary["id"].Value<UInt32>().ToString();
                    cat.Other = (Func<List<Category>>)(() => GetTitleCategories(cat));
                    cats.Add(cat);
                }
                if (cats.Count() > noOfItems)
                {
                    NextPageCategory next = new NextPageCategory() { ParentCategory = parentCategory };
                    next.Other = (Func<List<Category>>)(() => GetSubCategories(parentCategory, categoryType, noOfItems + startIndex + 1)); 
                    cats.Add(next);
                }
            }
            parentCategory.SubCategoriesDiscovered = true;
            return cats;
        }
예제 #3
0
        private List<Category> GetListCategories(Category parentCategory, string listType, uint startIndex)
        {
            List<Category> cats = new List<Category>();

            string data = MyGetWebData(ShaktiApi + "/" + BuildId + "/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=SLW32",
                postData: @"{""paths"":[[""lolomo"",""summary""],[""lolomo"",""" + listType + @""",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},[""summary"",""title"",""synopsis"",""queue"",""userRating"",""runtime"",""releaseYear""]],[""lolomo"",""" + listType + @""",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},""boxarts"",""_342x192"",""jpg""],[""lolomo"",""" + listType + @""",[""context"",""id"",""length"",""name"",""trackIds"",""requestId""]]],""authURL"":""" + latestAuthUrl + @"""}",
                contentType: "application/json");
            JObject json = (JObject)JsonConvert.DeserializeObject(data);
            if (json["value"] != null && json["value"]["videos"] != null)
            {

                foreach (JToken token in json["value"]["videos"].Where(t => t.Values().Count() > 1 && t.First()["title"] != null))
                {
                    JToken item = token.First();
                    JToken summary = item["summary"];
                    JToken userRating = item["userRating"];
                    NetflixCategory cat = new NetflixCategory() { ParentCategory = parentCategory, Name = item["title"].Value<string>(), HasSubCategories = true, InQueue = item["queue"]["inQueue"].Value<bool>(), IsShow = summary["type"].Value<string>() == "show" };
                    cat.Description = item["synopsis"].Value<string>() + "\r\n" + item["releaseYear"].Value<string>();
                    if (!string.IsNullOrWhiteSpace(userRating["userRating"].ToString()))
                        cat.Description += "\r\n" + Translate("User rating") + ": " + userRating["userRating"].ToString();
                    else if (!string.IsNullOrWhiteSpace(userRating["predicted"].ToString()))
                        cat.Description += "\r\n"+ string.Format (Translate("Predicted rating for {0}"), ProfileName) +": " + userRating["predicted"].ToString();
                    if (!string.IsNullOrWhiteSpace(userRating["average"].ToString()))
                        cat.Description += "\r\n" + Translate("Avg. rating") + ": " + userRating["average"].ToString();
                    cat.Runtime = cat.IsShow ? 0 : item["runtime"].Value<int>();
                    cat.Thumb = item["boxarts"]["_342x192"]["jpg"]["url"].Value<string>();
                    cat.Url = summary["id"].Value<UInt32>().ToString();
                    cat.Other = (Func<List<Category>>)(() => GetTitleCategories(cat));
                    cats.Add(cat);
                }

                //Paging
                int length = json["value"]["lists"].First(t => t.Values().Count() > 1).First()["length"].Value<int>();
                if (length > noOfItems + startIndex)
                {
                    NextPageCategory next = new NextPageCategory() { ParentCategory = parentCategory };
                    next.Other = (Func<List<Category>>)(() => GetListCategories(parentCategory, listType, noOfItems + startIndex + 1));
                    cats.Add(next);
                }
            }
            //Do not remember My List, need to be able to load new items
            parentCategory.SubCategoriesDiscovered = false;
            return cats;
        }