Пример #1
0
        private static Video FromGroup(CL_AnimeGroup_User grp, CL_AnimeSeries_User ser, int userid, int subgrpcnt)
        {
            Directory p = new Directory
            {
                Id        = grp.AnimeGroupID,
                AnimeType = AnimeTypes.AnimeGroup.ToString(),
                Title     = grp.GroupName,
                Summary   = grp.Description,
                Type      = "show",
                AirDate   = grp.Stat_AirDate_Min ?? DateTime.MinValue
            };

            if (grp.Stat_AllYears.Count > 0)
            {
                p.Year = grp.Stat_AllYears?.Min() ?? 0;
            }
            if (ser != null)
            {
                p.Thumb = ser.AniDBAnime?.AniDBAnime.DefaultImagePoster.GenPoster(null);
                p.Art   = ser.AniDBAnime?.AniDBAnime.DefaultImageFanart.GenArt(null);
            }
            p.LeafCount       = grp.UnwatchedEpisodeCount + grp.WatchedEpisodeCount;
            p.ViewedLeafCount = grp.WatchedEpisodeCount;
            p.ChildCount      = grp.Stat_SeriesCount + subgrpcnt;
            if ((grp.UnwatchedEpisodeCount == 0) && grp.WatchedDate.HasValue)
            {
                p.LastViewedAt = grp.WatchedDate.Value.ToUnixTime();
            }
            return(p);
        }
Пример #2
0
        public void UpdateGroupFilters()
        {
            IReadOnlyList <SVR_GroupFilter> gfs       = RepoFactory.GroupFilter.GetAll();
            List <SVR_AnimeGroup>           allGrps   = RepoFactory.AnimeGroup.GetAllTopLevelGroups(); // No Need of subgroups
            IReadOnlyList <SVR_AnimeSeries> allSeries = RepoFactory.AnimeSeries.GetAll();

            foreach (SVR_GroupFilter gf in gfs)
            {
                bool change = false;
                foreach (SVR_AnimeGroup grp in allGrps)
                {
                    CL_AnimeGroup_User cgrp = grp.GetUserContract(this.JMMUserID);
                    change |= gf.CalculateGroupFilterGroups(cgrp, this, JMMUserID);
                }
                foreach (SVR_AnimeSeries ser in allSeries)
                {
                    CL_AnimeSeries_User cser = ser.GetUserContract(this.JMMUserID);
                    change |= gf.CalculateGroupFilterSeries(cser, this, JMMUserID);
                }
                if (change)
                {
                    RepoFactory.GroupFilter.Save(gf);
                }
            }
        }
Пример #3
0
        public void UpdateGroupFilters()
        {
            List <SVR_AnimeGroup>           allGrps   = Repo.Instance.AnimeGroup.GetAllTopLevelGroups(); // No Need of subgroups
            IReadOnlyList <SVR_AnimeSeries> allSeries = Repo.Instance.AnimeSeries.GetAll();

            using (var upd = Repo.Instance.GroupFilter.BeginBatchUpdate(() => Repo.Instance.GroupFilter.GetAll()))
            {
                foreach (SVR_GroupFilter gf in upd)
                {
                    bool change = false;
                    foreach (SVR_AnimeGroup grp in allGrps)
                    {
                        CL_AnimeGroup_User cgrp = grp.GetUserContract(this.JMMUserID);
                        change |= gf.CalculateGroupFilterGroups(cgrp, this);
                    }
                    foreach (SVR_AnimeSeries ser in allSeries)
                    {
                        CL_AnimeSeries_User cser = ser.GetUserContract(this.JMMUserID);
                        change |= gf.CalculateGroupFilterSeries(cser, this);
                    }

                    if (change)
                    {
                        upd.Update(gf);
                    }
                }
                upd.Commit();
            }
        }
