コード例 #1
0
        private static void GetValidVideoRecursive(AnimeGroupRepository repGroups, GroupFilter f, int userid, Directory pp)
        {
            GroupFilterRepository repo = new GroupFilterRepository();
            List <GroupFilter>    gfs  = repo.GetByParentID(f.GroupFilterID).Where(a => a.GroupsIds.ContainsKey(userid) && a.GroupsIds[userid].Count > 0).ToList();

            foreach (GroupFilter gg in gfs.Where(a => (a.FilterType & (int)GroupFilterType.Directory) == 0))
            {
                if (gg.GroupsIds.ContainsKey(userid))
                {
                    HashSet <int> groups = gg.GroupsIds[userid];
                    if (groups.Count != 0)
                    {
                        foreach (int grp in groups)
                        {
                            AnimeGroup ag = repGroups.GetByID(grp);
                            Video      v  = ag.GetPlexContract(userid);
                            if (v?.Art != null && v.Thumb != null)
                            {
                                pp.Art   = Helper.ReplaceSchemeHost(v.Art);
                                pp.Thumb = Helper.ReplaceSchemeHost(v.Thumb);
                                break;
                            }
                        }
                    }
                }
                if (pp.Art != null)
                {
                    break;
                }
            }
            if (pp.Art == null)
            {
                foreach (GroupFilter gg in gfs.Where(a => (a.FilterType & (int)GroupFilterType.Directory) == (int)GroupFilterType.Directory && a.InvisibleInClients == 0))
                {
                    GetValidVideoRecursive(repGroups, gg, userid, pp);
                    if (pp.Art != null)
                    {
                        break;
                    }
                }
            }
            pp.LeafCount       = gfs.Count.ToString();
            pp.ViewedLeafCount = "0";
        }
コード例 #2
0
        public static Filter FilterFromGroupFilter(GroupFilter gg, int uid)
        {
            Filter ob = new Filter();

            ob.type = "show";
            ob.name = gg.GroupFilterName;
            ob.id   = gg.GroupFilterID;
            ob.url  = APIHelper.ConstructFilterIdUrl(gg.GroupFilterID);

            if (gg.GroupsIds.ContainsKey(uid))
            {
                HashSet <int> groups = gg.GroupsIds[uid];
                if (groups.Count != 0)
                {
                    ob.size   = groups.Count;
                    ob.viewed = 0;

                    foreach (int grp in groups)
                    {
                        AnimeGroup ag = RepoFactory.AnimeGroup.GetByID(grp);
                        Video      v  = ag.GetPlexContract(uid);
                        if (v?.Art != null && v.Thumb != null)
                        {
                            ob.art.fanart.Add(new Art()
                            {
                                url = APIHelper.ConstructImageLinkFromRest(v.Art), index = 0
                            });
                            ob.art.thumb.Add(new Art()
                            {
                                url = APIHelper.ConstructImageLinkFromRest(v.Thumb), index = 0
                            });
                            break;
                        }
                    }
                }
            }
            return(ob);
        }
コード例 #3
0
        public static Directory DirectoryFromFilter(AnimeGroupRepository repGroups, IProvider prov, GroupFilter gg,
                                                    int userid)
        {
            Directory pp = new Directory {
                Type = "show"
            };

            pp.Key       = prov.ConstructFilterIdUrl(userid, gg.GroupFilterID);
            pp.Title     = gg.GroupFilterName;
            pp.Id        = gg.GroupFilterID.ToString();
            pp.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimeGroupFilter.ToString();
            if ((gg.FilterType & (int)GroupFilterType.Directory) == (int)GroupFilterType.Directory)
            {
                GetValidVideoRecursive(repGroups, gg, userid, pp);
            }
            else if (gg.GroupsIds.ContainsKey(userid))
            {
                HashSet <int> groups = gg.GroupsIds[userid];
                if (groups.Count != 0)
                {
                    pp.LeafCount       = groups.Count.ToString();
                    pp.ViewedLeafCount = "0";
                    foreach (int grp in groups)
                    {
                        AnimeGroup ag = repGroups.GetByID(grp);
                        Video      v  = ag.GetPlexContract(userid);
                        if (v?.Art != null && v.Thumb != null)
                        {
                            pp.Art   = Helper.ReplaceSchemeHost(v.Art);
                            pp.Thumb = Helper.ReplaceSchemeHost(v.Thumb);
                            break;
                        }
                    }
                    return(pp);
                }
            }
            return(pp);
        }