Пример #1
0
        public EntryForApiContract(Song song, ContentLanguagePreference languagePreference, EntryOptionalFields includedFields)
            : this((IEntryWithNames)song, languagePreference)
        {
            ArtistString = song.ArtistString[languagePreference];
            CreateDate   = song.CreateDate;
            SongType     = song.SongType;
            Status       = song.Status;

            var thumb = VideoServiceHelper.GetThumbUrl(song.PVs.PVs);

            if (includedFields.HasFlag(EntryOptionalFields.MainPicture) && !string.IsNullOrEmpty(thumb))
            {
                MainPicture = new EntryThumbForApiContract {
                    UrlSmallThumb = thumb, UrlThumb = thumb, UrlTinyThumb = thumb
                };
            }

            if (includedFields.HasFlag(EntryOptionalFields.Names))
            {
                Names = song.Names.Select(n => new LocalizedStringContract(n)).ToArray();
            }

            if (includedFields.HasFlag(EntryOptionalFields.Tags))
            {
                Tags = song.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray();
            }

            if (includedFields.HasFlag(EntryOptionalFields.WebLinks))
            {
                WebLinks = song.WebLinks.Select(w => new ArchivedWebLinkContract(w)).ToArray();
            }
        }
        public void GetThumbUrl_HasOnlyReprint()
        {
            var pvs = new[] { reprintWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            Assert.AreEqual("reprint", result, "result");
        }
        public void GetThumbUrl_HasOriginalWithThumb()
        {
            var pvs = new[] { reprintWithThumb, originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            Assert.AreEqual("original", result, "result");
        }
Пример #4
0
        public void GetThumbUrl_HasOnlyReprint()
        {
            var pvs = new[] { _reprintWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be("reprint", "result");
        }
Пример #5
0
        public void GetThumbUrl_HasOriginalWithThumb()
        {
            var pvs = new[] { _reprintWithThumb, _originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be("original", "result");
        }
        public void GetThumbUrl_Disabled()
        {
            originalWithThumb.Disabled = true;
            var pvs = new[] { reprintWithThumb, originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            Assert.AreEqual("reprint", result, "result");
        }
Пример #7
0
 public SongContract(Song song, ContentLanguagePreference languagePreference, bool getThumbUrl = true)
     : this(song, languagePreference, string.Empty)
 {
     if (getThumbUrl)
     {
         // TODO: Used on the front page. Should be moved elsewhere.
         ThumbUrl = VideoServiceHelper.GetThumbUrl(song.PVs.PVs);
     }
 }
Пример #8
0
        public void GetThumbUrl_Disabled()
        {
            _originalWithThumb.Disabled = true;
            var pvs = new[] { _reprintWithThumb, _originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be("reprint", "result");
        }
Пример #9
0
        public void GetThumbUrl_HasReprintWithThumb()
        {
            _originalWithThumb.ThumbUrl = string.Empty;
            var pvs = new[] { _reprintWithThumb, _originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be("reprint", "result");
        }
        public void GetThumbUrl_HasReprintWithThumb()
        {
            originalWithThumb.ThumbUrl = string.Empty;
            var pvs = new[] { reprintWithThumb, originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            Assert.AreEqual("reprint", result, "result");
        }
        public void GetThumbUrl_HasNoThumbs()
        {
            originalWithThumb.ThumbUrl = string.Empty;
            reprintWithThumb.ThumbUrl  = string.Empty;
            var pvs       = new[] { reprintWithThumb, originalWithThumb };
            var nicoThumb = VideoService.NicoNicoDouga.GetThumbUrlById(originalWithThumb.PVId);

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            Assert.AreEqual(nicoThumb, result, "result");
        }
Пример #12
0
        public void GetThumbUrl_HasNoThumbs()
        {
            _originalWithThumb.ThumbUrl = string.Empty;
            _reprintWithThumb.ThumbUrl  = string.Empty;
            var pvs       = new[] { _reprintWithThumb, _originalWithThumb };
            var nicoThumb = VideoService.NicoNicoDouga.GetThumbUrlById(_originalWithThumb.PVId);

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be(nicoThumb, "result");
        }
Пример #13
0
        public SongForApiContract(Song song, ContentLanguagePreference languagePreference)
        {
            Albums  = song.Albums.Select(a => new AlbumContract(a.Album, languagePreference)).ToArray();
            Artists = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).ToArray();
            Tags    = song.Tags.Tags.Select(t => t.Name).ToArray();

            CreateDate          = song.CreateDate;
            DefaultName         = song.DefaultName;
            DefaultNameLanguage = song.Names.SortNames.DefaultLanguage;
            FavoritedTimes      = song.FavoritedTimes;
            Id          = song.Id;
            Names       = song.Names.Select(n => new LocalizedStringContract(n)).ToArray();
            PVServices  = song.PVServices;
            RatingScore = song.RatingScore;
            SongType    = song.SongType;
            Status      = song.Status;
            ThumbUrl    = VideoServiceHelper.GetThumbUrl(song.PVs.PVs);
            Version     = song.Version;
        }
Пример #14
0
 private string GetSongThumbUrl(IEntryBase entry)
 {
     return(entry is Song ? VideoServiceHelper.GetThumbUrl(((Song)entry).PVs.PVs) : string.Empty);
 }
Пример #15
0
 /// <summary>
 /// Gets primary thumbnail URL for this song.
 /// For new songs this is saved directly to the song entry, but for older entries the PVs list needs to be loaded.
 /// Therefore, there might be some performance penalty.
 /// See <see cref="ThumbUrl"/>.
 /// </summary>
 /// <returns>
 /// Absolute URL to song thumbnail. For example, http://tn-skr1.smilevideo.jp/smile?i=12849032.
 /// Can be null or empty if no thumbnail is available.
 /// </returns>
 public virtual string GetThumbUrl()
 {
     return(!string.IsNullOrEmpty(ThumbUrl) ? ThumbUrl : VideoServiceHelper.GetThumbUrl(PVs.PVs));
 }
Пример #16
0
        public SongForApiContract(Song song, SongMergeRecord mergeRecord, ContentLanguagePreference languagePreference,
                                  bool albums = true, bool artists = true, bool names = true, bool pvs = false, bool tags = true, bool thumbUrl = true, bool webLinks = false)
        {
            ArtistString        = song.ArtistString[languagePreference];
            CreateDate          = song.CreateDate;
            DefaultName         = song.DefaultName;
            DefaultNameLanguage = song.Names.SortNames.DefaultLanguage;
            FavoritedTimes      = song.FavoritedTimes;
            Id            = song.Id;
            LengthSeconds = song.LengthSeconds;
            Name          = song.Names.SortNames[languagePreference];
            PVServices    = song.PVServices;
            RatingScore   = song.RatingScore;
            SongType      = song.SongType;
            Status        = song.Status;
            Version       = song.Version;

            if (languagePreference != ContentLanguagePreference.Default)
            {
                AdditionalNames = song.Names.GetAdditionalNamesStringForLanguage(languagePreference);
                LocalizedName   = song.Names.SortNames[languagePreference];
            }

            if (albums)
            {
                Albums = song.Albums.Select(a => new AlbumContract(a.Album, languagePreference)).ToArray();
            }

            if (artists)
            {
                Artists = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).ToArray();
            }

            if (names)
            {
                Names = song.Names.Select(n => new LocalizedStringContract(n)).ToArray();
            }

            if (pvs)
            {
                PVs = song.PVs.Select(p => new PVContract(p)).ToArray();
            }

            if (tags)
            {
                Tags = song.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray();
            }

            if (thumbUrl)
            {
                ThumbUrl = VideoServiceHelper.GetThumbUrl(song.PVs.PVs);
            }

            if (webLinks)
            {
                WebLinks = song.WebLinks.Select(w => new WebLinkContract(w)).ToArray();
            }

            if (mergeRecord != null)
            {
                MergedTo = mergeRecord.Target.Id;
            }
        }
Пример #17
0
        public void GetThumbUrl_Nothing()
        {
            var result = VideoServiceHelper.GetThumbUrl(new IPVWithThumbnail[0]);

            result.Should().Be(string.Empty, "result");
        }
Пример #18
0
 public virtual void UpdateThumbUrl()
 {
     ThumbUrl = VideoServiceHelper.GetThumbUrl(PVs.PVs);
 }
        public void GetThumbUrl_Nothing()
        {
            var result = VideoServiceHelper.GetThumbUrl(new IPVWithThumbnail[0]);

            Assert.AreEqual(string.Empty, result, "result");
        }