Пример #4
0
        public static CL_AnimeGroup_User DeepCopy(this CL_AnimeGroup_User c)
        {
            CL_AnimeGroup_User contract = new CL_AnimeGroup_User();
            contract.AnimeGroupID = c.AnimeGroupID;
            contract.AnimeGroupParentID = c.AnimeGroupParentID;
            contract.DefaultAnimeSeriesID = c.DefaultAnimeSeriesID;
            contract.GroupName = c.GroupName;
            contract.Description = c.Description;
            contract.IsFave = c.IsFave;
            contract.IsManuallyNamed = c.IsManuallyNamed;
            contract.UnwatchedEpisodeCount = c.UnwatchedEpisodeCount;
            contract.DateTimeUpdated = c.DateTimeUpdated;
            contract.WatchedEpisodeCount = c.WatchedEpisodeCount;
            contract.SortName = c.SortName;
            contract.WatchedDate = c.WatchedDate;
            contract.EpisodeAddedDate = c.EpisodeAddedDate;
            contract.LatestEpisodeAirDate = c.LatestEpisodeAirDate;
            contract.PlayedCount = c.PlayedCount;
            contract.WatchedCount = c.WatchedCount;
            contract.StoppedCount = c.StoppedCount;
            contract.OverrideDescription = c.OverrideDescription;
            contract.MissingEpisodeCount = c.MissingEpisodeCount;
            contract.MissingEpisodeCountGroups = c.MissingEpisodeCountGroups;
            contract.Stat_AirDate_Min = c.Stat_AirDate_Min;
            contract.Stat_AirDate_Max = c.Stat_AirDate_Max;
            contract.Stat_EndDate = c.Stat_EndDate;
            contract.Stat_SeriesCreatedDate = c.Stat_SeriesCreatedDate;
            contract.Stat_UserVotePermanent = c.Stat_UserVotePermanent;
            contract.Stat_UserVoteTemporary = c.Stat_UserVoteTemporary;
            contract.Stat_UserVoteOverall = c.Stat_UserVoteOverall;
            contract.Stat_IsComplete = c.Stat_IsComplete;
            contract.Stat_HasFinishedAiring = c.Stat_HasFinishedAiring;
            contract.Stat_IsCurrentlyAiring = c.Stat_IsCurrentlyAiring;
            contract.Stat_HasTvDBLink = c.Stat_HasTvDBLink;
            contract.Stat_HasMALLink = c.Stat_HasMALLink;
            contract.Stat_HasMovieDBLink = c.Stat_HasMovieDBLink;
            contract.Stat_HasMovieDBOrTvDBLink = c.Stat_HasMovieDBOrTvDBLink;
            contract.Stat_SeriesCount = c.Stat_SeriesCount;
            contract.Stat_EpisodeCount = c.Stat_EpisodeCount;
            contract.Stat_AniDBRating = c.Stat_AniDBRating;
            contract.ServerPosterPath = c.ServerPosterPath;
            contract.SeriesForNameOverride = c.SeriesForNameOverride;

            contract.Stat_AllCustomTags =
                new HashSet<string>(c.Stat_AllCustomTags, StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_AllTags = new HashSet<string>(c.Stat_AllTags, StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_AllYears = new HashSet<int>(c.Stat_AllYears);
            contract.Stat_AllTitles = new HashSet<string>(c.Stat_AllTitles, StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_AnimeTypes = new HashSet<string>(c.Stat_AnimeTypes,
                StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_AllVideoQuality =
                new HashSet<string>(c.Stat_AllVideoQuality, StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_AllVideoQuality_Episodes = new HashSet<string>(c.Stat_AllVideoQuality_Episodes,
                StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_AudioLanguages =
                new HashSet<string>(c.Stat_AudioLanguages, StringComparer.InvariantCultureIgnoreCase);
            contract.Stat_SubtitleLanguages = new HashSet<string>(c.Stat_SubtitleLanguages,
                StringComparer.InvariantCultureIgnoreCase);
            return contract;
        }
Пример #5
0
        // ReSharper disable once FunctionComplexityOverflow
        public void Populate(CL_AnimeGroup_User contract)
        {
            // readonly members
            AnimeGroupID              = contract.AnimeGroupID;
            AnimeGroupParentID        = contract.AnimeGroupParentID;
            DateTimeUpdated           = contract.DateTimeUpdated;
            IsManuallyNamed           = contract.IsManuallyNamed;
            MissingEpisodeCount       = contract.MissingEpisodeCount;
            MissingEpisodeCountGroups = contract.MissingEpisodeCountGroups;
            PlayedCount                   = contract.PlayedCount;
            StoppedCount                  = contract.StoppedCount;
            UnwatchedEpisodeCount         = contract.UnwatchedEpisodeCount;
            WatchedCount                  = contract.WatchedCount;
            EpisodeAddedDate              = contract.EpisodeAddedDate;
            WatchedDate                   = contract.WatchedDate;
            WatchedEpisodeCount           = contract.WatchedEpisodeCount;
            Stat_AirDate_Min              = contract.Stat_AirDate_Min;
            Stat_AirDate_Max              = contract.Stat_AirDate_Max;
            Stat_EndDate                  = contract.Stat_EndDate;
            Stat_SeriesCreatedDate        = contract.Stat_SeriesCreatedDate;
            Stat_UserVoteOverall          = contract.Stat_UserVoteOverall;
            Stat_UserVotePermanent        = contract.Stat_UserVotePermanent;
            Stat_UserVoteTemporary        = contract.Stat_UserVoteTemporary;
            Stat_AllTags                  = new HashSet <string>(contract.Stat_AllTags, StringComparer.InvariantCultureIgnoreCase);
            Stat_AllCustomTags            = new HashSet <string>(contract.Stat_AllCustomTags, StringComparer.InvariantCultureIgnoreCase);
            Stat_AllTitles                = new HashSet <string>(contract.Stat_AllTitles, StringComparer.InvariantCultureIgnoreCase);
            Stat_IsComplete               = contract.Stat_IsComplete;
            Stat_HasFinishedAiring        = contract.Stat_HasFinishedAiring;
            Stat_IsCurrentlyAiring        = contract.Stat_IsCurrentlyAiring;
            Stat_AllVideoQuality          = new HashSet <string>(contract.Stat_AllVideoQuality);
            Stat_AllVideoQuality_Episodes = new HashSet <string>(contract.Stat_AllVideoQuality_Episodes);
            Stat_AudioLanguages           = new HashSet <string>(contract.Stat_AudioLanguages);
            Stat_SubtitleLanguages        = new HashSet <string>(contract.Stat_SubtitleLanguages);
            Stat_HasTvDBLink              = contract.Stat_HasTvDBLink;
            Stat_HasTraktLink             = contract.Stat_HasTraktLink;
            Stat_HasMALLink               = contract.Stat_HasMALLink;
            Stat_HasMovieDBLink           = contract.Stat_HasMovieDBLink;
            Stat_HasMovieDBOrTvDBLink     = contract.Stat_HasMovieDBOrTvDBLink;
            Stat_SeriesCount              = contract.Stat_SeriesCount;
            Stat_EpisodeCount             = contract.Stat_EpisodeCount;
            Stat_AniDBRating              = contract.Stat_AniDBRating;

            // editable members
            GroupName            = contract.GroupName;
            IsFave               = contract.IsFave;
            SortName             = contract.SortName;
            DefaultAnimeSeriesID = contract.DefaultAnimeSeriesID;
            Description          = contract.Description;
        }
Пример #6
0
        public void UpdateGroupFilters()
        {
            IReadOnlyList <SVR_GroupFilter> gfs     = RepoFactory.GroupFilter.GetAll();
            List <SVR_AnimeGroup>           allGrps = RepoFactory.AnimeGroup.GetAllTopLevelGroups(); // No Need of subgroups

            foreach (SVR_GroupFilter gf in gfs)
            {
                bool change = false;
                foreach (SVR_AnimeGroup grp in allGrps)
                {
                    CL_AnimeGroup_User cgrp = grp.GetUserContract(JMMUserID);
                    change |= gf.UpdateGroupFilterFromGroup(cgrp, this);
                }
                if (change)
                {
                    RepoFactory.GroupFilter.Save(gf);
                }
            }
        }
Пример #7
0
        public static Video GenerateFromAnimeGroup(SVR_AnimeGroup grp, int userid, List <SVR_AnimeSeries> allSeries,
                                                   ISessionWrapper session = null)
        {
            CL_AnimeGroup_User cgrp = grp.GetUserContract(userid);
            int subgrpcnt           = grp.GetAllChildGroups().Count;

            if ((cgrp.Stat_SeriesCount == 1) && (subgrpcnt == 0))
            {
                SVR_AnimeSeries     ser    = ShokoServiceImplementation.GetSeriesForGroup(grp.AnimeGroupID, allSeries);
                CL_AnimeSeries_User cserie = ser?.GetUserContract(userid);
                if (cserie == null)
                {
                    return(null);
                }
                Video v = GenerateFromSeries(cserie, ser, ser.GetAnime(), userid, session);
                v.AirDate   = ser.AirDate;
                v.UpdatedAt = ser.LatestEpisodeAirDate.HasValue
                    ? ser.LatestEpisodeAirDate.Value.ToUnixTime()
                    : null;
                v.Group = cgrp;
                return(v);
            }
            else
            {
                SVR_AnimeSeries ser = grp.DefaultAnimeSeriesID.HasValue
                    ? allSeries.FirstOrDefault(a => a.AnimeSeriesID == grp.DefaultAnimeSeriesID.Value)
                    : allSeries.Find(a => a.AirDate != DateTime.MinValue);
                if (ser == null && allSeries.Count > 0)
                {
                    ser = allSeries[0];
                }
                CL_AnimeSeries_User cserie = ser?.GetUserContract(userid);
                Video v = FromGroup(cgrp, cserie, userid, subgrpcnt);
                v.Group     = cgrp;
                v.AirDate   = cgrp.Stat_AirDate_Min ?? DateTime.MinValue;
                v.UpdatedAt = cgrp.LatestEpisodeAirDate?.ToUnixTime();
                v.Rating    = (int)Math.Round((grp.AniDBRating / 100), 1);
                List <Tag> newTags = new List <Tag>();
                foreach (AniDB_Tag tag in grp.Tags)
                {
                    Tag      newTag   = new Tag();
                    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                    newTag.Value = textInfo.ToTitleCase(tag.TagName.Trim());
                    if (!newTags.Contains(newTag))
                    {
                        newTags.Add(newTag);
                    }
                }
                v.Genres = newTags;
                if (ser == null)
                {
                    return(v);
                }
                List <AnimeTitle> newTitles = ser.GetAnime()
                                              .GetTitles()
                                              .Select(title => new AnimeTitle
                {
                    Title    = title.Title,
                    Language = title.Language,
                    Type     = title.TitleType
                })
                                              .ToList();
                v.Titles = newTitles;

                v.Roles = new List <RoleTag>();

                //TODO Character implementation is limited in JMM, One Character, could have more than one Seiyuu
                if (ser.GetAnime()?.Contract?.AniDBAnime?.Characters != null)
                {
                    foreach (CL_AniDB_Character c in ser.GetAnime().Contract.AniDBAnime.Characters)
                    {
                        string       ch     = c?.CharName;
                        AniDB_Seiyuu seiyuu = c?.Seiyuu;
                        if (String.IsNullOrEmpty(ch))
                        {
                            continue;
                        }
                        RoleTag t = new RoleTag
                        {
                            Value = seiyuu?.SeiyuuName
                        };
                        if (seiyuu != null)
                        {
                            t.TagPicture = ConstructSeiyuuImage(null, seiyuu.AniDB_SeiyuuID);
                        }
                        t.Role            = ch;
                        t.RoleDescription = c?.CharDescription;
                        t.RolePicture     = ConstructCharacterImage(null, c.CharID);
                        v.Roles.Add(t);
                    }
                }
                if (cserie?.AniDBAnime?.AniDBAnime?.Fanarts != null)
                {
                    v.Fanarts = new List <Contract_ImageDetails>();
                    cserie?.AniDBAnime?.AniDBAnime?.Fanarts.ForEach(
                        a =>
                        v.Fanarts.Add(new Contract_ImageDetails
                    {
                        ImageID   = a.AniDB_Anime_DefaultImageID,
                        ImageType = a.ImageType
                    }));
                }
                if (cserie?.AniDBAnime?.AniDBAnime?.Banners == null)
                {
                    return(v);
                }
                v.Banners = new List <Contract_ImageDetails>();
                cserie?.AniDBAnime?.AniDBAnime?.Banners.ForEach(
                    a =>
                    v.Banners.Add(new Contract_ImageDetails
                {
                    ImageID   = a.AniDB_Anime_DefaultImageID,
                    ImageType = a.ImageType
                }));
                return(v);
            }
        }
Пример #8
0
        public static CL_AnimeGroup_User DeepCopy(this CL_AnimeGroup_User c)
        {
            CL_AnimeGroup_User contract = new CL_AnimeGroup_User
            {
                AnimeGroupID         = c.AnimeGroupID,
                AnimeGroupParentID   = c.AnimeGroupParentID,
                DefaultAnimeSeriesID = c.DefaultAnimeSeriesID,
                GroupName            = c.GroupName,
                Description          = c.Description,
                IsFave                    = c.IsFave,
                IsManuallyNamed           = c.IsManuallyNamed,
                UnwatchedEpisodeCount     = c.UnwatchedEpisodeCount,
                DateTimeUpdated           = c.DateTimeUpdated,
                WatchedEpisodeCount       = c.WatchedEpisodeCount,
                SortName                  = c.SortName,
                WatchedDate               = c.WatchedDate,
                EpisodeAddedDate          = c.EpisodeAddedDate,
                LatestEpisodeAirDate      = c.LatestEpisodeAirDate,
                PlayedCount               = c.PlayedCount,
                WatchedCount              = c.WatchedCount,
                StoppedCount              = c.StoppedCount,
                OverrideDescription       = c.OverrideDescription,
                MissingEpisodeCount       = c.MissingEpisodeCount,
                MissingEpisodeCountGroups = c.MissingEpisodeCountGroups,
                Stat_AirDate_Min          = c.Stat_AirDate_Min,
                Stat_AirDate_Max          = c.Stat_AirDate_Max,
                Stat_EndDate              = c.Stat_EndDate,
                Stat_SeriesCreatedDate    = c.Stat_SeriesCreatedDate,
                Stat_UserVotePermanent    = c.Stat_UserVotePermanent,
                Stat_UserVoteTemporary    = c.Stat_UserVoteTemporary,
                Stat_UserVoteOverall      = c.Stat_UserVoteOverall,
                Stat_IsComplete           = c.Stat_IsComplete,
                Stat_HasFinishedAiring    = c.Stat_HasFinishedAiring,
                Stat_IsCurrentlyAiring    = c.Stat_IsCurrentlyAiring,
                Stat_HasTvDBLink          = c.Stat_HasTvDBLink,
                Stat_HasTraktLink         = c.Stat_HasTraktLink,
                Stat_HasMALLink           = c.Stat_HasMALLink,
                Stat_HasMovieDBLink       = c.Stat_HasMovieDBLink,
                Stat_HasMovieDBOrTvDBLink = c.Stat_HasMovieDBOrTvDBLink,
                Stat_SeriesCount          = c.Stat_SeriesCount,
                Stat_EpisodeCount         = c.Stat_EpisodeCount,
                Stat_AniDBRating          = c.Stat_AniDBRating,
                ServerPosterPath          = c.ServerPosterPath,
                SeriesForNameOverride     = c.SeriesForNameOverride,

                Stat_AllCustomTags =
                    new HashSet <string>(c.Stat_AllCustomTags, StringComparer.InvariantCultureIgnoreCase),
                Stat_AllTags    = new HashSet <string>(c.Stat_AllTags, StringComparer.InvariantCultureIgnoreCase),
                Stat_AllYears   = new HashSet <int>(c.Stat_AllYears),
                Stat_AllTitles  = new HashSet <string>(c.Stat_AllTitles, StringComparer.InvariantCultureIgnoreCase),
                Stat_AnimeTypes = new HashSet <string>(c.Stat_AnimeTypes,
                                                       StringComparer.InvariantCultureIgnoreCase),
                Stat_AllVideoQuality =
                    new HashSet <string>(c.Stat_AllVideoQuality, StringComparer.InvariantCultureIgnoreCase),
                Stat_AllVideoQuality_Episodes = new HashSet <string>(c.Stat_AllVideoQuality_Episodes,
                                                                     StringComparer.InvariantCultureIgnoreCase),
                Stat_AudioLanguages =
                    new HashSet <string>(c.Stat_AudioLanguages, StringComparer.InvariantCultureIgnoreCase),
                Stat_SubtitleLanguages = new HashSet <string>(c.Stat_SubtitleLanguages,
                                                              StringComparer.InvariantCultureIgnoreCase)
            };

            return(contract);
        }