public CDInfoDetail GetDiscDetails(string category, string discid) { string[] content = GetInfo("cddb+read+" + category + "+" + discid); XMCDParser parser = new XMCDParser(); CDInfoDetail cdInfo = parser.Parse2(content); return(cdInfo); }
public static string createXMCD(CDInfoDetail cdinfo) { string newline = "\n"; int index = 0; StringBuilder content = new StringBuilder(400); StringBuilder tracks = new StringBuilder(100); StringBuilder extt = new StringBuilder(100); content.Append("# xmcd"); content.Append(newline); content.Append("#"); content.Append(newline); // Track frame offsets content.Append("# Track frame offsets:"); foreach (CDTrackDetail track in cdinfo.Tracks) { content.Append(newline); content.Append("#\t"); content.Append(track.Offset); // do the other info about track too... // track title tracks.Append(newline); tracks.Append("TTITLE"); tracks.Append(index); tracks.Append("="); tracks.Append(track.Title); // track EXTT extt.Append(newline); extt.Append("EXTT"); extt.Append(index); extt.Append("="); extt.Append(track.EXTT); index++; } // Disc Length content.Append(newline); content.Append("#"); content.Append(newline); content.Append("# Disc length: "); content.Append(cdinfo.Duration); content.Append(" seconds"); // Revision content.Append(newline); content.Append("#"); content.Append(newline); content.Append("# Revision: 0"); // App information content.Append(newline); content.Append("# Submitted via: "); content.Append(APPNAME); content.Append(" "); content.Append(APPVERSION); content.Append(newline); content.Append("#"); content.Append(newline); // DISC ID content.Append("DISCID="); content.Append(cdinfo.DiscID); content.Append(newline); // Title = Artist / Title content.Append("DTITLE="); content.Append(cdinfo.Artist); content.Append(" / "); content.Append(cdinfo.Title); content.Append(newline); // Year content.Append("DYEAR="); content.Append(cdinfo.Year); content.Append(newline); // Genre content.Append("DGENRE="); content.Append(cdinfo.Genre); //track titles content.Append(tracks); // EXTD content.Append(newline); content.Append("EXTD="); content.Append(cdinfo.EXTD); // EXTT content.Append(extt); // EXTD content.Append(newline); content.Append("PLAYORDER="); int[] order = cdinfo.PlayOrder; for (int i = 0; i < order.Length; i++) { if (i != 0) content.Append(','); content.Append(order[i]); } content.Append(newline); return content.ToString(); }
/// <summary> /// Queries FreeDB for the Audio CD inserted /// </summary> /// <param name = "drive"></param> private void QueryFreeDB(char drive) { log.Trace(">>>"); SetStatusLabel(localisation.ToString("Conversion", "FreeDBAccess")); string discId = string.Empty; CDInfoDetail MusicCD = new CDInfoDetail(); int driveID = Util.Drive2BassID(drive); if (driveID < 0) { SetStatusLabel(""); return; } log.Info("Starting FreeDB Lookup"); _main.Cursor = Cursors.WaitCursor; bindingList[driveID].Clear(); try { FreeDBQuery freedb = new FreeDBQuery(); freedb.Connect(); CDInfo[] cds = freedb.GetDiscInfo(drive); if (cds != null) { log.Debug("FreeDB: Found {0} matching discs.", cds.Length); if (cds.Length == 1) { MusicCD = freedb.GetDiscDetails(cds[0].Category, cds[0].DiscId); } else { FreeDBMultiCDSelect multiCDSelect = new FreeDBMultiCDSelect(); multiCDSelect.CDList.ValueMember = "DiscId"; multiCDSelect.CDList.DisplayMember = "Title"; multiCDSelect.CDList.DataSource = cds; if (multiCDSelect.ShowDialog() == DialogResult.OK) { MusicCD = freedb.GetDiscDetails(cds[0].Category, multiCDSelect.DiscID); } else { MusicCD = null; } } } else { log.Debug("FreeDB: Disc could not be located in FreeDB."); MusicCD = null; } freedb.Disconnect(); } catch (System.Net.WebException webEx) { if (webEx.Status == WebExceptionStatus.Timeout) { log.Info("FreeDB: Timeout querying FreeDB. No Data returned for CD"); MusicCD = null; } else { log.Error("FreeDB: Exception querying Disc. {0} {1}", webEx.Message, webEx.StackTrace); MusicCD = null; } } catch (Exception ex) { log.Error("FreeDB: Exception querying Disc. {0} {1}", ex.Message, ex.StackTrace); MusicCD = null; } log.Info("Finished FreeDB Lookup"); _main.Cursor = Cursors.Default; if (MusicCD != null) { tbAlbumArtist.Text = MusicCD.Artist; tbAlbum.Text = MusicCD.Title; tbGenre.Text = MusicCD.Genre; tbYear.Text = MusicCD.Year.ToString(); foreach (CDTrackDetail trackDetail in MusicCD.Tracks) { if (trackDetail.Artist == null) trackDetail.Artist = MusicCD.Artist; bindingList[driveID].Add(trackDetail); } } else { int numTracks = BassCd.BASS_CD_GetTracks(driveID); for (int i = 0; i < numTracks; i++) { CDTrackDetail trackDetail = new CDTrackDetail(); trackDetail.Track = i + 1; trackDetail.Title = string.Format("Track{0}", (i + 1).ToString().PadLeft(2, '0')); bindingList[driveID].Add(trackDetail); } } CheckRows(true); (dataGridViewRip.Columns[0].HeaderCell as DatagridViewCheckBoxHeaderCell).Checked = true; SetStatusLabel(""); log.Trace("<<<"); }
public static string createXMCD(CDInfoDetail cdinfo) { string newline = "\n"; int index = 0; StringBuilder content = new StringBuilder(400); StringBuilder tracks = new StringBuilder(100); StringBuilder extt = new StringBuilder(100); content.Append("# xmcd"); content.Append(newline); content.Append("#"); content.Append(newline); // Track frame offsets content.Append("# Track frame offsets:"); foreach (CDTrackDetail track in cdinfo.Tracks) { content.Append(newline); content.Append("#\t"); content.Append(track.Offset); // do the other info about track too... // track title tracks.Append(newline); tracks.Append("TTITLE"); tracks.Append(index); tracks.Append("="); tracks.Append(track.Title); // track EXTT extt.Append(newline); extt.Append("EXTT"); extt.Append(index); extt.Append("="); extt.Append(track.EXTT); index++; } // Disc Length content.Append(newline); content.Append("#"); content.Append(newline); content.Append("# Disc length: "); content.Append(cdinfo.Duration); content.Append(" seconds"); // Revision content.Append(newline); content.Append("#"); content.Append(newline); content.Append("# Revision: 0"); // App information content.Append(newline); content.Append("# Submitted via: "); content.Append(APPNAME); content.Append(" "); content.Append(APPVERSION); content.Append(newline); content.Append("#"); content.Append(newline); // DISC ID content.Append("DISCID="); content.Append(cdinfo.DiscID); content.Append(newline); // Title = Artist / Title content.Append("DTITLE="); content.Append(cdinfo.Artist); content.Append(" / "); content.Append(cdinfo.Title); content.Append(newline); // Year content.Append("DYEAR="); content.Append(cdinfo.Year); content.Append(newline); // Genre content.Append("DGENRE="); content.Append(cdinfo.Genre); //track titles content.Append(tracks); // EXTD content.Append(newline); content.Append("EXTD="); content.Append(cdinfo.EXTD); // EXTT content.Append(extt); // EXTD content.Append(newline); content.Append("PLAYORDER="); int[] order = cdinfo.PlayOrder; for (int i = 0; i < order.Length; i++) { if (i != 0) { content.Append(','); } content.Append(order[i]); } content.Append(newline); return(content.ToString()); }