Beispiel #1
0
        public void TestSplitSameArtistAlbum()
        {
            Cddb.DTitle artistAndAlbum = Cddb.SplitDiscTitle("Ensiferum");

            Assert.AreEqual("Ensiferum", artistAndAlbum.Artist);
            Assert.AreEqual("Ensiferum", artistAndAlbum.Title);
        }
Beispiel #2
0
        public void TestSplitDifferentArtistAlbum()
        {
            Cddb.DTitle artistAndAlbum = Cddb.SplitDiscTitle(
                "Catamenia / VIII: The Time Unchained"
                );

            Assert.AreEqual("Catamenia", artistAndAlbum.Artist);
            Assert.AreEqual("VIII: The Time Unchained", artistAndAlbum.Title);
        }
Beispiel #3
0
        public void TestDiscIdCalculation()
        {
            // Example given on wikipedia: CD with one track starting at 2 seconds
            Assert.AreEqual(
                0x020e1a01,
                Cddb.CalculateDiscId(3610, new int[] { 2 })
                );

            // Another example I've found on the 'net. It seems to be quite hard to track
            // down any test data to verify a given implementation of a CDDB disc id calculator
            Assert.AreEqual(
                0x2e0da505,
                Cddb.CalculateDiscId(
                    3493,
                    new int[] {
                182 / 75,    // 2
                19527 / 75,  // 260
                39015 / 75,  // 520
                132282 / 75, // 1763
                189270 / 75  // 2523
            }
                    )
                );
        }
Beispiel #4
0
        /// <summary>Interprets a keyword assignment appearing in an XMCD file</summary>
        /// <param name="name">Name of the keyword</param>
        /// <param name="value">Value assigned to the keyword</param>
        private void interpretKeyword(string name, string value)
        {
            if (name == "DISCID")
            {
                this.haveDiscId    = true;
                this.entry.DiscIds = parseDiscIds(value);
            }
            else if (name == "DTITLE")
            {
                this.haveTitle = true;
                Cddb.DTitle dTitle = Cddb.SplitDiscTitle(value);
                this.entry.Artist = dTitle.Artist;
                this.entry.Album  = dTitle.Title;
            }
            else if (name == "DYEAR")
            {
                this.haveYear   = true;
                this.entry.Year = Convert.ToInt32(value);
            }
            else if (name == "DGENRE")
            {
                this.haveGenre   = true;
                this.entry.Genre = value;
            }
            else if (name == "EXTD")
            {
                this.haveExtendedData = true;
            }
            else if (name == "PLAYORDER")
            {
                this.havePlayOrder = true;
            }
            else if (name.StartsWith("TTITLE"))
            {
                int trackIndex = Convert.ToInt32(name.Substring(6));

                // Make sure there are enough entries in the list (minus one because it allows
                // us to use the Add() method then, instead of adding an empty entry and replacing
                // it further down
                while (this.trackTitles.Count < trackIndex)
                {
                    this.trackTitles.Add(new Cddb.DTitle());
                }

                // Get the track title. If a " / " sequence is contained in the title, the track
                // contains an artist specification. Otherwise, leave the artist field set to
                // null because we can't be sure that the disc title field has been filled already.
                Cddb.DTitle track;
                if (value.Contains(" / "))
                {
                    track = Cddb.SplitDiscTitle(value);
                }
                else
                {
                    track = new Cddb.DTitle(null, value);
                }

                // Finally, add the track to the track list. If it is an out-of-order track, we
                // will replace the existing, empty entry. Otherwise, the list will be just one
                // element short of the track and we can normally add it.
                if (this.trackTitles.Count == trackIndex)
                {
                    this.trackTitles.Add(track);
                }
                else
                {
                    this.trackTitles[trackIndex] = track;
                }
            }
            else if (name.StartsWith("EXTT"))
            {
                // Ignore for now
            }
        }