Esempio n. 1
0
		public override void CopyMetaFrom(PVContract contract) {

			base.CopyMetaFrom(contract);

			ThumbUrl = contract.ThumbUrl;

		}
Esempio n. 2
0
		public void SetUp() {

			manager = new PVManager<PVForSong>();
			pvContract = new PVContract { Id = 1, Author = "Miku!", Name = "A cool Miku PV", PVId = "3939", ThumbUrl = "http://youtube.com/thumb", Url = "http://youtube.com/39" };
			pvContract2 = new PVContract { Id = 2, Author = "Luka!", Name = "A cool Luka PV", PVId = "0303", ThumbUrl = "http://youtube.com/thumb3", Url = "http://youtube.com/3" };

		}
Esempio n. 3
0
		public PVForSong(Song song, PVContract contract)
			: base(contract) {

			Song = song;
			Length = contract.Length;
			ThumbUrl = contract.ThumbUrl ?? string.Empty;

		}
 public SongWithAlbumAndPVsContract(Song song, ContentLanguagePreference languagePreference, bool getPVs)
     : base(song, languagePreference)
 {
     if (getPVs)
         PVs = song.PVs.Select(p => new PVContract(p)).ToArray();
     else
         PVs = new PVContract[] {};
 }
Esempio n. 5
0
        public bool ContentEquals(PVContract pv)
        {
            if (pv == null)
            {
                return(false);
            }

            return(Name == pv.Name);
        }
Esempio n. 6
0
        public ActionResult ParsePVUrl(string pvUrl, string callback, DataFormat format = DataFormat.Auto)
        {
            var result = VideoServiceHelper.ParseByUrl(pvUrl, true);

            if (!result.IsOk) {
                return Json(new GenericResponse<string>(false, result.Exception.Message));
            }

            var contract = new PVContract(result, PVType.Original);

            return Object(contract, format, callback);
        }
Esempio n. 7
0
        public PVContract GetPVByUrl(string pvUrl, PVType type = PVType.Original)
        {
            if (string.IsNullOrEmpty(pvUrl))
                throw new HttpResponseException(HttpStatusCode.BadRequest);

            var result = pvParser.ParseByUrl(pvUrl, true, permissionContext);

            if (!result.IsOk) {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = result.Exception.Message });
            }

            var contract = new PVContract(result, type);
            return contract;
        }
Esempio n. 8
0
 public static PVContract[] GetMainPVs(PVContract[] allPvs)
 {
     return EnumVal<PVService>.Values.Select(service => VideoServiceHelper.GetPV(allPvs, service)).Where(p => p != null).ToArray();
 }
Esempio n. 9
0
        public void Sync_Contracts_Removed()
        {
            manager.PVs.Add(CreatePV(pvContract));
            var newLinks = new PVContract[] { };

            var result = manager.Sync(newLinks, CreatePV);

            Assert.IsNotNull(result, "result is not null");
            Assert.IsTrue(result.Changed, "is changed");
            Assert.AreEqual(0, result.Added.Length, "none added");
            Assert.AreEqual(0, result.Edited.Length, "none edited");
            Assert.AreEqual(1, result.Removed.Length, "1 removed");
            Assert.AreEqual(0, result.Unchanged.Length, "none unchanged");
            Assert.IsTrue(result.Removed.First().ContentEquals(pvContract), "removed link matches contract");
        }
Esempio n. 10
0
 private PVForSong CreatePV(PVContract contract)
 {
     return new PVForSong(new Song(), contract) { Id = contract.Id };
 }
Esempio n. 11
0
        public ActionResult CreatePVForSongByUrl(int songId, string pvUrl, PVType type)
        {
            var result = VideoServiceHelper.ParseByUrl(pvUrl, true);

            if (!result.IsOk) {
                return Json(new GenericResponse<string>(false, result.Exception.Message));
            }

            var contract = new PVContract(result, type);

            var view = RenderPartialViewToString("PVForSongEditRow", contract);
            return Json(new GenericResponse<string>(view));
        }
Esempio n. 12
0
        public bool ContentEquals(PVContract pv)
        {
            if (pv == null)
                return false;

            return (Name == pv.Name);
        }
Esempio n. 13
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));

            }
        }
Esempio n. 14
0
 public PVForAlbum(Album album, PVContract contract)
     : base(contract)
 {
     Album = album;
 }
Esempio n. 15
0
        public SongDetails(SongDetailsContract contract)
        {
            ParamIs.NotNull(() => 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;
            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;
            LikedTimes = contract.LikeCount;
            Lyrics = contract.LyricsFromParents;
            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();
            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);

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

            var nicoPvId = PVHelper.GetNicoId(pvs, NicoId);

            if (!string.IsNullOrEmpty(nicoPvId)) {
                WebLinks.Add(new WebLinkContract(VideoServiceUrlFactory.NicoSound.CreateUrl(nicoPvId),
                    ViewRes.Song.DetailsStrings.CheckNicoSound, WebLinkCategory.Other));
            }

            if (pvs.All(p => p.Service != PVService.Youtube)) {

                var nicoPV = VideoServiceHelper.PrimaryPV(pvs, PVService.NicoNicoDouga);
                var query = (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));

            }
        }