Exemplo n.º 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");
        }
Exemplo n.º 4
0
        public void GetThumbUrl_HasOnlyReprint()
        {
            var pvs = new[] { _reprintWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be("reprint", "result");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 8
0
        public void GetThumbUrl_Disabled()
        {
            _originalWithThumb.Disabled = true;
            var pvs = new[] { _reprintWithThumb, _originalWithThumb };

            var result = VideoServiceHelper.GetThumbUrl(pvs);

            result.Should().Be("reprint", "result");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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;
        }
Exemplo n.º 14
0
 private string GetSongThumbUrl(IEntryBase entry)
 {
     return(entry is Song ? VideoServiceHelper.GetThumbUrl(((Song)entry).PVs.PVs) : string.Empty);
 }
Exemplo n.º 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));
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 17
0
        public void GetThumbUrl_Nothing()
        {
            var result = VideoServiceHelper.GetThumbUrl(new IPVWithThumbnail[0]);

            result.Should().Be(string.Empty, "result");
        }
Exemplo n.º 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");
        }