public SongInAlbumEditContract(SongInAlbum songInAlbum, ContentLanguagePreference languagePreference) {

			ParamIs.NotNull(() => songInAlbum);

			DiscNumber = songInAlbum.DiscNumber;
			SongInAlbumId = songInAlbum.Id;
			TrackNumber = songInAlbum.TrackNumber;

			ArtistString = string.Empty;
			SongAdditionalNames = string.Empty;
			SongId = 0;

			var song = songInAlbum.Song;
			if (song != null) {

				Artists = song.ArtistList.Select(a => new ArtistContract(a, languagePreference)).ToArray();
				ArtistString = song.ArtistString[languagePreference];
				SongName = song.TranslatedName[languagePreference];
				SongAdditionalNames = string.Join(", ", song.AllNames.Where(n => n != SongName));
				SongId = song.Id;

			} else {
				
				Artists = new ArtistContract[0];
				SongName = songInAlbum.Name;

			}

			IsCustomTrack = song == null;

		}
예제 #2
0
		private string GetVocalistStr(SongInAlbum track, ContentLanguagePreference languagePreference) {

			if (track.Song == null)
				return string.Empty;

			return string.Join(", ", ArtistHelper.GetVocalistNames(track.Song.Artists, languagePreference));

		}
예제 #3
0
		private string GetProducerStr(SongInAlbum track, ContentLanguagePreference languagePreference) {

			if (track.Song == null)
				return string.Empty;

			return string.Join(", ", ArtistHelper.GetProducerNames(track.Song.Artists, SongHelper.IsAnimation(track.Song.SongType), languagePreference));

		}
예제 #4
0
        public SongInAlbumContract(SongInAlbum songInAlbum, ContentLanguagePreference languagePreference)
        {
            ParamIs.NotNull(() => songInAlbum);

            DiscNumber = songInAlbum.DiscNumber;
            Id = songInAlbum.Id;
            Song = new SongWithAdditionalNamesContract(songInAlbum.Song, languagePreference);
            TrackNumber = songInAlbum.TrackNumber;
        }
        public SongInAlbumEditContract(SongInAlbum songInAlbum, ContentLanguagePreference languagePreference)
        {
            ParamIs.NotNull(() => songInAlbum);

            ArtistString = songInAlbum.Song.ArtistString[languagePreference];
            DiscNumber = songInAlbum.DiscNumber;
            SongName = songInAlbum.Song.TranslatedName[languagePreference];
            SongAdditionalNames = string.Join(", ", songInAlbum.Song.AllNames.Where(n => n != SongName));
            SongId = songInAlbum.Song.Id;
            SongInAlbumId = songInAlbum.Id;
            TrackNumber = songInAlbum.TrackNumber;
        }
예제 #6
0
        public virtual bool Equals(SongInAlbum another)
        {
            if (another == null)
                return false;

            if (ReferenceEquals(this, another))
                return true;

            if (Id == 0)
                return false;

            return this.Id == another.Id;
        }
예제 #7
0
		public SongInAlbumContract(SongInAlbum songInAlbum, ContentLanguagePreference languagePreference, bool getThumbUrl = true) {
			
			ParamIs.NotNull(() => songInAlbum);

			DiscNumber = songInAlbum.DiscNumber;
			Id = songInAlbum.Id;
			TrackNumber = songInAlbum.TrackNumber;

			var song = songInAlbum.Song;
			Song = song != null ? new SongContract(song, languagePreference, getThumbUrl) : null;
			Name = Song != null ? Song.Name : songInAlbum.Name;

		}
예제 #8
0
		public SongInAlbumRefContract(SongInAlbum songInAlbum) {

			DiscNumber = songInAlbum.DiscNumber;
			TrackNumber = songInAlbum.TrackNumber;

			var song = songInAlbum.Song;
			if (song != null) {
				Id = song.Id;
				NameHint = song.DefaultName;
			} else {
				NameHint = songInAlbum.Name;
			}

		}
예제 #9
0
        private string ApplyFormat(SongInAlbum track, string format, ContentLanguagePreference languagePreference)
        {
            var album = track.Album;
            var sb = new StringBuilder(format);

            sb.Replace("%album%", GetField(album.Names.SortNames[languagePreference]));
            sb.Replace("%artists%", GetField(track.Song.ArtistString[languagePreference]));
            sb.Replace("%discnumber%", track.DiscNumber.ToString());
            sb.Replace("%producers%", GetField(string.Join(", ", ArtistHelper.GetProducerNames(track.Song.Artists, SongHelper.IsAnimation(track.Song.SongType), languagePreference))));
            sb.Replace("%title%", GetField(track.Song.Names.SortNames[languagePreference]));
            sb.Replace("%track%", track.TrackNumber.ToString());
            sb.Replace("%vocalists%", GetField(string.Join(", ", ArtistHelper.GetVocalistNames(track.Song.Artists, languagePreference))));

            return sb.ToString();
        }
예제 #10
0
		public static Tag[] GetGenreTags(SongInAlbum songInAlbum) {

			Tag[] genres;

			if (songInAlbum.Song != null) {

				genres = songInAlbum.Song.Tags.TagsByVotes.Where(t => t.CategoryName == Tag.CommonCategory_Genres).ToArray();

				if (genres.Any())
					return genres.ToArray();
				
			}

			genres = songInAlbum.Album.Tags.TagsByVotes.Where(t => t.CategoryName == Tag.CommonCategory_Genres).ToArray();
			return genres.ToArray();

		}
