Exemple #1
0
        public SongDetails(SongDetailsContract contract, IUserPermissionContext userContext, PVHelper pvHelper)
        {
            ParamIs.NotNull(() => contract);

            Contract                   = contract;
            AdditionalNames            = contract.AdditionalNames;
            Albums                     = contract.Albums;
            AlternateVersions          = contract.AlternateVersions.Where(a => a.SongType != SongType.Original).ToArray();
            ArtistString               = contract.ArtistString;
            BrowsedAlbumId             = contract.Album?.Id;
            CanEdit                    = EntryPermissionManager.CanEdit(userContext, contract.Song);
            CanEditPersonalDescription = contract.CanEditPersonalDescription;
            CanRemoveTagUsages         = contract.CanRemoveTagUsages;
            CommentCount               = contract.CommentCount;
            CreateDate                 = contract.CreateDate;
            DefaultLanguageSelection   = contract.TranslatedName.DefaultLanguage;
            Deleted                    = contract.Deleted;
            Draft                     = contract.Song.Status == EntryStatus.Draft;
            FavoritedTimes            = contract.Song.FavoritedTimes;
            Hits                      = contract.Hits;
            Id                        = contract.Song.Id;
            IsFavorited               = contract.UserRating != SongVoteRating.Nothing;
            LatestComments            = contract.LatestComments;
            Length                    = contract.Song.LengthSeconds;
            LikedTimes                = contract.LikeCount;
            ListCount                 = contract.ListCount;
            Lyrics                    = contract.LyricsFromParents;
            MergedTo                  = contract.MergedTo;
            Name                      = contract.Song.Name;
            NicoId                    = contract.Song.NicoId;
            Notes                     = contract.Notes;
            OriginalVersion           = (contract.Song.SongType != SongType.Original ? contract.OriginalVersion : null);
            Pools                     = contract.Pools;
            PublishDate               = contract.Song.PublishDate;
            RatingScore               = contract.Song.RatingScore;
            ReleaseEvent              = contract.ReleaseEvent;
            PersonalDescriptionText   = contract.PersonalDescriptionText;
            PersonalDescriptionAuthor = contract.PersonalDescriptionAuthor;
            SongType                  = contract.Song.SongType;
            SongTypeTag               = contract.SongTypeTag;
            Status                    = contract.Song.Status;
            Suggestions               = contract.Suggestions;
            Tags                      = contract.Tags;
            UserRating                = contract.UserRating;
            WebLinks                  = contract.WebLinks.ToList();
            ContentFocus              = SongHelper.GetContentFocus(SongType);

            Animators    = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Animator)).ToArray();
            Bands        = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Band)).ToArray();
            Illustrators = ContentFocus == ContentFocus.Illustration ? contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Illustrator)).ToArray() : null;
            Performers   = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Vocalist)).ToArray();
            Producers    = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Producer)).ToArray();
            var subjectsForThis = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Subject)).ToArray();

            Subject      = subjectsForThis.Any() ? subjectsForThis : contract.SubjectsFromParents;
            OtherArtists = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Circle) ||
                                                  a.Categories.HasFlag(ArtistCategories.Label) ||
                                                  a.Categories.HasFlag(ArtistCategories.Other) ||
                                                  (ContentFocus != ContentFocus.Illustration && a.Categories.HasFlag(ArtistCategories.Illustrator))).ToArray();

            var pvs = contract.PVs;

            OriginalPVs     = pvs.Where(p => p.PVType == PVType.Original).ToArray();
            OtherPVs        = pvs.Where(p => p.PVType != PVType.Original).ToArray();
            PrimaryPV       = pvHelper.PrimaryPV(pvs);
            ThumbUrl        = VideoServiceHelper.GetThumbUrlPreferNotNico(pvs);
            ThumbUrlMaxSize = VideoServiceHelper.GetMaxSizeThumbUrl(pvs) ?? ThumbUrl;

            if (PrimaryPV == null && !string.IsNullOrEmpty(NicoId))
            {
                PrimaryPV = new PVContract {
                    PVId = NicoId, Service = PVService.NicoNicoDouga
                }
            }
            ;

            if (pvs.All(p => p.Service != PVService.Youtube))
            {
                var nicoPV = VideoServiceHelper.PrimaryPV(pvs, PVService.NicoNicoDouga);
                var query  = HttpUtility.UrlEncode((nicoPV != null && !string.IsNullOrEmpty(nicoPV.Name))
                                        ? nicoPV.Name
                                        : $"{ArtistString} {Name}");

                WebLinks.Add(new WebLinkContract($"http://www.youtube.com/results?search_query={query}",
                                                 ViewRes.Song.DetailsStrings.SearchYoutube, WebLinkCategory.Other, disabled: false));
            }

            JsonModel = new SongDetailsAjax(this, contract.PreferredLyrics, contract.Song.Version);

            MinMilliBpm = contract.MinMilliBpm;
            MaxMilliBpm = contract.MaxMilliBpm;
        }
