Example #1
0
        public void SetCDInfo(CCDMetadata data, int track, CTDBResponseMetaTrack[] tr)
        {
            var t = tr[track];

            data.SetTrackTitle(track, t.name ?? "");
            data.SetTrackArtist(track, t.artist ?? "");
            data.SetExtendedTrackInformation(track, t.extra ?? "");
        }
Example #2
0
        public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
        {
            if (Options.CoversSearch == CTDBCoversSearch.None)
                cover = false;

            if (!cdinfo && !cover)
                return false;

            var TOC = new CDImageLayout();
            for (int i = 0; i < data.NumberOfTracks; i++)
            {
                uint start = data.GetTrackStartPosition(i);
                uint next = data.GetTrackEndPosition(i);
                TOC.AddTrack(new CDTrack(
                    (uint)i + 1,
                    start,
                    next - start,
                    !data.GetTrackDataTrack(i),
                    data.GetTrackPreemphasis(i)));
            }
            TOC[1][0].Start = 0U;

            var ctdb = new CUEToolsDB(TOC, null);
            var form = new CUETools.CTDB.EACPlugin.FormMetadata(ctdb, "EAC" + data.HostVersion + " CTDB 2.1.4", cdinfo, cover);
            form.ShowDialog();
            var meta = form.Meta;
            if (meta == null)
                return false;

            if (cdinfo)
            {
                int year, disccount, discnumber;
                string extra = meta.extra ?? "";
                if (!string.IsNullOrEmpty(meta.discname))
                    extra += "Disc name: " + meta.discname + "\r\n";
                if (!string.IsNullOrEmpty(meta.infourl))
                    extra += "Info URL: " + meta.infourl + "\r\n";
                if (!string.IsNullOrEmpty(meta.barcode))
                    extra += "Barcode: " + meta.barcode + "\r\n";
                if (!string.IsNullOrEmpty(meta.releasedate))
                    extra += "Release date: " + meta.releasedate + "\r\n";
                if (!string.IsNullOrEmpty(meta.country))
                    extra += "Release country: " + meta.country + "\r\n";
                if (meta.label != null)
                    foreach (var label in meta.label)
                    {
                        if (!string.IsNullOrEmpty(label.name))
                            extra += "Release label: " + label.name + "\r\n";
                        if (!string.IsNullOrEmpty(label.catno))
                            extra += "Release catalog#: " + label.catno + "\r\n";
                    }
                data.Year = meta.year != null && int.TryParse(meta.year, out year) ? year : -1;
                data.TotalNumberOfCDs = meta.disccount != null && int.TryParse(meta.disccount, out disccount) ? disccount : 1;
                data.CDNumber = meta.discnumber != null && int.TryParse(meta.discnumber, out discnumber) ? discnumber : 1;
                data.FirstTrackNumber = 1;
                data.AlbumTitle = meta.album ?? "";
                data.AlbumArtist = meta.artist ?? "";
                data.MP3V2Type = meta.genre ?? "";
                data.CDDBMusicType = GetFreeDBMusicType(meta);
                data.MP3Type = GetMP3MusicType(data.CDDBMusicType);
                data.ExtendedDiscInformation = extra;
                data.Revision = -1; // TODO: meta.id? rock/ffffffff/16?
                if (meta.track != null)
                {
                    int firstAudio = meta.track.Length == TOC.AudioTracks ? TOC.FirstAudio - 1 : 0;
                    for (int track = 0; track < data.NumberOfTracks; track++)
                    {
                        if (track - firstAudio >= 0 && track - firstAudio < meta.track.Length)
                        {
                            data.SetTrackTitle(track, meta.track[track - firstAudio].name ?? "");
                            data.SetTrackArtist(track, meta.track[track - firstAudio].artist ?? meta.artist ?? "");
                            data.SetExtendedTrackInformation(track, meta.track[track - firstAudio].extra ?? "");
                        }
                        else if (!TOC[track + 1].IsAudio)
                        {
                            data.SetTrackTitle(track, "[data track]");
                            data.SetTrackArtist(track, meta.artist ?? "");
                            data.SetExtendedTrackInformation(track, "");
                        }
                        else
                        {
                            data.SetTrackTitle(track, "");
                            data.SetTrackArtist(track, meta.artist ?? "");
                            data.SetExtendedTrackInformation(track, "");
                        }
                        data.SetTrackComposer(track, "");
                    }
                }
            }

            if (cover)
            {                
                data.CoverImage = null;
                data.CoverImageURL = "";
                if (form.Image != null)
                {
                    data.CoverImage = form.Image.Data;
                    data.CoverImageURL = form.Image.URL;
                }
            }

            return true;
        }