예제 #11
0
        public virtual bool Equals(SongInAlbum another)
        {
            if (another == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, another))
            {
                return(true);
            }

            if (Id == 0)
            {
                return(false);
            }

            return(this.Id == another.Id);
        }
예제 #12
0
		public void SetUp() {

			album = new Album(new LocalizedString("Synthesis", ContentLanguageSelection.English));

			producer = new Artist(TranslatedString.Create("Tripshots")) { Id = 1, ArtistType = ArtistType.Producer };
			vocalist = new Artist(TranslatedString.Create("Hatsune Miku")) { Id = 39, ArtistType = ArtistType.Vocaloid };
			producerContract = new ArtistContract(producer, ContentLanguagePreference.Default);
			vocalistContract = new ArtistContract(vocalist, ContentLanguagePreference.Default);

			song1 = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = 2 };
			song1.AddArtist(producer);

			album.AddArtist(producer);
			album.AddArtist(vocalist);

			var songInAlbum = new SongInAlbum(song1, album, 1, 1);
			songInAlbumContract = new SongInAlbumEditContract(songInAlbum, ContentLanguagePreference.Default);
			songInAlbumContract.Artists = new[] { producerContract };

		}
예제 #13
0
		private void ReplaceField(
			string tokenName, string tokenStr, StringBuilder sb, SongInAlbum track, ContentLanguagePreference languagePreference) {

			var val = GetField(GetFieldValue(tokenName, track, languagePreference));
			sb.Replace(tokenStr, val);

		}
예제 #14
0
		private void AssertEquals(SongInAlbum first, SongInAlbumEditContract second, string message) {
			
			Assert.IsTrue(Album.TrackPropertiesEqual(first, second), message);
			Assert.IsTrue(Album.TrackArtistsEqual(first.Song, second), message);

		}
예제 #15
0
 public SongInAlbumRefContract(SongInAlbum songInAlbum)
     : base(songInAlbum.Song)
 {
     DiscNumber = songInAlbum.DiscNumber;
     TrackNumber = songInAlbum.TrackNumber;
 }
예제 #16
0
		private string GetFieldValue(string fieldName, SongInAlbum track, ContentLanguagePreference languagePreference) {

			var album = track.Album;

			switch (fieldName.ToLowerInvariant()) {
				// Album title
				case "album":			
					return album.Names.SortNames[languagePreference];

				// Artists for album
				case "albumartist":
					return album.ArtistString[languagePreference];
				case "album artist": // foobar style
					return album.ArtistString[languagePreference];

				case "albummaincircle":
					var circle = ArtistHelper.GetMainCircle(album.Artists.ToArray(), AlbumHelper.IsAnimation(album.DiscType));
					return (circle != null ? circle.TranslatedName[languagePreference] : GetAlbumMainProducersStr(album, languagePreference));

				// Artists for song, both producers and vocalists
				case "artist":			
					return track.Song != null ? track.Song.ArtistString[languagePreference] : string.Empty;
				case "track artist": // foobar style
					return track.Song != null ? track.Song.ArtistString[languagePreference] : string.Empty;

				case "catalognum":
					return (album.OriginalRelease != null ? album.OriginalRelease.CatNum : string.Empty);

				case "disccount":
					return (album.Songs.Any() ? album.Songs.Max(s => s.DiscNumber) : 0).ToString();

				// Disc number
				case "discnumber":		
					return track.DiscNumber.ToString();

				// List of vocalists, separated by comma, with "feat." in the beginning if there are any vocalists, otherwise empty.
				case "featvocalists":	
					var vocalistStr = GetVocalistStr(track, languagePreference);
					return (vocalistStr.Any() ? " feat. " + vocalistStr : string.Empty);

				case "genres":
					return string.Join(", ", SongHelper.GetGenreTags(track).Select(t => t.NameWithSpaces));

				// List of producers
				case "producers":		
					return GetProducerStr(track, languagePreference);

				// Album release date
				case "releasedate":		
					return track.Album.OriginalReleaseDate.ToString();

				case "releaseyear":
					return track.Album.OriginalReleaseDate.Year.ToString();

				case "releaseevent":
					return album.OriginalReleaseEventName;

				// Song title
				case "title":			
					return track.Song != null ? track.Song.Names.SortNames[languagePreference] : track.Name;

				case "totaltrackcount":
					return album.Songs.Count().ToString();

				// Track number
				case "track":			
					return track.TrackNumber.ToString();
				case "tracknumber": // foobar style
					return track.TrackNumber.ToString();

				// List of vocalists, separated by comma.
				case "vocalists":		
					return GetVocalistStr(track, languagePreference);

				default:
					return string.Empty;
			}

		}
예제 #17
0
		private string ApplyFormat(SongInAlbum track, string format, ContentLanguagePreference languagePreference, MatchCollection fieldMatches) {

			var sb = new StringBuilder(format);

			foreach (Match match in fieldMatches) {
				ReplaceField(match.Groups[1].Value, match.Value, sb, track, languagePreference);
			}

			return sb.ToString();

		}