Exemple #2
0
        public SongDetails(SongDetailsContract contract)
        {
            ParamIs.NotNull(() => contract);

            Contract                 = contract;
            AdditionalNames          = contract.AdditionalNames;
            Albums                   = contract.Albums;
            AlternateVersions        = contract.AlternateVersions.Where(a => a.SongType != SongType.Original).ToArray();
            ArtistString             = contract.ArtistString;
            CanEdit                  = EntryPermissionManager.CanEdit(MvcApplication.LoginManager, contract.Song);
            CommentCount             = contract.CommentCount;
            CreateDate               = contract.CreateDate;
            DefaultLanguageSelection = contract.TranslatedName.DefaultLanguage;
            Deleted                  = contract.Deleted;
            Draft           = contract.Song.Status == EntryStatus.Draft;
            FavoritedTimes  = contract.Song.FavoritedTimes;
            Hits            = contract.Hits;
            Id              = contract.Song.Id;
            IsFavorited     = contract.UserRating != SongVoteRating.Nothing;
            LatestComments  = contract.LatestComments;
            Length          = contract.Song.LengthSeconds;
            LikedTimes      = contract.LikeCount;
            ListCount       = contract.ListCount;
            Lyrics          = contract.LyricsFromParents;
            MergedTo        = contract.MergedTo;
            Name            = contract.Song.Name;
            NicoId          = contract.Song.NicoId;
            Notes           = contract.Notes;
            OriginalVersion = (contract.Song.SongType != SongType.Original ? contract.OriginalVersion : null);
            Pools           = contract.Pools;
            RatingScore     = contract.Song.RatingScore;
            SongType        = contract.Song.SongType;
            Status          = contract.Song.Status;
            Tags            = contract.Tags;
            UserRating      = contract.UserRating;
            WebLinks        = contract.WebLinks.ToList();

            Animators    = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Animator)).ToArray();
            Bands        = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Band)).ToArray();
            Performers   = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Vocalist)).ToArray();
            Producers    = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Producer)).ToArray();
            OtherArtists = contract.Artists.Where(a => a.Categories.HasFlag(ArtistCategories.Circle) ||
                                                  a.Categories.HasFlag(ArtistCategories.Label) ||
                                                  a.Categories.HasFlag(ArtistCategories.Other)).ToArray();

            var pvs = contract.PVs;

            OriginalPVs     = pvs.Where(p => p.PVType == PVType.Original).ToArray();
            OtherPVs        = pvs.Where(p => p.PVType != PVType.Original).ToArray();
            PrimaryPV       = PVHelper.PrimaryPV(pvs);
            ThumbUrl        = VideoServiceHelper.GetThumbUrlPreferNotNico(pvs);
            ThumbUrlMaxSize = VideoServiceHelper.GetMaxSizeThumbUrl(pvs) ?? ThumbUrl;

            /*var nicoMimiUrl = GetNicoMimiUrl(contract);
             * if (!string.IsNullOrEmpty(nicoMimiUrl)) {
             *      WebLinks.Add(new WebLinkContract(nicoMimiUrl, ViewRes.Song.DetailsStrings.NicoMimiDownload, WebLinkCategory.Other));
             * }*/

            if (PrimaryPV == null && !string.IsNullOrEmpty(NicoId))
            {
                PrimaryPV = new PVContract {
                    PVId = NicoId, Service = PVService.NicoNicoDouga
                }
            }
            ;

            if (pvs.All(p => p.Service != PVService.Youtube))
            {
                var nicoPV = VideoServiceHelper.PrimaryPV(pvs, PVService.NicoNicoDouga);
                var query  = HttpUtility.UrlEncode((nicoPV != null && !string.IsNullOrEmpty(nicoPV.Name))
                                        ? nicoPV.Name
                                        : string.Format("{0} {1}", ArtistString, Name));

                WebLinks.Add(new WebLinkContract(string.Format("http://www.youtube.com/results?search_query={0}", query),
                                                 ViewRes.Song.DetailsStrings.SearchYoutube, WebLinkCategory.Other));
            }
        }