Example #3
0
        public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
        {
            var TOC = new CDImageLayout();

            for (int i = 0; i < data.NumberOfTracks; i++)
            {
                uint start = data.GetTrackStartPosition(i);
                uint next  = data.GetTrackEndPosition(i);
                TOC.AddTrack(new CDTrack(
                                 (uint)i + 1,
                                 start,
                                 next - start,
                                 !data.GetTrackDataTrack(i),
                                 data.GetTrackPreemphasis(i)));
            }
            TOC[1][0].Start = 0U;

            var form = new Form1();

            form.ShowDialog();
            var meta = form.Meta;

            int    year, disccount, discnumber;
            string extra = meta.extra ?? "";

            if (!string.IsNullOrEmpty(meta.discname))
            {
                extra += "Disc name: " + meta.discname + "\r\n";
            }
            if (!string.IsNullOrEmpty(meta.infourl))
            {
                extra += "Info URL: " + meta.infourl + "\r\n";
            }
            if (!string.IsNullOrEmpty(meta.barcode))
            {
                extra += "Barcode: " + meta.barcode + "\r\n";
            }
            if (meta.release != null)
            {
                foreach (var release in meta.release)
                {
                    if (!string.IsNullOrEmpty(release.date))
                    {
                        extra += "Release date: " + release.date + "\r\n";
                    }
                    if (!string.IsNullOrEmpty(release.country))
                    {
                        extra += "Release country: " + release.country + "\r\n";
                    }
                }
            }
            if (meta.label != null)
            {
                foreach (var label in meta.label)
                {
                    if (!string.IsNullOrEmpty(label.name))
                    {
                        extra += "Release label: " + label.name + "\r\n";
                    }
                    if (!string.IsNullOrEmpty(label.catno))
                    {
                        extra += "Release catalog#: " + label.catno + "\r\n";
                    }
                }
            }
            if (meta.track != null)
            {
                int firstAudio = meta.track.Length == TOC.AudioTracks ? TOC.FirstAudio - 1 : 0;
                for (int track = 0; track < data.NumberOfTracks; track++)
                {
                    if (track - firstAudio >= 0 && track - firstAudio < meta.track.Length)
                    {
                        SetCDInfo(data, track - firstAudio, meta.track);
                    }
                    else if (!TOC[track + 1].IsAudio)
                    {
                        data.SetTrackTitle(track, "[data track]");
                        if (!string.IsNullOrEmpty(meta.artist))
                        {
                            data.SetTrackArtist(track, meta.artist);
                        }
                        data.SetExtendedTrackInformation(track, "");
                    }
                    else
                    {
                        SetCDInfo(data, track, meta.track);
                    }

                    /*if (!string.IsNullOrEmpty(meta.artist))
                     *  data.SetTrackComposer(track, meta.artist);*/
                }
            }
            data.Year             = meta.year != null && int.TryParse(meta.year, out year) ? year : -1;
            data.TotalNumberOfCDs = meta.disccount != null && int.TryParse(meta.disccount, out disccount) ? disccount : 1;
            data.CDNumber         = meta.discnumber != null && int.TryParse(meta.discnumber, out discnumber) ? discnumber : 1;
            data.FirstTrackNumber = 1;
            data.AlbumTitle       = meta.album ?? "";
            data.AlbumArtist      = meta.artist ?? "";
            if (!string.IsNullOrEmpty(extra))
            {
                data.ExtendedDiscInformation = extra;
            }
            data.Revision = -1;

            if (cover)
            {
                data.CoverImage    = null;
                data.CoverImageURL = "";
                if (form.Image != null)
                {
                    data.CoverImage = form.Image.Data;
                }
            }

            return(true);
        }
