Example #1
0
        public MikuDbAlbumContract Parse(Stream input)
        {
            var tracks = new List <ImportedAlbumTrack>();
            var parser = new DataRowParser();
            var data   = new ImportedAlbumDataContract();

            data.Title = "Unknown";

            using (var reader = new StreamReader(input)) {
                string row;
                while ((row = reader.ReadLine()) != null)
                {
                    if (!parser.IsConfigured)
                    {
                        parser.Configure(row);
                    }
                    else
                    {
                        var dataRow = new DataRow(parser, row);

                        var albumName = dataRow.GetString(AlbumFileField.Album, string.Empty);
                        if (albumName != string.Empty)
                        {
                            data.Title = albumName;
                        }

                        var year = dataRow.GetIntOrDefault(AlbumFileField.Year, 0);
                        if (year != 0)
                        {
                            data.ReleaseYear = year;
                        }

                        var track = ParseTrack(dataRow, tracks.Count + 1);
                        tracks.Add(track);
                    }
                }
            }

            data.ArtistNames   = tracks.SelectMany(t => t.ArtistNames).Distinct().ToArray();
            data.VocalistNames = tracks.SelectMany(t => t.VocalistNames).Distinct().ToArray();
            data.Tracks        = tracks.OrderBy(t => t.TrackNum).ToArray();

            return(new MikuDbAlbumContract(data));
        }
Example #2
0
		public MikuDbAlbumContract Parse(Stream input) {

			var tracks = new List<ImportedAlbumTrack>();
			var parser = new DataRowParser();
			var data = new ImportedAlbumDataContract();
			data.Title = "Unknown";

			using (var reader = new StreamReader(input)) {

				string row;
				while ((row = reader.ReadLine()) != null) {

					if (!parser.IsConfigured) {
						parser.Configure(row);
					} else {

						var dataRow = new DataRow(parser, row);

						var albumName = dataRow.GetString(AlbumFileField.Album, string.Empty);
						if (albumName != string.Empty)
							data.Title = albumName;

						var year = dataRow.GetIntOrDefault(AlbumFileField.Year, 0);
						if (year != 0)
							data.ReleaseYear = year;

						var track = ParseTrack(dataRow, tracks.Count + 1);
						tracks.Add(track);

					}

				}

			}

			data.ArtistNames = tracks.SelectMany(t => t.ArtistNames).Distinct().ToArray();
			data.VocalistNames = tracks.SelectMany(t => t.VocalistNames).Distinct().ToArray();
			data.Tracks = tracks.OrderBy(t => t.TrackNum).ToArray();

			return new MikuDbAlbumContract(data);

		}
Example #3
0
 public DataRow(DataRowParser rowParser, string row)
 {
     this.rowParser = rowParser;
     this.cols      = row.Split(';');
 }
Example #4
0
		public DataRow(DataRowParser rowParser, string row) {
			this.rowParser = rowParser;
			this.cols = row.Split(';');
		}