diff --git a/CUEControls/ImgComboBox.cs b/CUEControls/ImgComboBox.cs index aca2765..dcde0ed 100644 --- a/CUEControls/ImgComboBox.cs +++ b/CUEControls/ImgComboBox.cs @@ -156,6 +156,12 @@ namespace CUEControls AdjustControls(); } + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + Invalidate(true); + } + protected override void OnDrawItem(DrawItemEventArgs e) { if (_drawMode != DrawMode.Normal) @@ -250,7 +256,7 @@ namespace CUEControls LinearGradientMode.Vertical); Brush brBackground; if (this.DropDownStyle == ComboBoxStyle.DropDownList) - brBackground = new LinearGradientBrush(pathInnerBorder.GetBounds(), BackColor, hovered ? Color.FromArgb(100, SystemColors.HotTrack) : foreColor, LinearGradientMode.Vertical); + brBackground = new LinearGradientBrush(pathInnerBorder.GetBounds(), BackColor, (hovered || Focused)? Color.FromArgb(100, SystemColors.HotTrack) : foreColor, LinearGradientMode.Vertical); else brBackground = new SolidBrush(BackColor); Pen penInnerBorder = new Pen(brInnerBrush, 0); diff --git a/CUERipper/CUERipper.csproj b/CUERipper/CUERipper.csproj index be5e95a..be1e8bd 100644 --- a/CUERipper/CUERipper.csproj +++ b/CUERipper/CUERipper.csproj @@ -79,6 +79,12 @@ frmCUERipper.cs + + Form + + + frmFreedbSubmit.cs + @@ -91,6 +97,9 @@ frmCUERipper.cs + + frmFreedbSubmit.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -224,6 +233,8 @@ + + diff --git a/CUERipper/Properties/Resources.Designer.cs b/CUERipper/Properties/Resources.Designer.cs index 4cd15f1..e1af87d 100644 --- a/CUERipper/Properties/Resources.Designer.cs +++ b/CUERipper/Properties/Resources.Designer.cs @@ -177,6 +177,13 @@ namespace CUERipper.Properties { } } + internal static System.Drawing.Bitmap freedb16 { + get { + object obj = ResourceManager.GetObject("freedb16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + internal static System.Drawing.Icon ipod_sound { get { object obj = ResourceManager.GetObject("ipod_sound", resourceCulture); diff --git a/CUERipper/Properties/Resources.resx b/CUERipper/Properties/Resources.resx index 540a625..f9fee35 100644 --- a/CUERipper/Properties/Resources.resx +++ b/CUERipper/Properties/Resources.resx @@ -123,15 +123,18 @@ Looking up album via - - No CD drives found - - - Failed to load ripper module - - - ..\Resources\flac.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ipod_sound.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\wave.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\tta.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Paused Rip probably contains errors @@ -139,11 +142,11 @@ ..\musicbrainz.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Done ripping + + ..\freedb.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - You can try to repair it using CUETools + + ..\arok.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\cdrepair.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -157,14 +160,11 @@ ..\Resources\ogg.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Detecting drives + + No CD drives found - - ..\Resources\ape.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\ipod_sound.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\tag-label.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\wv.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -172,37 +172,40 @@ ..\Resources\accuraterip_16.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\freedb.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\arrow-circle-double.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\spellcheck.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Paused + + ..\Resources\ape.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\mp3.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\arok.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\spellcheck.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\tta.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + You can try to repair it using CUETools - - ..\Resources\wave.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Done ripping - - ..\Resources\arrow-circle-double.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Detecting drives + + + Failed to load ripper module + + + ..\Resources\flac.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a retry - - ..\Resources\tag-label.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\edit-list-order.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\freedb16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/CUERipper/frmCUERipper.Designer.cs b/CUERipper/frmCUERipper.Designer.cs index a5fddae..0601a34 100644 --- a/CUERipper/frmCUERipper.Designer.cs +++ b/CUERipper/frmCUERipper.Designer.cs @@ -47,6 +47,7 @@ namespace CUERipper this.listTracks = new System.Windows.Forms.ListView(); this.Title = new System.Windows.Forms.ColumnHeader(); this.TrackNo = new System.Windows.Forms.ColumnHeader(); + this.columnHeaderArtist = new System.Windows.Forms.ColumnHeader(); this.Start = new System.Windows.Forms.ColumnHeader(); this.Length = new System.Windows.Forms.ColumnHeader(); this.buttonGo = new System.Windows.Forms.Button(); @@ -97,6 +98,7 @@ namespace CUERipper this.buttonReload = new System.Windows.Forms.Button(); this.buttonEncoding = new System.Windows.Forms.Button(); this.buttonTracks = new System.Windows.Forms.Button(); + this.buttonFreedbSubmit = new System.Windows.Forms.Button(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericWriteOffset)).BeginInit(); this.groupBoxSettings.SuspendLayout(); @@ -183,6 +185,7 @@ namespace CUERipper this.listTracks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.Title, this.TrackNo, + this.columnHeaderArtist, this.Start, this.Length}); this.listTracks.FullRowSelect = true; @@ -193,10 +196,10 @@ namespace CUERipper this.listTracks.UseCompatibleStateImageBehavior = false; this.listTracks.View = System.Windows.Forms.View.Details; this.listTracks.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listTracks_AfterLabelEdit); - this.listTracks.DoubleClick += new System.EventHandler(this.listTracks_DoubleClick); this.listTracks.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.listTracks_PreviewKeyDown); this.listTracks.BeforeLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listTracks_BeforeLabelEdit); this.listTracks.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listTracks_KeyDown); + this.listTracks.Click += new System.EventHandler(this.listTracks_Click); // // Title // @@ -206,6 +209,10 @@ namespace CUERipper // resources.ApplyResources(this.TrackNo, "TrackNo"); // + // columnHeaderArtist + // + resources.ApplyResources(this.columnHeaderArtist, "columnHeaderArtist"); + // // Start // resources.ApplyResources(this.Start, "Start"); @@ -444,6 +451,7 @@ namespace CUERipper this.progressBarErrors.ProgressPainter = this.plainProgressPainter1; this.progressBarErrors.ProgressType = ProgressODoom.ProgressType.Smooth; this.progressBarErrors.ShowPercentage = false; + this.progressBarErrors.TabStop = false; this.progressBarErrors.Value = 10; // // plainBackgroundPainter1 @@ -487,6 +495,7 @@ namespace CUERipper this.progressBarCD.ProgressPainter = this.plainProgressPainter2; this.progressBarCD.ProgressType = ProgressODoom.ProgressType.Smooth; this.progressBarCD.ShowPercentage = true; + this.progressBarCD.TabStop = false; this.progressBarCD.Value = 10; // // plainProgressPainter2 @@ -560,7 +569,7 @@ namespace CUERipper // // bnComboBoxOutputFormat // - this.bnComboBoxOutputFormat.BackColor = System.Drawing.Color.Transparent; + this.bnComboBoxOutputFormat.BackColor = System.Drawing.SystemColors.Window; this.bnComboBoxOutputFormat.ForeColor = System.Drawing.SystemColors.ControlText; this.bnComboBoxOutputFormat.ImageList = null; resources.ApplyResources(this.bnComboBoxOutputFormat, "bnComboBoxOutputFormat"); @@ -571,6 +580,7 @@ namespace CUERipper rectRadius7.TopLeft = 2; rectRadius7.TopRight = 6; this.bnComboBoxOutputFormat.Radius = rectRadius7; + this.bnComboBoxOutputFormat.TabStop = false; this.bnComboBoxOutputFormat.Leave += new System.EventHandler(this.bnComboBoxOutputFormat_Leave); this.bnComboBoxOutputFormat.MouseLeave += new System.EventHandler(this.bnComboBoxOutputFormat_MouseLeave); this.bnComboBoxOutputFormat.DropDown += new System.EventHandler(this.bnComboBoxOutputFormat_DroppedDown); @@ -590,6 +600,7 @@ namespace CUERipper this.listMetadata.UseCompatibleStateImageBehavior = false; this.listMetadata.View = System.Windows.Forms.View.Details; this.listMetadata.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listMetadata_AfterLabelEdit); + this.listMetadata.BeforeLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listMetadata_BeforeLabelEdit); this.listMetadata.Click += new System.EventHandler(this.listMetadata_Click); // // columnHeaderValue @@ -652,10 +663,19 @@ namespace CUERipper this.buttonTracks.UseVisualStyleBackColor = true; this.buttonTracks.Click += new System.EventHandler(this.buttonTracks_Click); // + // buttonFreedbSubmit + // + this.buttonFreedbSubmit.Image = global::CUERipper.Properties.Resources.freedb16; + resources.ApplyResources(this.buttonFreedbSubmit, "buttonFreedbSubmit"); + this.buttonFreedbSubmit.Name = "buttonFreedbSubmit"; + this.buttonFreedbSubmit.UseVisualStyleBackColor = true; + this.buttonFreedbSubmit.Click += new System.EventHandler(this.buttonFreedbSubmit_Click); + // // frmCUERipper // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.buttonFreedbSubmit); this.Controls.Add(this.buttonTracks); this.Controls.Add(this.buttonEncoding); this.Controls.Add(this.buttonMetadata); @@ -764,6 +784,8 @@ namespace CUERipper private System.Windows.Forms.Button buttonReload; private System.Windows.Forms.Button buttonEncoding; private System.Windows.Forms.Button buttonTracks; + private System.Windows.Forms.ColumnHeader columnHeaderArtist; + private System.Windows.Forms.Button buttonFreedbSubmit; } } diff --git a/CUERipper/frmCUERipper.cs b/CUERipper/frmCUERipper.cs index 9687fc3..8e26b3f 100644 --- a/CUERipper/frmCUERipper.cs +++ b/CUERipper/frmCUERipper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Specialized; using System.Collections.ObjectModel; using System.ComponentModel; using System.Data; @@ -312,8 +313,9 @@ namespace CUERipper buttonTracks.Enabled = data.selectedRelease != null && !running; buttonMetadata.Enabled = data.selectedRelease != null && !running; + buttonFreedbSubmit.Enabled = data.selectedRelease != null && !running; buttonVA.Enabled = data.selectedRelease != null && !running && - data.selectedRelease.ImageKey == "freedb" && !data.selectedRelease.metadata.IsVarious(); + data.selectedRelease.ImageKey == "freedb" && !data.selectedRelease.metadata.IsVarious() && (new CUEMetadata(data.selectedRelease.metadata)).FreedbToVarious(); buttonEncoding.Enabled = data.selectedRelease != null && !running && data.selectedRelease.ImageKey == "freedb" && (new CUEMetadata(data.selectedRelease.metadata)).FreedbToEncoding(); buttonReload.Enabled = data.selectedRelease != null && !running; @@ -517,21 +519,37 @@ namespace CUERipper listTracks.Visible = true; listMetadata.Visible = false; if (data.selectedRelease != null) + { + bool various = data.selectedRelease.metadata.IsVarious(); + if (various) + { + Title.Width = 235; + columnHeaderArtist.Width = 120; + } + else + { + Title.Width = 235 + 120; + columnHeaderArtist.Width = 0; + } for (int i = 1; i <= selectedDriveInfo.drive.TOC.TrackCount; i++) { - string title; - if (!selectedDriveInfo.drive.TOC[i].IsAudio) - title = "Data track"; - else + string title = "Data track"; + string artist = ""; + if (selectedDriveInfo.drive.TOC[i].IsAudio) + { title = data.selectedRelease.metadata.Tracks[i - selectedDriveInfo.drive.TOC.FirstAudio].Title; + artist = data.selectedRelease.metadata.Tracks[i - selectedDriveInfo.drive.TOC.FirstAudio].Artist; + } listTracks.Items.Add(new ListViewItem(new string[] { - title, - selectedDriveInfo.drive.TOC[i].Number.ToString(), - selectedDriveInfo.drive.TOC[i].StartMSF, - selectedDriveInfo.drive.TOC[i].LengthMSF })); + title, + selectedDriveInfo.drive.TOC[i].Number.ToString(), + artist, + selectedDriveInfo.drive.TOC[i].StartMSF, + selectedDriveInfo.drive.TOC[i].LengthMSF })); } + } } - else //if (data.selectedTrack.no == 0) + else if (data.metadataTrack < 0) { listTracks.Visible = false; listMetadata.Visible = true; @@ -544,20 +562,27 @@ namespace CUERipper listMetadata.Items.Add(new ListViewItem(new string[] { p.GetValue(data.selectedRelease.metadata).ToString(), p.Name })); } } - //else - //{ - // listTracks.Visible = false; - // listMetadata.Visible = true; - // if (data.selectedRelease != null) - // { - // CUETrackMetadata track = data.selectedRelease.metadata.Tracks[data.selectedTrack.no - 1]; - // PropertyDescriptorCollection props = TypeDescriptor.GetProperties(track); - // //props = props.Sort(new string[] { "TopLeft", "TopRight", "BottomLeft", "BottomRight" }); - // foreach (PropertyDescriptor p in props) - // if (p.Name != "ISRC") - // listMetadata.Items.Add(new ListViewItem(new string[] { p.GetValue(track).ToString(), p.Name })); - // } - //} + else + { + listTracks.Visible = false; + listMetadata.Visible = true; + if (data.selectedRelease != null) + { + CUETrackMetadata track = data.selectedRelease.metadata.Tracks[data.metadataTrack]; + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(track); + props = props.Sort(new string[] { "ISRC", "Title", "Artist" }); + ListViewItem lvItem = new ListViewItem(new string[] { (data.metadataTrack + 1).ToString(), "Number" }); + lvItem.ForeColor = SystemColors.GrayText; + listMetadata.Items.Add(lvItem); + foreach (PropertyDescriptor p in props) + { + lvItem = new ListViewItem(new string[] { p.GetValue(track).ToString(), p.Name }); + if (p.Name == "ISRC") + lvItem.ForeColor = SystemColors.GrayText; + listMetadata.Items.Add(lvItem); + } + } + } listTracks.EndUpdate(); listMetadata.EndUpdate(); SetupControls(); @@ -645,6 +670,7 @@ namespace CUERipper ReleaseQueryParameters p = new ReleaseQueryParameters(); p.DiscId = audioSource.TOC.MusicBrainzId; Query results = Release.Query(p); + MusicBrainzService.Proxy = _config.GetProxy(); MusicBrainzService.XmlRequest += new EventHandler(MusicBrainz_LookupProgress); try @@ -663,13 +689,14 @@ namespace CUERipper if (!(ex is MusicBrainzNotFoundException)) musicbrainzError = ex.Message; } + MusicBrainzService.Proxy = null; MusicBrainzService.XmlRequest -= new EventHandler(MusicBrainz_LookupProgress); FreedbHelper m_freedb = new FreedbHelper(); - - m_freedb.UserName = "gchudov"; - m_freedb.Hostname = "gmail.com"; + m_freedb.Proxy = _config.GetProxy(); + m_freedb.UserName = _config.advanced.FreedbUser; + m_freedb.Hostname = _config.advanced.FreedbDomain; m_freedb.ClientName = "CUERipper"; m_freedb.Version = "2.0.8"; m_freedb.SetDefaultSiteAddress(Properties.Settings.Default.MAIN_FREEDB_SITEADDRESS); @@ -803,11 +830,6 @@ namespace CUERipper _workThread.Start(selectedDriveInfo.drive); } - private void listTracks_DoubleClick(object sender, EventArgs e) - { - listTracks.FocusedItem.BeginEdit(); - } - private void listTracks_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F2) @@ -1110,11 +1132,11 @@ namespace CUERipper { if (outputFormatVisible) return; + txtOutputPath.Enabled = false; + txtOutputPath.Visible = false; outputFormatVisible = true; bnComboBoxOutputFormat.Visible = true; bnComboBoxOutputFormat.Focus(); - txtOutputPath.Enabled = false; - txtOutputPath.Visible = false; } private void bnComboBoxOutputFormat_MouseLeave(object sender, EventArgs e) @@ -1129,7 +1151,7 @@ namespace CUERipper private void bnComboBoxOutputFormat_DroppedDown(object sender, EventArgs e) { - if (!outputFormatVisible || bnComboBoxOutputFormat.DroppedDown || bnComboBoxOutputFormat.Focused) + if (!outputFormatVisible || bnComboBoxOutputFormat.DroppedDown || ActiveControl == bnComboBoxOutputFormat) return; outputFormatVisible = false; bnComboBoxOutputFormat.Visible = false; @@ -1147,13 +1169,32 @@ namespace CUERipper listMetadata.FocusedItem.BeginEdit(); } + private void listMetadata_BeforeLabelEdit(object sender, LabelEditEventArgs e) + { + if (data.selectedRelease == null || !data.metadataMode) + { + e.CancelEdit = true; + } + else if (data.metadataTrack < 0) + { + } + else + { + if (listMetadata.Items[e.Item].SubItems[1].Text == "ISRC" || + listMetadata.Items[e.Item].SubItems[1].Text == "Number") + { + e.CancelEdit = true; + } + } + } + private void listMetadata_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (data.selectedRelease == null || e.Label == null || !data.metadataMode) { e.CancelEdit = true; } - else + else if (data.metadataTrack < 0) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data.selectedRelease.metadata); PropertyDescriptor prop = props[listMetadata.Items[e.Item].SubItems[1].Text]; @@ -1163,13 +1204,13 @@ namespace CUERipper prop.SetValue(data.selectedRelease.metadata, e.Label); data.Releases.ResetItem(bnComboBoxRelease.SelectedIndex); } - //else - //{ - // CUETrackMetadata track = data.selectedRelease.metadata.Tracks[data.selectedTrack.no - 1]; - // PropertyDescriptorCollection props = TypeDescriptor.GetProperties(track); - // props[listMetadata.Items[e.Item].SubItems[1].Text].SetValue(track, e.Label); - // data.Tracks.ResetItem(data.selectedTrack.no + 1); - //} + else + { + CUETrackMetadata track = data.selectedRelease.metadata.Tracks[data.metadataTrack]; + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(track); + props[listMetadata.Items[e.Item].SubItems[1].Text].SetValue(track, e.Label); + //data.Tracks.ResetItem(data.metadataTrack); + } } private void buttonMetadata_Click(object sender, EventArgs e) @@ -1177,6 +1218,7 @@ namespace CUERipper buttonTracks.Visible = true; buttonTracks.Focus(); buttonMetadata.Visible = false; + data.metadataTrack = -1; data.metadataMode = true; UpdateRelease(); } @@ -1221,6 +1263,118 @@ namespace CUERipper comboBoxOutputFormat_TextUpdate(sender, e); SetupControls(); } + + private void listTracks_Click(object sender, EventArgs e) + { + Point p = listTracks.PointToClient(MousePosition); + ListViewItem lvItem = listTracks.GetItemAt(p.X, p.Y); + if (lvItem != null) + { + ListViewItem.ListViewSubItem a = lvItem.GetSubItemAt(p.X, p.Y); + if (a != null) + { + int track = lvItem.Index + 1 - selectedDriveInfo.drive.TOC.FirstAudio; + if (a == lvItem.SubItems[0]) + lvItem.BeginEdit(); + else if (/*a == lvItem.SubItems[2] &&*/ track >= 0) + { + buttonTracks.Visible = true; + buttonTracks.Focus(); + buttonMetadata.Visible = false; + data.metadataTrack = track; + data.metadataMode = true; + UpdateRelease(); + } + } + } + } + + private void FreedbSubmit(object o) + { + StringCollection tmp = new StringCollection(); + tmp.Add("DTITLE="); + CDEntry entry = new CDEntry(tmp); + entry.Artist = data.selectedRelease.metadata.Artist; + entry.Title = data.selectedRelease.metadata.Title; + entry.Year = data.selectedRelease.metadata.Year; + entry.Genre = data.selectedRelease.metadata.Genre; + int i = 1; + foreach (CUETrackMetadata t in data.selectedRelease.metadata.Tracks) + { + Freedb.Track tt = new Freedb.Track(); + if (t.Artist != "" && t.Artist != entry.Artist) + tt.Title = t.Artist + " / " + t.Title; + else + tt.Title = t.Title; + tt.FrameOffset = 150 + (int)selectedDriveInfo.drive.TOC[i++].Start; + entry.Tracks.Add(tt); + } + + FreedbHelper m_freedb = new FreedbHelper(); + + frmFreedbSubmit frm = new frmFreedbSubmit(); + foreach (string c in m_freedb.ValidCategories) + frm.Data.Categories.Add(c); + frm.Data.User = _config.advanced.FreedbUser; + frm.Data.Domain = _config.advanced.FreedbDomain; + frm.Data.Category = "misc"; + + DialogResult dlgRes = DialogResult.Cancel; + this.Invoke((MethodInvoker)delegate() { dlgRes = frm.ShowDialog(); }); + if (dlgRes == DialogResult.Cancel) + { + _workThread = null; + this.BeginInvoke((MethodInvoker)delegate() { SetupControls(); }); + return; + } + + data.selectedRelease.metadata.Save(); + + _config.advanced.FreedbUser = frm.Data.User; + _config.advanced.FreedbDomain = frm.Data.Domain; + + m_freedb.Proxy = _config.GetProxy(); + m_freedb.UserName = _config.advanced.FreedbUser; + m_freedb.Hostname = _config.advanced.FreedbDomain; + m_freedb.ClientName = "CUERipper"; + m_freedb.Version = "2.0.8"; + //try + //{ + // string code = m_freedb.GetCategories(out tmp); + // if (code == FreedbHelper.ResponseCodes.CODE_210) + // m_freedb.ValidCategories = tmp; + //} + //catch + //{ + //} + uint length = selectedDriveInfo.drive.TOC.Length / 75 - selectedDriveInfo.drive.TOC[1].Start / 75 + 2; + try + { + string res = m_freedb.Submit(entry, (int)length, AccurateRipVerify.CalculateCDDBId(selectedDriveInfo.drive.TOC), frm.Data.Category, false); + this.BeginInvoke((MethodInvoker)delegate() + { + dlgRes = MessageBox.Show(this, res, "Submit result", MessageBoxButtons.OK, MessageBoxIcon.Information); + }); + } + catch (Exception ex) + { + this.BeginInvoke((MethodInvoker)delegate() + { + dlgRes = MessageBox.Show(this, ex.Message, "Submit result", MessageBoxButtons.OK, MessageBoxIcon.Error); + }); + } + _workThread = null; + this.BeginInvoke((MethodInvoker)delegate() { SetupControls(); }); + } + + private void buttonFreedbSubmit_Click(object sender, EventArgs e) + { + _workThread = new Thread(FreedbSubmit); + _workThread.Priority = ThreadPriority.BelowNormal; + _workThread.IsBackground = true; + SetupControls(); + _workThread.Start(); + } } public class StartStop @@ -1348,6 +1502,7 @@ namespace CUERipper public CUEMetadataEntry selectedRelease { get; set; } public bool metadataMode { get; set; } + public int metadataTrack { get; set; } public BindingList CUEStyles { diff --git a/CUERipper/frmCUERipper.resx b/CUERipper/frmCUERipper.resx index 47f15e4..31fc72a 100644 --- a/CUERipper/frmCUERipper.resx +++ b/CUERipper/frmCUERipper.resx @@ -197,7 +197,7 @@ $this - 15 + 16 @@ -210,7 +210,7 @@ Title - 355 + 235 0 @@ -221,6 +221,12 @@ 30 + + Artist + + + 120 + Start @@ -240,7 +246,7 @@ 553, 221 - 2 + 7 357, 17 @@ -258,7 +264,7 @@ $this - 13 + 14 Top, Left, Right @@ -273,7 +279,7 @@ 177, 33 - 13 + 12 Go @@ -288,7 +294,7 @@ $this - 14 + 15 Top, Left, Right @@ -303,7 +309,7 @@ 85, 33 - 19 + 13 Abort @@ -321,7 +327,7 @@ $this - 16 + 17 Top, Left, Right @@ -354,7 +360,7 @@ $this - 17 + 18 310, 15 @@ -363,7 +369,7 @@ 54, 20 - 7 + 5 Right @@ -423,7 +429,7 @@ 64, 17 - 3 + 6 EAC log @@ -453,7 +459,7 @@ 80, 21 - 39 + 0 lossless @@ -480,7 +486,7 @@ 80, 21 - 38 + 3 libFlac @@ -534,7 +540,7 @@ 80, 21 - 37 + 2 flac @@ -600,7 +606,7 @@ 80, 21 - 34 + 1 image @@ -705,7 +711,7 @@ 166, 45 - 8 + 4 trackBarEncoderMode @@ -729,7 +735,7 @@ 127, 45 - 30 + 7 trackBarSecureMode @@ -750,7 +756,7 @@ 370, 134 - 29 + 11 groupBoxSettings @@ -762,7 +768,7 @@ $this - 12 + 13 998, 56 @@ -855,7 +861,7 @@ $this - 9 + 10 382, 392 @@ -882,7 +888,7 @@ $this - 11 + 12 6, 314 @@ -891,7 +897,7 @@ 552, 20 - 33 + 10 Click to edit output path template @@ -906,7 +912,7 @@ $this - 7 + 8 708, 56 @@ -990,7 +996,7 @@ 552, 21 - 35 + 1 Releases @@ -1005,11 +1011,8 @@ $this - 6 + 7 - - 116, 469 - 6, 6 @@ -1017,7 +1020,7 @@ 552, 21 - 36 + 0 Drives @@ -1032,7 +1035,7 @@ $this - 8 + 9 5, 313 @@ -1041,7 +1044,7 @@ 552, 21 - 37 + 9 bnComboBoxOutputFormat @@ -1053,7 +1056,7 @@ $this - 10 + 11 1 @@ -1080,7 +1083,7 @@ 550, 220 - 39 + 8 False @@ -1095,7 +1098,7 @@ $this - 18 + 19 Flat @@ -1128,7 +1131,7 @@ $this - 4 + 5 7, 60 @@ -1137,7 +1140,7 @@ 80, 23 - 41 + 3 Meta @@ -1155,7 +1158,7 @@ $this - 2 + 3 NoControl @@ -1167,7 +1170,7 @@ 80, 23 - 42 + 5 V/A @@ -1185,7 +1188,7 @@ $this - 5 + 6 NoControl @@ -1197,7 +1200,7 @@ 80, 23 - 43 + 4 Reload @@ -1215,7 +1218,7 @@ $this - 3 + 4 NoControl @@ -1227,7 +1230,7 @@ 80, 23 - 44 + 6 Codepage @@ -1245,7 +1248,7 @@ $this - 1 + 2 NoControl @@ -1257,7 +1260,7 @@ 80, 23 - 45 + 3 Tracks @@ -1278,14 +1281,44 @@ $this + 1 + + + NoControl + + + 357, 60 + + + 80, 23 + + + 41 + + + Submit + + + ImageBeforeText + + + buttonFreedbSubmit + + + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 - - 50 - True + + 50 + 6, 13 @@ -1743,6 +1776,12 @@ System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + columnHeaderArtist + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Start @@ -1851,12 +1890,6 @@ System.Windows.Forms.ImageList, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - tracksBindingSource - - - System.Windows.Forms.BindingSource, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - columnHeaderValue diff --git a/CUETools.AccurateRip/AccurateRip.cs b/CUETools.AccurateRip/AccurateRip.cs index 92ac657..220adce 100644 --- a/CUETools.AccurateRip/AccurateRip.cs +++ b/CUETools.AccurateRip/AccurateRip.cs @@ -15,17 +15,10 @@ namespace CUETools.AccurateRip public AccurateRipVerify(CDImageLayout toc, IWebProxy proxy) { this.proxy = proxy; - _toc = toc; _accDisks = new List(); - //_crc32 = new Crc32(); _hasLogCRC = false; - _finalSampleCount = _toc.AudioLength * 588; - _CRCLOG = new uint[_toc.AudioTracks + 1]; - _CRCMASK = new uint[_toc.AudioTracks + 1]; - _CRCMASK[0] = 0xffffffff ^ Crc32.Combine(0xffffffff, 0, (int)_finalSampleCount * 4); - for (int iTrack = 1; iTrack <= _toc.AudioTracks; iTrack++) - _CRCMASK[iTrack] = 0xffffffff ^ Crc32.Combine(0xffffffff, 0, (int)_toc[iTrack + _toc.FirstAudio - 1].Length * 588 * 4); - Init(); + _CRCLOG = new uint[toc.AudioTracks + 1]; + Init(toc); } public uint Confidence(int iTrack) @@ -336,7 +329,7 @@ namespace CUETools.AccurateRip this.npar = npar; this.calcSyn = calcSyn; this.calcParity = calcParity; - Init(); + Init(_toc); } internal unsafe uint CTDBCRC(int actualOffset) @@ -648,8 +641,14 @@ namespace CUETools.AccurateRip } } - public void Init() + public void Init(CDImageLayout toc) { + _toc = toc; + _finalSampleCount = _toc.AudioLength * 588; + _CRCMASK = new uint[_toc.AudioTracks + 1]; + _CRCMASK[0] = 0xffffffff ^ Crc32.Combine(0xffffffff, 0, (int)_finalSampleCount * 4); + for (int iTrack = 1; iTrack <= _toc.AudioTracks; iTrack++) + _CRCMASK[iTrack] = 0xffffffff ^ Crc32.Combine(0xffffffff, 0, (int)_toc[iTrack + _toc.FirstAudio - 1].Length * 588 * 4); _CRCAR = new uint[_toc.AudioTracks + 1, 31 * 588]; _CRCSM = new uint[_toc.AudioTracks + 1, 31 * 588]; _CRC32 = new uint[_toc.AudioTracks + 1, 31 * 588]; diff --git a/CUETools.Codecs.FLAKE/CUETools.Codecs.FLAKE.csproj b/CUETools.Codecs.FLAKE/CUETools.Codecs.FLAKE.csproj index 2b1d9be..ab048e4 100644 --- a/CUETools.Codecs.FLAKE/CUETools.Codecs.FLAKE.csproj +++ b/CUETools.Codecs.FLAKE/CUETools.Codecs.FLAKE.csproj @@ -2,7 +2,7 @@ Debug AnyCPU - 8.0.50727 + 9.0.30729 2.0 {082D6B9E-326E-4D15-9798-EDAE9EDE70A6} Library @@ -19,7 +19,7 @@ true full false - bin\Debug\ + ..\bin\Debug\plugins\ DEBUG;TRACE prompt 4 diff --git a/CUETools.Codecs.FlaCuda/CUETools.Codecs.FlaCuda.csproj b/CUETools.Codecs.FlaCuda/CUETools.Codecs.FlaCuda.csproj index dfb203e..62199c0 100644 --- a/CUETools.Codecs.FlaCuda/CUETools.Codecs.FlaCuda.csproj +++ b/CUETools.Codecs.FlaCuda/CUETools.Codecs.FlaCuda.csproj @@ -2,7 +2,7 @@ Debug AnyCPU - 8.0.50727 + 9.0.30729 2.0 {DFE50673-906C-4B8F-993B-A24CAD1CA17D} Library @@ -19,7 +19,7 @@ true full false - bin\Debug\ + ..\bin\Debug\plugins\ DEBUG;TRACE prompt 4 diff --git a/CUETools.Codecs.HDCD/CUETools.Codecs.HDCD.csproj b/CUETools.Codecs.HDCD/CUETools.Codecs.HDCD.csproj index fee586e..ab62f88 100644 --- a/CUETools.Codecs.HDCD/CUETools.Codecs.HDCD.csproj +++ b/CUETools.Codecs.HDCD/CUETools.Codecs.HDCD.csproj @@ -19,7 +19,7 @@ true full false - bin\Debug\ + ..\bin\Debug\plugins\ DEBUG;TRACE prompt 4 diff --git a/CUETools.Processor/AudioReadWrite.cs b/CUETools.Processor/AudioReadWrite.cs index c7744bc..1985341 100644 --- a/CUETools.Processor/AudioReadWrite.cs +++ b/CUETools.Processor/AudioReadWrite.cs @@ -111,8 +111,8 @@ namespace CUETools.Processor break; case "CUETools.Codecs.FlaCuda.FlaCudaWriter": dest.Options = string.Format("{0}{1}--padding-length {2} --cpu-threads {3}", - config.flaCudaVerify ? "--verify " : "", - config.flaCudaGPUOnly ? "--gpu-only " : "", + config.FlaCudaVerify ? "--verify " : "", + config.FlaCudaGPUOnly ? "--gpu-only " : "", padding, config.FlaCudaThreads ? 1 : 0); break; diff --git a/CUETools.Processor/CUEMetadata.cs b/CUETools.Processor/CUEMetadata.cs index b390ff2..66c7f19 100644 --- a/CUETools.Processor/CUEMetadata.cs +++ b/CUETools.Processor/CUEMetadata.cs @@ -82,6 +82,53 @@ namespace CUETools.Processor return serializer.Deserialize(fs) as CUEMetadata; } + public void Merge(CUEMetadata metadata, bool overwrite) + { + if ((overwrite || TotalDiscs == "") && metadata.TotalDiscs != "") TotalDiscs = metadata.TotalDiscs; + if ((overwrite || DiscNumber == "") && metadata.DiscNumber != "") DiscNumber = metadata.DiscNumber; + if ((overwrite || Year == "") && metadata.Year != "") Year = metadata.Year; + if ((overwrite || Genre == "") && metadata.Genre != "") Genre = metadata.Genre; + if ((overwrite || Artist == "") && metadata.Artist != "") Artist = metadata.Artist; + if ((overwrite || Title == "") && metadata.Title != "") Title = metadata.Title; + if ((overwrite || Catalog == "") && metadata.Catalog != "") Catalog = metadata.Catalog; + for (int i = 0; i < Tracks.Count; i++) + { + if ((overwrite || Tracks[i].Title == "") && metadata.Tracks[i].Title != "") Tracks[i].Title = metadata.Tracks[i].Title; + if ((overwrite || Tracks[i].Artist == "") && metadata.Tracks[i].Artist != "") Tracks[i].Artist = metadata.Tracks[i].Artist; + if ((overwrite || Tracks[i].ISRC == "") && metadata.Tracks[i].ISRC != "") Tracks[i].ISRC = metadata.Tracks[i].ISRC; + } + } + + public override bool Equals(object obj) + { + CUEMetadata metadata = obj as CUEMetadata; + if (metadata == null) + return false; + if (TotalDiscs != metadata.TotalDiscs || + DiscNumber != metadata.DiscNumber || + Year != metadata.Year || + Genre != metadata.Genre || + Artist != metadata.Artist || + Title != metadata.Title || + Catalog != metadata.Catalog || + Tracks.Count != metadata.Tracks.Count + ) + return false; + for (int i = 0; i < Tracks.Count; i++) + if (Tracks[i].Title != metadata.Tracks[i].Title || + Tracks[i].Artist != metadata.Tracks[i].Artist || + Tracks[i].ISRC != metadata.Tracks[i].ISRC) + return false; + return true; + } + + public bool Contains(CUEMetadata metadata) + { + CUEMetadata sum = new CUEMetadata(metadata); + sum.Merge(this, false); + return sum.Equals(this); + } + public void CopyMetadata(CUEMetadata metadata) { // if (metadata.Tracks.Count != Tracks.Count) throw; @@ -161,8 +208,9 @@ namespace CUETools.Processor return different && !error; } - public void FreedbToVarious() + public bool FreedbToVarious() { + bool found = false; for (int i = 0; i < Tracks.Count; i++) { string title = Tracks[i].Title; @@ -172,12 +220,14 @@ namespace CUETools.Processor { Tracks[i].Title = title.Substring(idx + 3); Tracks[i].Artist = title.Substring(0, idx); + found = true; } else { Tracks[i].Artist = title; } } + return found; } public void UpdateArtist(string artist) diff --git a/CUETools.Processor/Processor.cs b/CUETools.Processor/Processor.cs index e873179..f73b96e 100644 --- a/CUETools.Processor/Processor.cs +++ b/CUETools.Processor/Processor.cs @@ -38,6 +38,7 @@ using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Reflection; using System.Runtime.InteropServices; +using System.Xml.Serialization; using CUETools.Codecs; using CUETools.CDImage; using CUETools.AccurateRip; @@ -873,6 +874,65 @@ namespace CUETools.Processor } } + //class LocalizedDisplayNameAttribute : DisplayNameAttribute + //{ + // private readonly string resourceName; + // public LocalizedDisplayNameAttribute(string resourceName) + // : base() + // { + // this.resourceName = resourceName; + // } + + // public override string DisplayName + // { + // get + // { + // return Resources.ResourceManager.GetString(this.resourceName); + // } + // } + //} + + [Serializable] + public class CUEConfigAdvanced + { + public CUEConfigAdvanced() + { + // Iterate through each property and call ResetValue() + foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) + property.ResetValue(this); + } + internal static XmlSerializer serializer = new XmlSerializer(typeof(CUEConfigAdvanced)); + [DefaultValue("i"),Category("Freedb"),DisplayName("Email user")] + public string FreedbUser { get; set; } + [DefaultValue("wont.tell"), Category("Freedb"), DisplayName("Email domain")] + public string FreedbDomain { get; set; } + [DefaultValue(ProxyMode.System), Category("Proxy"), DisplayName("Proxy mode")] + public ProxyMode UseProxyMode { get; set; } + [DefaultValue("127.0.0.1"), Category("Proxy"), DisplayName("Proxy server host")] + public string ProxyServer { get; set; } + [DefaultValue(8080), Category("Proxy"), DisplayName("Proxy server port")] + public int ProxyPort { get; set; } + [DefaultValue(""), Category("Proxy"), DisplayName("Proxy auth user")] + public string ProxyUser { get; set; } + [DefaultValue(""), Category("Proxy"), DisplayName("Proxy auth password")] + public string ProxyPassword { get; set; } + [DefaultValue(true), Category("Cache"), DisplayName("Cache metadata")] + public bool CacheMetadata { get; set; } + [DefaultValue(new string[]{"folder.jpg", "cover.jpg", "albumart.jpg", "thumbnail.jpg", "albumartlarge.jpg", "front.jpg"})] + [Category("Cover Art"), DisplayName("Cover Art Files")] + public string[] CoverArtFiles { get; set; } + [DefaultValue(true)] + [Category("Cover Art"), DisplayName("Cover Art Extended Search")] + public bool CoverArtSearchSubdirs { get; set; } + + public enum ProxyMode + { + None, + System, + Custom + } + } + public class CUEConfig { public uint fixOffsetMinimumConfidence; public uint fixOffsetMinimumTracksPercent; @@ -887,9 +947,6 @@ namespace CUETools.Processor public bool noUnverifiedOutput; public bool autoCorrectFilenames; public bool flacVerify; - public bool flaCudaVerify; - public bool flaCudaGPUOnly; - public bool flaCudaThreads; public bool preserveHTOA; public int wvExtraMode; public bool wvStoreMD5; @@ -929,24 +986,22 @@ namespace CUETools.Processor public bool writeBasicTagsFromCUEData; public bool copyBasicTags; public bool copyUnknownTags; - public bool copyAlbumArt; public bool embedAlbumArt; public bool extractAlbumArt; public bool arLogToSourceFolder; public bool arLogVerbose; public bool fixOffsetToNearest; public int maxAlbumArtSize; - public string arLogFilenameFormat, alArtFilenameFormat; public CUEStyle gapsHandling; public bool separateDecodingThread; - public bool useSystemProxySettings; - public bool CopyAlbumArt { get { return copyAlbumArt; } set { copyAlbumArt = value; } } - public bool FlaCudaThreads { get { return flaCudaThreads; } set { flaCudaThreads = value; } } - public bool FlaCudaGPUOnly { get { return flaCudaGPUOnly; } set { flaCudaGPUOnly = value; } } - public bool FlaCudaVerify { get { return flaCudaVerify; } set { flaCudaVerify = value; } } - public string ArLogFilenameFormat { get { return arLogFilenameFormat; } set { arLogFilenameFormat = value; } } - public string AlArtFilenameFormat { get { return alArtFilenameFormat; } set { alArtFilenameFormat = value; } } + public CUEConfigAdvanced advanced { get; private set; } + public bool CopyAlbumArt { get; set; } + public bool FlaCudaThreads { get; set; } + public bool FlaCudaGPUOnly { get; set; } + public bool FlaCudaVerify { get; set; } + public string ArLogFilenameFormat { get; set; } + public string AlArtFilenameFormat { get; set; } public CUEToolsUDCList Encoders { get { return encoders; } @@ -968,9 +1023,9 @@ namespace CUETools.Processor autoCorrectFilenames = true; flacVerify = false; - flaCudaVerify = false; - flaCudaGPUOnly = false; - flaCudaThreads = true; + FlaCudaVerify = false; + FlaCudaGPUOnly = false; + FlaCudaThreads = true; preserveHTOA = true; wvExtraMode = 0; wvStoreMD5 = false; @@ -1005,7 +1060,7 @@ namespace CUETools.Processor writeBasicTagsFromCUEData = true; copyBasicTags = true; copyUnknownTags = true; - copyAlbumArt = true; + CopyAlbumArt = true; embedAlbumArt = true; extractAlbumArt = true; maxAlbumArtSize = 300; @@ -1013,14 +1068,15 @@ namespace CUETools.Processor arLogToSourceFolder = false; arLogVerbose = true; fixOffsetToNearest = true; - arLogFilenameFormat = "%filename%.accurip"; - alArtFilenameFormat = "folder.jpg"; + ArLogFilenameFormat = "%filename%.accurip"; + AlArtFilenameFormat = "folder.jpg"; separateDecodingThread = true; - useSystemProxySettings = true; gapsHandling = CUEStyle.GapsAppended; + advanced = new CUEConfigAdvanced(); + language = Thread.CurrentThread.CurrentUICulture.Name; encoders = new CUEToolsUDCList(); @@ -1151,9 +1207,9 @@ string status = processor.Go(); sw.Save("PreserveHTOA", preserveHTOA); sw.Save("AutoCorrectFilenames", autoCorrectFilenames); sw.Save("FLACVerify", flacVerify); - sw.Save("FlaCudaVerify", flaCudaVerify); - sw.Save("FlaCudaGPUOnly", flaCudaGPUOnly); - sw.Save("FlaCudaThreads", flaCudaThreads); + sw.Save("FlaCudaVerify", FlaCudaVerify); + sw.Save("FlaCudaGPUOnly", FlaCudaGPUOnly); + sw.Save("FlaCudaThreads", FlaCudaThreads); sw.Save("WVExtraMode", wvExtraMode); sw.Save("WVStoreMD5", wvStoreMD5); sw.Save("KeepOriginalFilenames", keepOriginalFilenames); @@ -1165,7 +1221,7 @@ string status = processor.Go(); sw.Save("EmbedLog", embedLog); sw.Save("ExtractLog", extractLog); sw.Save("FillUpCUE", fillUpCUE); - sw.Save("OverwriteCUEData", overwriteCUEData); + sw.Save("OverwriteCUEData", overwriteCUEData); sw.Save("FilenamesANSISafe", filenamesANSISafe); if (bruteForceDTL) sw.Save("BruteForceDTL", bruteForceDTL); sw.Save("CreateEACLOG", createEACLOG); @@ -1185,12 +1241,11 @@ string status = processor.Go(); sw.Save("Language", language); sw.Save("SeparateDecodingThread", separateDecodingThread); - sw.Save("UseSystemProxySettings", useSystemProxySettings); - + sw.Save("WriteBasicTagsFromCUEData", writeBasicTagsFromCUEData); sw.Save("CopyBasicTags", copyBasicTags); sw.Save("CopyUnknownTags", copyUnknownTags); - sw.Save("CopyAlbumArt", copyAlbumArt); + sw.Save("CopyAlbumArt", CopyAlbumArt); sw.Save("EmbedAlbumArt", embedAlbumArt); sw.Save("ExtractAlbumArt", extractAlbumArt); sw.Save("MaxAlbumArtSize", maxAlbumArtSize); @@ -1199,8 +1254,14 @@ string status = processor.Go(); sw.Save("ArLogVerbose", arLogVerbose); sw.Save("FixOffsetToNearest", fixOffsetToNearest); - sw.Save("ArLogFilenameFormat", arLogFilenameFormat); - sw.Save("AlArtFilenameFormat", alArtFilenameFormat); + sw.Save("ArLogFilenameFormat", ArLogFilenameFormat); + sw.Save("AlArtFilenameFormat", AlArtFilenameFormat); + + using (TextWriter writer = new StringWriter()) + { + CUEConfigAdvanced.serializer.Serialize(writer, advanced); //writer.Close(); + sw.SaveText("Advanced", writer.ToString()); + } int nEncoders = 0; foreach (CUEToolsUDC encoder in encoders) @@ -1284,9 +1345,9 @@ string status = processor.Go(); preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? true; autoCorrectFilenames = sr.LoadBoolean("AutoCorrectFilenames") ?? true; flacVerify = sr.LoadBoolean("FLACVerify") ?? false; - flaCudaVerify = sr.LoadBoolean("FlaCudaVerify") ?? false; - flaCudaGPUOnly = sr.LoadBoolean("FlaCudaGPUOnly") ?? false; - flaCudaThreads = sr.LoadBoolean("FlaCudaThreads") ?? true; + FlaCudaVerify = sr.LoadBoolean("FlaCudaVerify") ?? false; + FlaCudaGPUOnly = sr.LoadBoolean("FlaCudaGPUOnly") ?? false; + FlaCudaThreads = sr.LoadBoolean("FlaCudaThreads") ?? true; wvExtraMode = sr.LoadInt32("WVExtraMode", 0, 6) ?? 0; wvStoreMD5 = sr.LoadBoolean("WVStoreMD5") ?? false; keepOriginalFilenames = sr.LoadBoolean("KeepOriginalFilenames") ?? false; @@ -1320,7 +1381,7 @@ string status = processor.Go(); writeBasicTagsFromCUEData = sr.LoadBoolean("WriteBasicTagsFromCUEData") ?? true; copyBasicTags = sr.LoadBoolean("CopyBasicTags") ?? true; copyUnknownTags = sr.LoadBoolean("CopyUnknownTags") ?? true; - copyAlbumArt = sr.LoadBoolean("CopyAlbumArt") ?? true; + CopyAlbumArt = sr.LoadBoolean("CopyAlbumArt") ?? true; embedAlbumArt = sr.LoadBoolean("EmbedAlbumArt") ?? true; extractAlbumArt = sr.LoadBoolean("ExtractAlbumArt") ?? true; maxAlbumArtSize = sr.LoadInt32("MaxAlbumArtSize", 100, 10000) ?? maxAlbumArtSize; @@ -1328,11 +1389,20 @@ string status = processor.Go(); arLogToSourceFolder = sr.LoadBoolean("ArLogToSourceFolder") ?? arLogToSourceFolder; arLogVerbose = sr.LoadBoolean("ArLogVerbose") ?? arLogVerbose; fixOffsetToNearest = sr.LoadBoolean("FixOffsetToNearest") ?? fixOffsetToNearest; - arLogFilenameFormat = sr.Load("ArLogFilenameFormat") ?? arLogFilenameFormat; - alArtFilenameFormat = sr.Load("AlArtFilenameFormat") ?? alArtFilenameFormat; + ArLogFilenameFormat = sr.Load("ArLogFilenameFormat") ?? ArLogFilenameFormat; + AlArtFilenameFormat = sr.Load("AlArtFilenameFormat") ?? AlArtFilenameFormat; separateDecodingThread = sr.LoadBoolean("SeparateDecodingThread") ?? separateDecodingThread; - useSystemProxySettings = sr.LoadBoolean("UseSystemProxySettings") ?? useSystemProxySettings; + + try + { + using (TextReader reader = new StringReader(sr.Load("Advanced"))) + advanced = CUEConfigAdvanced.serializer.Deserialize(reader) as CUEConfigAdvanced; + } + catch (Exception ex) + { + System.Diagnostics.Trace.WriteLine(ex.Message); + } int totalEncoders = sr.LoadInt32("ExternalEncoders", 0, null) ?? 0; for (int nEncoders = 0; nEncoders < totalEncoders; nEncoders++) @@ -1449,8 +1519,8 @@ string status = processor.Go(); language = sr.Load("Language") ?? Thread.CurrentThread.CurrentUICulture.Name; - if (arLogFilenameFormat.Contains("%F")) - arLogFilenameFormat = "%filename%.accurip"; + if (ArLogFilenameFormat.Contains("%F")) + ArLogFilenameFormat = "%filename%.accurip"; if (singleFilenameFormat.Contains("%F")) singleFilenameFormat = "%filename%"; if (trackFilenameFormat.Contains("%N")) @@ -1466,6 +1536,23 @@ string status = processor.Go(); return result == null ? null : result.Name; } + public IWebProxy GetProxy() + { + IWebProxy proxy = null; + switch (advanced.UseProxyMode) + { + case CUEConfigAdvanced.ProxyMode.System: + proxy = WebRequest.GetSystemWebProxy(); + break; + case CUEConfigAdvanced.ProxyMode.Custom: + proxy = new WebProxy(advanced.ProxyServer, advanced.ProxyPort); + if (advanced.ProxyUser != "") + proxy.Credentials = new NetworkCredential(advanced.ProxyUser, advanced.ProxyPassword); + break; + } + return proxy; + } + public string CleanseString (string s) { StringBuilder sb = new StringBuilder(); @@ -1668,7 +1755,7 @@ string status = processor.Go(); _hasEmbeddedCUESheet = false; _isArchive = false; _isCD = false; - proxy = _config.useSystemProxySettings ? WebRequest.GetSystemWebProxy() : null; + proxy = _config.GetProxy(); } public void OpenCD(ICDRipper ripper) @@ -1797,69 +1884,6 @@ string status = processor.Go(); } } - public void FillFromMusicBrainz(MusicBrainz.Release release) - { - string date = release.GetEvents().Count > 0 ? release.GetEvents()[0].Date : null; - Year = date == null ? "" : date.Substring(0, 4); - Artist = release.GetArtist(); - Title = release.GetTitle(); - // How to get Genre: http://mm.musicbrainz.org/ws/1/release/6fe1e218-2aee-49ac-94f0-7910ba2151df.html?type=xml&inc=tags - //Catalog = release.GetEvents().Count > 0 ? release.GetEvents()[0].Barcode : ""; - for (int i = 1; i <= _toc.AudioTracks; i++) - { - MusicBrainz.Track track = release.GetTracks()[(int)_toc[i].Number - 1]; // !!!!!! - _toc.FirstAudio - Tracks[i - 1].Title = track.GetTitle(); - Tracks[i - 1].Artist = track.GetArtist(); - } - } - - public bool FreedbToEncoding() - { - Encoding iso = Encoding.GetEncoding("iso-8859-1"); - bool different = false; - string tmp; - tmp = Encoding.Default.GetString(iso.GetBytes(Artist)); different |= Artist != tmp; Artist = tmp; - tmp = Encoding.Default.GetString(iso.GetBytes(Title)); different |= Title != tmp; Title = tmp; - for (int i = 0; i < _toc.AudioTracks; i++) - { - tmp = Encoding.Default.GetString(iso.GetBytes(Tracks[i].Artist)); different |= Tracks[i].Artist != tmp; Tracks[i].Artist = tmp; - tmp = Encoding.Default.GetString(iso.GetBytes(Tracks[i].Title)); different |= Tracks[i].Title != tmp; Tracks[i].Title = tmp; - } - return different; - } - - public void FreedbToVarious() - { - for (int i = 0; i < _toc.AudioTracks; i++) - { - string title = Tracks[i].Title; - int idx = title.IndexOf(" / "); - if (idx < 0) idx = title.IndexOf(" - "); - if (idx >= 0) - { - Tracks[i].Title = title.Substring(idx + 3); - Tracks[i].Artist = title.Substring(0, idx); - } - else - { - Tracks[i].Artist = title; - } - } - } - - public void FillFromFreedb(Freedb.CDEntry cdEntry) - { - Year = cdEntry.Year; - Genre = cdEntry.Genre; - Artist = cdEntry.Artist; - Title = cdEntry.Title; - for (int i = 0; i < _toc.AudioTracks; i++) - { - Tracks[i].Title = cdEntry.Tracks[i + _toc.FirstAudio - 1].Title; - Tracks[i].Artist = cdEntry.Artist; - } - } - public List LookupAlbumInfo(bool useFreedb, bool useMusicBrainz, bool useCache) { List Releases = new List(); @@ -1880,17 +1904,20 @@ string status = processor.Go(); } } - Releases.Add(new CUEMetadataEntry(Metadata, TOC, "cue")); - Releases.Add(new CUEMetadataEntry(new CUEMetadata(taglibMetadata), TOC, "tags")); + CUEMetadata meta = Metadata; + if (meta.Contains(taglibMetadata) || !taglibMetadata.Contains(meta)) + Releases.Add(new CUEMetadataEntry(meta, TOC, "cue")); + if (!meta.Contains(taglibMetadata)) + Releases.Add(new CUEMetadataEntry(new CUEMetadata(taglibMetadata), TOC, "tags")); if (useFreedb) { ShowProgress("Looking up album via Freedb...", 0.0, null, null); FreedbHelper m_freedb = new FreedbHelper(); - - m_freedb.UserName = "gchudov"; - m_freedb.Hostname = "gmail.com"; + m_freedb.Proxy = proxy; + m_freedb.UserName = _config.advanced.FreedbUser; + m_freedb.Hostname = _config.advanced.FreedbDomain; m_freedb.ClientName = "CUETools"; m_freedb.Version = "2.0.8"; m_freedb.SetDefaultSiteAddress("freedb.org"); @@ -1953,6 +1980,7 @@ string status = processor.Go(); // DiscIds.Add(_tocFromLog.MusicBrainzId); MusicBrainzService.XmlRequest += new EventHandler(MusicBrainz_LookupProgress); + MusicBrainzService.Proxy = proxy; foreach (string DiscId in DiscIds) { ReleaseQueryParameters p = new ReleaseQueryParameters(); @@ -1986,6 +2014,7 @@ string status = processor.Go(); System.Diagnostics.Trace.WriteLine(ex.Message); } } + MusicBrainzService.Proxy = null; MusicBrainzService.XmlRequest -= new EventHandler(MusicBrainz_LookupProgress); //if (release != null) //{ @@ -2598,24 +2627,11 @@ string status = processor.Go(); if (_config.fillUpCUE) { - if ((_config.overwriteCUEData || General.FindCUELine(_attributes, "PERFORMER") == null) && taglibMetadata.Artist != "") - General.SetCUELine(_attributes, "PERFORMER", taglibMetadata.Artist, true); - if ((_config.overwriteCUEData || General.FindCUELine(_attributes, "TITLE") == null) && taglibMetadata.Title != "") - General.SetCUELine(_attributes, "TITLE", taglibMetadata.Title, true); - if ((_config.overwriteCUEData || General.FindCUELine(_attributes, "REM", "DATE") == null) && taglibMetadata.Year != "") - General.SetCUELine(_attributes, "REM", "DATE", taglibMetadata.Year, false); - if ((_config.overwriteCUEData || General.FindCUELine(_attributes, "REM", "GENRE") == null) && taglibMetadata.Genre != "") - General.SetCUELine(_attributes, "REM", "GENRE", taglibMetadata.Genre, true); - if ((_config.overwriteCUEData || TotalDiscs == "") && taglibMetadata.TotalDiscs != "") - TotalDiscs = taglibMetadata.TotalDiscs; - if ((_config.overwriteCUEData || DiscNumber == "") && taglibMetadata.DiscNumber != "") - DiscNumber = taglibMetadata.DiscNumber; + CUEMetadata meta = Metadata; // new CUEMetadata(Metadata); + meta.Merge(taglibMetadata, _config.overwriteCUEData); + CopyMetadata(meta); for (i = 0; i < TrackCount; i++) { - if ((_config.overwriteCUEData || _tracks[i].Artist == "") && taglibMetadata.Tracks[i].Artist != "") - _tracks[i].Artist = taglibMetadata.Tracks[i].Artist; - if ((_config.overwriteCUEData || _tracks[i].Title == "") && taglibMetadata.Tracks[i].Title != "") - _tracks[i].Title = taglibMetadata.Tracks[i].Title; if (_tracks[i].Title == "" && _hasTrackFilenames) _tracks[i].Title = Path.GetFileNameWithoutExtension(_trackFilenames[i]).TrimStart(" .-_0123456789".ToCharArray()); } @@ -2778,7 +2794,7 @@ string status = processor.Go(); LoadAlbumArt(_tracks[0]._fileInfo ?? _fileInfo); ResizeAlbumArt(); - if (_config.embedAlbumArt || _config.copyAlbumArt) + if (_config.embedAlbumArt || _config.CopyAlbumArt) _albumArt.ForEach(t => _padding += _albumArt[0].Data.Count); if (_config.embedLog && _eacLog != null) _padding += _eacLog.Length; @@ -3147,9 +3163,9 @@ string status = processor.Go(); extension = ".20bit" + extension; } - ArLogFileName = General.ReplaceMultiple(_config.arLogFilenameFormat, vars, "unique", CheckIfFileExists) + ArLogFileName = General.ReplaceMultiple(_config.ArLogFilenameFormat, vars, "unique", CheckIfFileExists) ?? vars["%filename%"] + ".accurip"; - AlArtFileName = General.ReplaceMultiple(_config.alArtFilenameFormat, vars, "unique", CheckIfFileExists) + AlArtFileName = General.ReplaceMultiple(_config.AlArtFilenameFormat, vars, "unique", CheckIfFileExists) ?? "folder.jpg"; if (OutputStyle == CUEStyle.SingleFileWithCUE) @@ -3883,7 +3899,7 @@ string status = processor.Go(); if (_action == CUEAction.Encode) { string cueContents = CUESheetContents(OutputStyle); - if (_config.createEACLOG) + if (_config.createEACLOG && _isCD) cueContents = CUESheet.Encoding.GetString(CUESheet.Encoding.GetBytes(cueContents)); if (OutputStyle == CUEStyle.SingleFileWithCUE && _config.createCUEFileWhenEmbedded) WriteText(Path.ChangeExtension(_outputPath, ".cue"), cueContents); @@ -3985,7 +4001,7 @@ string status = processor.Go(); fileInfo.Tag.Year = sourceFileInfo.Tag.Year; } - if ((_config.embedAlbumArt || _config.copyAlbumArt) && _albumArt.Count > 0) + if ((_config.embedAlbumArt || _config.CopyAlbumArt) && _albumArt.Count > 0) fileInfo.Tag.Pictures = _albumArt.ToArray(); fileInfo.Save(); @@ -4052,7 +4068,7 @@ string status = processor.Go(); fileInfo.Tag.Genres = sourceFileInfo.Tag.Genres; } - if ((_config.embedAlbumArt || _config.copyAlbumArt) && _albumArt.Count > 0) + if ((_config.embedAlbumArt || _config.CopyAlbumArt) && _albumArt.Count > 0) fileInfo.Tag.Pictures = _albumArt.ToArray(); fileInfo.Save(); @@ -4113,7 +4129,7 @@ string status = processor.Go(); public void LoadAlbumArt(TagLib.File fileInfo) { - if ((_config.extractAlbumArt || _config.copyAlbumArt) && fileInfo != null) + if ((_config.extractAlbumArt || _config.CopyAlbumArt) && fileInfo != null) foreach (TagLib.IPicture picture in fileInfo.Tag.Pictures) if (picture.Type == TagLib.PictureType.FrontCover) if (picture.MimeType == "image/jpeg") @@ -4123,15 +4139,7 @@ string status = processor.Go(); } if ((_config.extractAlbumArt || _config.embedAlbumArt) && !_isCD) { - List names = new List(); - names.Add("folder.jpg"); - names.Add("cover.jpg"); - names.Add("albumart.jpg"); - names.Add("thumbnail.jpg"); - names.Add("albumartlarge.jpg"); - names.Add("front.jpg"); - - foreach (string name in names) + foreach (string name in _config.advanced.CoverArtFiles) { string imgPath = Path.Combine(_isArchive ? _archiveCUEpath : _inputDir, name); bool exists = _isArchive ? _archiveContents.Contains(imgPath) : File.Exists(imgPath); @@ -4147,9 +4155,28 @@ string status = processor.Go(); } } - if (!_isArchive) + if (!_isArchive && _config.advanced.CoverArtSearchSubdirs) { // TODO: archive case + foreach (string name in _config.advanced.CoverArtFiles) + { + foreach (string imgPath in Directory.GetFiles(_inputDir, name, SearchOption.AllDirectories)) + { + TagLib.File.IFileAbstraction file = _isArchive + ? (TagLib.File.IFileAbstraction)new ArchiveFileAbstraction(this, imgPath) + : (TagLib.File.IFileAbstraction)new TagLib.File.LocalFileAbstraction(imgPath); + TagLib.Picture pic = new TagLib.Picture(file); + pic.Description = name; + _albumArt.Add(pic); + } + if (_albumArt.Count == 1) + return; + if (_albumArt.Count > 1) + { + _albumArt.Clear(); + break; + } + } foreach (string imgPath in Directory.GetFiles(_inputDir, "*.jpg", SearchOption.AllDirectories)) { TagLib.Picture pic = new TagLib.Picture(imgPath); @@ -4158,11 +4185,15 @@ string status = processor.Go(); else pic.Description = Path.GetFileName(imgPath); _albumArt.Add(pic); - if (Action != CUEAction.Encode) - return; } } + if (Action != CUEAction.Encode && _albumArt.Count > 1) + { + _albumArt.Clear(); + return; + } + if (_albumArt.Count != 0) { CUEToolsSelectionEventArgs e = new CUEToolsSelectionEventArgs(); @@ -4505,11 +4536,11 @@ string status = processor.Go(); int diskLength = 588 * (int)_toc.AudioLength; int diskOffset = 0; - // we init CTDB before AR so that AR gets inited with correct CTDB settings + // we init AR before CTDB so that CTDB gets inited with correct TOC + if (_useAccurateRip || _useCUEToolsDB) + _arVerify.Init(_toc); if (_useCUEToolsDB && !_useCUEToolsDBFix) _CUEToolsDB.Init(_useCUEToolsDBSibmit, _arVerify); - if (_useAccurateRip) - _arVerify.Init(); ShowProgress(String.Format("{2} track {0:00} ({1:00}%)...", 0, 0, noOutput ? "Verifying" : "Writing"), 0.0, null, null); @@ -4662,12 +4693,12 @@ string status = processor.Go(); ApplyWriteOffset(); hdcdDecoder = null; - - // we init CTDB before AR so that AR gets inited with correct CTDB settings + + // we init AR before CTDB so that CTDB gets inited with correct TOC + if (_useAccurateRip || _useCUEToolsDB) + _arVerify.Init(_toc); if (_useCUEToolsDB && !_useCUEToolsDBFix) _CUEToolsDB.Init(_useCUEToolsDBSibmit, _arVerify); - if (_useAccurateRip) - _arVerify.Init(); ShowProgress(String.Format("Verifying ({0:00}%)...", 0), 0.0, null, null); diff --git a/CUETools/frmCUETools.cs b/CUETools/frmCUETools.cs index 79ff660..5f9ce6f 100644 --- a/CUETools/frmCUETools.cs +++ b/CUETools/frmCUETools.cs @@ -746,9 +746,9 @@ namespace JDP { if (_batchPaths.Count == 0 && action == CUEAction.Encode) { if (checkBoxUseFreeDb.Checked || checkBoxUseMusicBrainz.Checked) - releases = cueSheet.LookupAlbumInfo(checkBoxUseFreeDb.Checked, checkBoxUseMusicBrainz.Checked, true); + releases = cueSheet.LookupAlbumInfo(checkBoxUseFreeDb.Checked, checkBoxUseMusicBrainz.Checked, _profile._config.advanced.CacheMetadata); } - else // if checkBoxUseMetadataCache.Checked + else if (_profile._config.advanced.CacheMetadata) { try { diff --git a/CUETools/frmChoice.cs b/CUETools/frmChoice.cs index e6d6f6c..93e42a7 100644 --- a/CUETools/frmChoice.cs +++ b/CUETools/frmChoice.cs @@ -140,7 +140,8 @@ namespace JDP if (e.CloseReason != CloseReason.None || DialogResult != DialogResult.OK || ri == null || CUE == null) return; CUE.CopyMetadata(ri.metadata); - ri.metadata.Save(); + if (CUE.Config.advanced.CacheMetadata) + ri.metadata.Save(); } private void AutoResizeTracks() diff --git a/CUETools/frmSettings.Designer.cs b/CUETools/frmSettings.Designer.cs index bc7434a..5565615 100644 --- a/CUETools/frmSettings.Designer.cs +++ b/CUETools/frmSettings.Designer.cs @@ -172,11 +172,12 @@ namespace JDP { this.columnHeader6 = new System.Windows.Forms.ColumnHeader(); this.listViewScripts = new System.Windows.Forms.ListView(); this.columnHeader5 = new System.Windows.Forms.ColumnHeader(); + this.tabPage7 = new System.Windows.Forms.TabPage(); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); this.labelFormatDecoder = new System.Windows.Forms.Label(); this.labelFormatEncoder = new System.Windows.Forms.Label(); this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); this.checkBox1 = new System.Windows.Forms.CheckBox(); - this.checkBoxUseSystemProxy = new System.Windows.Forms.CheckBox(); btnCancel = new System.Windows.Forms.Button(); this.grpGeneral.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -218,6 +219,7 @@ namespace JDP { this.grpHDCD.SuspendLayout(); this.tabPage5.SuspendLayout(); this.groupBoxScriptConditions.SuspendLayout(); + this.tabPage7.SuspendLayout(); this.SuspendLayout(); // // btnCancel @@ -229,7 +231,6 @@ namespace JDP { // // grpGeneral // - this.grpGeneral.Controls.Add(this.checkBoxUseSystemProxy); this.grpGeneral.Controls.Add(this.checkBoxSeparateDecodingThread); this.grpGeneral.Controls.Add(this.checkBoxCheckForUpdates); this.grpGeneral.Controls.Add(this.chkAllowMultipleInstances); @@ -654,6 +655,7 @@ namespace JDP { this.tabControl1.Controls.Add(this.tabPage11); this.tabControl1.Controls.Add(this.tabPage4); this.tabControl1.Controls.Add(this.tabPage5); + this.tabControl1.Controls.Add(this.tabPage7); this.tabControl1.HotTrack = true; this.tabControl1.Multiline = true; this.tabControl1.Name = "tabControl1"; @@ -1453,6 +1455,20 @@ namespace JDP { // resources.ApplyResources(this.columnHeader5, "columnHeader5"); // + // tabPage7 + // + this.tabPage7.BackColor = System.Drawing.SystemColors.Control; + this.tabPage7.Controls.Add(this.propertyGrid1); + resources.ApplyResources(this.tabPage7, "tabPage7"); + this.tabPage7.Name = "tabPage7"; + // + // propertyGrid1 + // + resources.ApplyResources(this.propertyGrid1, "propertyGrid1"); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.PropertySort = System.Windows.Forms.PropertySort.Categorized; + this.propertyGrid1.ToolbarVisible = false; + // // labelFormatDecoder // resources.ApplyResources(this.labelFormatDecoder, "labelFormatDecoder"); @@ -1473,12 +1489,6 @@ namespace JDP { this.checkBox1.Name = "checkBox1"; this.checkBox1.UseVisualStyleBackColor = true; // - // checkBoxUseSystemProxy - // - resources.ApplyResources(this.checkBoxUseSystemProxy, "checkBoxUseSystemProxy"); - this.checkBoxUseSystemProxy.Name = "checkBoxUseSystemProxy"; - this.checkBoxUseSystemProxy.UseVisualStyleBackColor = true; - // // frmSettings // this.AcceptButton = this.btnOK; @@ -1557,6 +1567,7 @@ namespace JDP { this.grpHDCD.PerformLayout(); this.tabPage5.ResumeLayout(false); this.groupBoxScriptConditions.ResumeLayout(false); + this.tabPage7.ResumeLayout(false); this.ResumeLayout(false); } @@ -1713,7 +1724,8 @@ namespace JDP { private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.CheckBox checkBoxFlaCudaMultithread; private System.Windows.Forms.CheckBox checkBoxSeparateDecodingThread; - private System.Windows.Forms.CheckBox checkBoxUseSystemProxy; + private System.Windows.Forms.TabPage tabPage7; + private System.Windows.Forms.PropertyGrid propertyGrid1; } } \ No newline at end of file diff --git a/CUETools/frmSettings.cs b/CUETools/frmSettings.cs index 72ce3fb..d26a717 100644 --- a/CUETools/frmSettings.cs +++ b/CUETools/frmSettings.cs @@ -35,6 +35,7 @@ namespace JDP { private void frmSettings_Load(object sender, EventArgs e) { cUEConfigBindingSource.DataSource = _config; + propertyGrid1.SelectedObject = _config.advanced; chkReducePriority.Checked = _reducePriority; checkBoxCheckForUpdates.Checked = _config.checkForUpdates; @@ -85,7 +86,6 @@ namespace JDP { //textBoxARLogExtension.Text = _config.arLogFilenameFormat; numericUpDownMaxResolution.Value = _config.maxAlbumArtSize; checkBoxSeparateDecodingThread.Checked = _config.separateDecodingThread; - checkBoxUseSystemProxy.Checked = _config.useSystemProxySettings; switch (_config.gapsHandling) { @@ -249,7 +249,6 @@ namespace JDP { //_config.arLogFilenameFormat = textBoxARLogExtension.Text; _config.maxAlbumArtSize = (int) numericUpDownMaxResolution.Value; _config.separateDecodingThread = checkBoxSeparateDecodingThread.Checked; - _config.useSystemProxySettings = checkBoxUseSystemProxy.Checked; _config.language = ((CultureInfo)comboLanguage.SelectedItem).Name; } diff --git a/CUETools/frmSettings.resx b/CUETools/frmSettings.resx index 867f0d9..0b3b181 100644 --- a/CUETools/frmSettings.resx +++ b/CUETools/frmSettings.resx @@ -150,33 +150,6 @@ 1 - - True - - - 12, 157 - - - 153, 17 - - - 10 - - - Use system proxy settings - - - checkBoxUseSystemProxy - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpGeneral - - - 0 - True @@ -208,7 +181,7 @@ grpGeneral - 1 + 0 True @@ -241,7 +214,7 @@ grpGeneral - 2 + 1 True @@ -274,7 +247,7 @@ grpGeneral - 3 + 2 True @@ -307,7 +280,7 @@ grpGeneral - 4 + 3 True @@ -340,7 +313,7 @@ grpGeneral - 5 + 4 True @@ -373,7 +346,7 @@ grpGeneral - 6 + 5 True @@ -406,7 +379,7 @@ grpGeneral - 7 + 6 True @@ -439,7 +412,7 @@ grpGeneral - 8 + 7 6, 6 @@ -4192,6 +4165,54 @@ 7 + + 8, 6 + + + 518, 279 + + + 0 + + + propertyGrid1 + + + System.Windows.Forms.PropertyGrid, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 535, 291 + + + 10 + + + Advanced + + + tabPage7 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 8 + 0, 0 diff --git a/Freedb/Freedb.csproj b/Freedb/Freedb.csproj index e44a1a4..54b4c18 100644 --- a/Freedb/Freedb.csproj +++ b/Freedb/Freedb.csproj @@ -62,7 +62,7 @@ - false + true 4096 false @@ -72,7 +72,7 @@ false false 4 - none + pdbonly prompt diff --git a/Freedb/FreedbHelper.cs b/Freedb/FreedbHelper.cs index 02b0ccd..c3b1ad1 100644 --- a/Freedb/FreedbHelper.cs +++ b/Freedb/FreedbHelper.cs @@ -32,6 +32,7 @@ namespace Freedb { public const string MAIN_FREEDB_ADDRESS = "freedb.freedb.org"; public const string DEFAULT_ADDITIONAL_URL_INFO = "/~cddb/cddb.cgi"; + public const string SUBMIT_ADDITIONAL_URL_INFO = "/~cddb/submit.cgi"; private Site m_mainSite = new Site(MAIN_FREEDB_ADDRESS,"http",DEFAULT_ADDITIONAL_URL_INFO); private string m_UserName; private string m_Hostname; @@ -77,6 +78,13 @@ namespace Freedb #region Public Properties + + /// + /// Proxy server to use + /// + public IWebProxy Proxy { get; set; } + + /// /// Property Version (string) /// @@ -189,6 +197,7 @@ namespace Freedb public FreedbHelper() { m_ProtocolLevel = "6"; // default it + ValidCategories.AddRange(new string[]{"blues", "classical", "country", "data", "folk", "jazz", "misc", "newage", "reggae", "rock", "soundtrack"}); } @@ -452,6 +461,94 @@ namespace Freedb } + public StringCollection ValidCategories = new StringCollection(); + + public string Submit(CDEntry entry, int length, string discid, string category, bool test) + { + StreamReader reader = null; + HttpWebResponse response = null; + string url = "http://" + MAIN_FREEDB_ADDRESS + SUBMIT_ADDITIONAL_URL_INFO; + string command = ""; + string result = ""; + + if ((entry.Artist ?? "") == "") + throw new Exception("Artist not set"); + if ((entry.Title ?? "") == "") + throw new Exception("Title not set"); + if (!ValidCategories.Contains(category)) + throw new Exception("Category not valid"); + foreach (Track t in entry.Tracks) + if ((t.Title ?? "") == "") + throw new Exception("Track titles not set"); + foreach (Track t in entry.Tracks) + if (t.FrameOffset < 150) + throw new Exception("Track frame offsets not set"); + + command += "# xmcd CD database file\n"; + command += "#\n"; + command += "# Track frame offsets:\n"; + foreach(Track t in entry.Tracks) + command += "# " + t.FrameOffset + "\n"; + command += "#\n"; + command += "# Disc length: " + length.ToString() + " seconds\n"; + command += "#\n"; + command += "# Revision: 0\n"; + command += "# Submitted via: " + ClientName + " " + Version + "\n"; + command += "#\n"; + command += "DISCID=" + discid.ToLower() + "\n"; + command += "DTITLE=" + entry.Artist.Replace(" / ", "/") + " / " + entry.Title.Replace(" / ", "/") + "\n"; + command += "DYEAR=" + entry.Year + "\n"; // DYEAR=#{@year.to_i == 0 ? "" : "%04d" % @year} + command += "DGENRE=" + entry.Genre + "\n"; // DGENRE=#{(@genre || "").split(" ").collect do |w| w.capitalize end.join(" ")} + int i = 0; + foreach (Track t in entry.Tracks) + command += "TTITLE" + (i++).ToString() + "=" + t.Title + "\n"; // escape + i = 0; + command += "EXTD=" + entry.ExtendedData + "\n"; + foreach (Track t in entry.Tracks) + command += "EXTT" + (i++).ToString() + "=" + t.ExtendedData + "\n"; // escape + command += "PLAYORDER=\n"; + + try + { + //create our HttpWebRequest which we use to call the freedb server + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Proxy = Proxy; + req.ContentType = "text/plain"; + req.Method = "POST"; + req.Headers.Add("Category", category); + req.Headers.Add("Discid", discid.ToLower()); + req.Headers.Add("User-Email", UserName + '@' + Hostname); + req.Headers.Add("Submit-Mode", test ? "test" : "submit"); + req.Headers.Add("X-Cddbd-Note", "Sent by " + ClientName + " " + Version); + req.Headers.Add("Charset", "utf-8"); + //using Unicode + byte[] byteArray = Encoding.UTF8.GetBytes(command); + //get our request stream + Stream newStream = req.GetRequestStream(); + //write our command data to it + newStream.Write(byteArray, 0, byteArray.Length); + newStream.Close(); + //Make the call. Note this is a synchronous call + response = (HttpWebResponse)req.GetResponse(); + //put the results into a StreamReader + reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8); + result = reader.ReadToEnd(); + } + catch (Exception ex) + { + throw ex; + } + finally + { + if (response != null) + response.Close(); + if (reader != null) + reader.Close(); + } + + return result; + } + /// /// Retrieve the categories @@ -549,6 +646,7 @@ namespace Freedb { //create our HttpWebRequest which we use to call the freedb server HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Proxy = Proxy; req.ContentType = "text/plain"; // we are using th POST method of calling the http server. We could have also used the GET method req.Method="POST"; diff --git a/MusicBrainz/MusicBrainz/MusicBrainzObject.cs b/MusicBrainz/MusicBrainz/MusicBrainzObject.cs index 8f43386..d258be5 100644 --- a/MusicBrainz/MusicBrainz/MusicBrainzObject.cs +++ b/MusicBrainz/MusicBrainz/MusicBrainzObject.cs @@ -380,73 +380,73 @@ namespace MusicBrainz static void XmlProcessingClosure (string url, XmlProcessingDelegate code) { - Monitor.Enter (server_mutex); - - // Don't access the MB server twice within a second - if (last_accessed != null) + lock (server_mutex) { - TimeSpan time = DateTime.Now - last_accessed; - if (min_interval > time) - Thread.Sleep((min_interval - time).Milliseconds); - } - - WebRequest request = WebRequest.Create (url); - bool cache_implemented = false; - - try { - request.CachePolicy = MusicBrainzService.CachePolicy; - cache_implemented = true; - } catch (NotImplementedException) {} - - HttpWebResponse response = null; - - try { - response = (HttpWebResponse)request.GetResponse (); - } catch (WebException e) { - response = (HttpWebResponse)e.Response; - } - - if (response == null) throw new MusicBrainzNotFoundException (); - - switch (response.StatusCode) - { - case HttpStatusCode.BadRequest: - Monitor.Exit(server_mutex); - throw new MusicBrainzInvalidParameterException(); - case HttpStatusCode.Unauthorized: - Monitor.Exit(server_mutex); - throw new MusicBrainzUnauthorizedException(); - case HttpStatusCode.NotFound: - Monitor.Exit(server_mutex); - throw new MusicBrainzNotFoundException(); - case HttpStatusCode.ServiceUnavailable: - Monitor.Exit(server_mutex); - throw new MusicBrainzUnavailableException(response.StatusDescription); - case HttpStatusCode.OK: - break; - default: - Monitor.Exit(server_mutex); - throw new MusicBrainzUnavailableException(response.StatusDescription); - } - - bool from_cache = cache_implemented && response.IsFromCache; - - if (from_cache) Monitor.Exit (server_mutex); - - try - { - MusicBrainzService.OnXmlRequest(url, from_cache); - - // Should we read the stream into a memory stream and run the XmlReader off of that? - code(new XmlTextReader(response.GetResponseStream())); - } - finally - { - response.Close(); - if (!from_cache) + // Don't access the MB server twice within a second + if (last_accessed != null) { - last_accessed = DateTime.Now; - Monitor.Exit(server_mutex); + TimeSpan time = DateTime.Now - last_accessed; + if (min_interval > time) + Thread.Sleep((min_interval - time).Milliseconds); + } + + WebRequest request = WebRequest.Create(url); + bool cache_implemented = false; + + request.Proxy = MusicBrainzService.Proxy; + + try + { + request.CachePolicy = MusicBrainzService.CachePolicy; + cache_implemented = true; + } + catch (NotImplementedException) { } + + HttpWebResponse response = null; + + try + { + response = (HttpWebResponse)request.GetResponse(); + } + catch (WebException e) + { + if (e.Response == null) + throw e; + response = (HttpWebResponse)e.Response; + } + + switch (response.StatusCode) + { + case HttpStatusCode.BadRequest: + throw new MusicBrainzInvalidParameterException(); + case HttpStatusCode.Unauthorized: + throw new MusicBrainzUnauthorizedException(); + case HttpStatusCode.NotFound: + throw new MusicBrainzNotFoundException(); + case HttpStatusCode.ServiceUnavailable: + throw new MusicBrainzUnavailableException(response.StatusDescription); + case HttpStatusCode.OK: + break; + default: + throw new MusicBrainzUnavailableException(response.StatusDescription); + } + + bool from_cache = cache_implemented && response.IsFromCache; + + try + { + MusicBrainzService.OnXmlRequest(url, from_cache); + + // Should we read the stream into a memory stream and run the XmlReader off of that? + code(new XmlTextReader(response.GetResponseStream())); + } + finally + { + response.Close(); + if (!from_cache) + { + last_accessed = DateTime.Now; + } } } } diff --git a/MusicBrainz/MusicBrainz/MusicBrainzService.cs b/MusicBrainz/MusicBrainz/MusicBrainzService.cs index 1006c38..9aa3714 100644 --- a/MusicBrainz/MusicBrainz/MusicBrainzService.cs +++ b/MusicBrainz/MusicBrainz/MusicBrainzService.cs @@ -40,8 +40,10 @@ namespace MusicBrainz public static RequestCachePolicy CachePolicy { get { return cache_policy; } set { cache_policy = value; } - } - + } + + public static System.Net.IWebProxy Proxy { get; set; } + public static event EventHandler XmlRequest; internal static void OnXmlRequest (string url, bool fromCache)