Example #4
0
        public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
        {
            if (Options.CoversSearch == CTDBCoversSearch.None)
            {
                cover = false;
            }

            if (!cdinfo && !cover)
            {
                return(false);
            }

            var TOC = new CDImageLayout();

            for (int i = 0; i < data.NumberOfTracks; i++)
            {
                uint start = data.GetTrackStartPosition(i);
                uint next  = data.GetTrackEndPosition(i);
                TOC.AddTrack(new CDTrack(
                                 (uint)i + 1,
                                 start,
                                 next - start,
                                 !data.GetTrackDataTrack(i),
                                 data.GetTrackPreemphasis(i)));
            }
            TOC[1][0].Start = 0U;

            var ctdb = new CUEToolsDB(TOC, null);
            var form = new CUETools.CTDB.EACPlugin.FormMetadata(ctdb, "EAC" + data.HostVersion + " CTDB 2.1.8", cdinfo, cover);

            form.ShowDialog();
            var meta = form.Meta;

            if (meta == null)
            {
                return(false);
            }

            if (cdinfo)
            {
                int    year, disccount, discnumber;
                string extra = meta.extra ?? "";
                if (!string.IsNullOrEmpty(meta.discname))
                {
                    extra += "Disc name: " + meta.discname + "\r\n";
                }
                if (!string.IsNullOrEmpty(meta.infourl))
                {
                    extra += "Info URL: " + meta.infourl + "\r\n";
                }
                if (!string.IsNullOrEmpty(meta.barcode))
                {
                    extra += "Barcode: " + meta.barcode + "\r\n";
                }
                if (meta.release != null)
                {
                    foreach (var release in meta.release)
                    {
                        if (!string.IsNullOrEmpty(release.date))
                        {
                            extra += "Release date: " + release.date + "\r\n";
                        }
                        if (!string.IsNullOrEmpty(release.country))
                        {
                            extra += "Release country: " + release.country + "\r\n";
                        }
                    }
                }
                if (meta.label != null)
                {
                    foreach (var label in meta.label)
                    {
                        if (!string.IsNullOrEmpty(label.name))
                        {
                            extra += "Release label: " + label.name + "\r\n";
                        }
                        if (!string.IsNullOrEmpty(label.catno))
                        {
                            extra += "Release catalog#: " + label.catno + "\r\n";
                        }
                    }
                }
                data.Year                    = meta.year != null && int.TryParse(meta.year, out year) ? year : -1;
                data.TotalNumberOfCDs        = meta.disccount != null && int.TryParse(meta.disccount, out disccount) ? disccount : 1;
                data.CDNumber                = meta.discnumber != null && int.TryParse(meta.discnumber, out discnumber) ? discnumber : 1;
                data.FirstTrackNumber        = 1;
                data.AlbumTitle              = meta.album ?? "";
                data.AlbumArtist             = meta.artist ?? "";
                data.MP3V2Type               = meta.genre ?? "";
                data.CDDBMusicType           = GetFreeDBMusicType(meta);
                data.MP3Type                 = GetMP3MusicType(data.CDDBMusicType);
                data.ExtendedDiscInformation = extra;
                data.Revision                = -1; // TODO: meta.id? rock/ffffffff/16?
                if (meta.track != null)
                {
                    int firstAudio = meta.track.Length == TOC.AudioTracks ? TOC.FirstAudio - 1 : 0;
                    for (int track = 0; track < data.NumberOfTracks; track++)
                    {
                        if (track - firstAudio >= 0 && track - firstAudio < meta.track.Length)
                        {
                            data.SetTrackTitle(track, meta.track[track - firstAudio].name ?? "");
                            data.SetTrackArtist(track, meta.track[track - firstAudio].artist ?? meta.artist ?? "");
                            data.SetExtendedTrackInformation(track, meta.track[track - firstAudio].extra ?? "");
                        }
                        else if (!TOC[track + 1].IsAudio)
                        {
                            data.SetTrackTitle(track, "[data track]");
                            data.SetTrackArtist(track, meta.artist ?? "");
                            data.SetExtendedTrackInformation(track, "");
                        }
                        else
                        {
                            data.SetTrackTitle(track, "");
                            data.SetTrackArtist(track, meta.artist ?? "");
                            data.SetExtendedTrackInformation(track, "");
                        }
                        data.SetTrackComposer(track, "");
                    }
                }
            }

            if (cover)
            {
                data.CoverImage    = null;
                data.CoverImageURL = "";
                if (form.Image != null)
                {
                    data.CoverImage    = form.Image.Data;
                    data.CoverImageURL = form.Image.URL;
                }
            }

            return(true);
        }