Community Forums Archive

Go Back

Subject:CDDB support
Posted by: rsagevik
Date:8/28/2005 4:40:38 AM

I`ve got no scripting skills whatsoever, so I just wondered..
Would it be possible to make a script that would also support CDDB?
or modify the "Extract CD and encode" script to do the job.

regards
rune

Subject:RE: CDDB support
Reply by: _TJ
Date:9/10/2005 8:46:04 PM

Yes, this is possible. Although CDDB is no longer available as a service, the company formally known as CDDB is now called GraceNote, and they don't do business with individuals as far as I know.

However, there is a free service called FreeDB that uses the same protocols as the old CDDB service, and it is certainly possible to write a script that extracts IO and fetches song titles from FreeDB. The information that you need to send to the FreeDB service is available to scripts.

Here's some fragments to get you started.

How to look for CD Drives that have Audio CDs in them.

foreach (ISfCDDrive drv in app.CDDrives)
{
DPF("checking {0} for an audio cd", drv.Letter);
if ((drv.DiscType & DiscType.Audio) == DiscType.Audio)
{
// found an Audio CD,

SfSummaryInfo info = new SfSummaryInfo();
SfAudioMarkerList markers = Get_Album_Info(drv.DiscTOC, ref info);

foreach (SfAudioMarker mk in markers)
{
ISfFileHost file = drv.ExtractAudio(mk.Name, mk.Start, mk.Length,0);
if (null == file)
break;
if (SfStatus.Cancel == file.WaitForDoneOrCancel())
break;

file.Summary = info;
file.Summary.TrackNo = mk.Ident.ToString();
file.Summary.Title = mk.Name;

string szFilename = Path.Combine(@"c:\My Music\", mk.Name + ".mp3");
file.RenderAs(szFilename, "MP3","160 Kbps, CD Transparent Audio",null,
RenderOptions.RenderOnly | RenderOptions.AndClose);
}

// done extraction audio. Eject the disk...
drv.Eject(true);
}
}


Of course, you will have to write the Get_Album_Info function yourself. But I can assure you that the information in the ISfCDDiscTOC object is sufficient.



public SfAudioMarkerList Get_Album_Info(ISfCDDiscTOC disc, ref SfSummaryInfo info)
{
SfAudioMarkerList markers = disc.MarkerList();
info.Clear();

// fill in the marker list to contain song title, track number, start and end time

// fill in the SfSummaryInfo to contain Artist, Album, Genre and other information.

return markers;
}



Subject:RE: CDDB support
Reply by: hat3k
Date:10/26/2005 7:19:35 AM

TJ, can i email you?
Or please email me hat3k@mail.ru

Go Back