This commit is contained in:
chudov
2009-05-13 16:07:53 +00:00
parent 00c229caad
commit 7f27f99406
4 changed files with 1997 additions and 801 deletions

View File

@@ -408,7 +408,7 @@ namespace CUETools.Processor
public bool copyUnknownTags;
public bool copyAlbumArt;
public bool embedAlbumArt;
//public bool extractAlbumArt;
public bool extractAlbumArt;
public bool arLogToSourceFolder;
public bool arLogVerbose;
public bool fixOffsetToNearest;
@@ -469,6 +469,7 @@ namespace CUETools.Processor
copyUnknownTags = true;
copyAlbumArt = true;
embedAlbumArt = true;
extractAlbumArt = true;
maxAlbumArtSize = 300;
arLogToSourceFolder = false;
@@ -618,6 +619,7 @@ return processor.Go();
sw.Save("CopyUnknownTags", copyUnknownTags);
sw.Save("CopyAlbumArt", copyAlbumArt);
sw.Save("EmbedAlbumArt", embedAlbumArt);
sw.Save("ExtractAlbumArt", extractAlbumArt);
sw.Save("MaxAlbumArtSize", maxAlbumArtSize);
sw.Save("ArLogToSourceFolder", arLogToSourceFolder);
@@ -737,7 +739,8 @@ return processor.Go();
copyUnknownTags = sr.LoadBoolean("CopyUnknownTags") ?? true;
copyAlbumArt = sr.LoadBoolean("CopyAlbumArt") ?? true;
embedAlbumArt = sr.LoadBoolean("EmbedAlbumArt") ?? true;
maxAlbumArtSize = sr.LoadInt32("MaxAlbumArtSize", 100, 3000) ?? maxAlbumArtSize;
extractAlbumArt = sr.LoadBoolean("ExtractAlbumArt") ?? true;
maxAlbumArtSize = sr.LoadInt32("MaxAlbumArtSize", 100, 10000) ?? maxAlbumArtSize;
arLogToSourceFolder = sr.LoadBoolean("ArLogToSourceFolder") ?? arLogToSourceFolder;
arLogVerbose = sr.LoadBoolean("ArLogVerbose") ?? arLogVerbose;
@@ -2234,7 +2237,8 @@ return processor.Go();
if ((audioSource.BitsPerSample != 16) ||
(audioSource.ChannelCount != 2) ||
(audioSource.SampleRate != 44100) ||
(audioSource.Length > Int32.MaxValue))
(audioSource.Length == 0) ||
(audioSource.Length >= Int32.MaxValue))
{
audioSource.Close();
throw new Exception("Audio format is invalid.");
@@ -2851,6 +2855,9 @@ return processor.Go();
fileInfo.Tag.Year = sourceFileInfo.Tag.Year;
}
if (_config.extractAlbumArt && sourceFileInfo.Tag.Pictures.Length > 0)
ExtractCover(sourceFileInfo);
// copy album art
if (_config.copyAlbumArt && sourceFileInfo != null)
fileInfo.Tag.Pictures = sourceFileInfo.Tag.Pictures;
@@ -2910,6 +2917,9 @@ return processor.Go();
fileInfo.Tag.Genres = sourceFileInfo.Tag.Genres;
}
if (_config.extractAlbumArt && sourceFileInfo.Tag.Pictures.Length > 0)
ExtractCover(sourceFileInfo);
if (_config.copyAlbumArt && sourceFileInfo != null)
fileInfo.Tag.Pictures = sourceFileInfo.Tag.Pictures;
@@ -2955,11 +2965,33 @@ return processor.Go();
return b;
}
public void ExtractCover(TagLib.File fileInfo)
{
string imgPath = Path.Combine(OutputDir, "Folder.jpg");
if (File.Exists(imgPath))
return;
foreach (TagLib.IPicture picture in fileInfo.Tag.Pictures)
{
if (picture.Type == TagLib.PictureType.FrontCover)
{
if (picture.MimeType == "image/jpeg")
{
using (FileStream file = new FileStream(imgPath, FileMode.CreateNew, FileAccess.Write, FileShare.Read))
{
file.Write(picture.Data.Data, 0, picture.Data.Count);
return;
}
}
}
}
}
public void EmbedCover(TagLib.File fileInfo)
{
string imgPath = Path.Combine(_inputDir, "Folder.jpg");
if (File.Exists(imgPath))
{
if (!File.Exists(imgPath))
return;
using (Image img = Image.FromFile(imgPath))
{
if (img.Width > _config.maxAlbumArtSize || img.Height > _config.maxAlbumArtSize)
@@ -2979,7 +3011,6 @@ return processor.Go();
fileInfo.Tag.Pictures = new TagLib.Picture[] { new TagLib.Picture(imgPath) };
}
}
}
public string WriteReport()
{

View File

@@ -67,10 +67,14 @@ namespace JDP {
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage6 = new System.Windows.Forms.TabPage();
this.groupBoxTagging = new System.Windows.Forms.GroupBox();
this.groupBoxAlbumArt = new System.Windows.Forms.GroupBox();
this.labelAlbumArtMaximumResolution = new System.Windows.Forms.Label();
this.numericUpDownMaxResolution = new System.Windows.Forms.NumericUpDown();
this.checkBoxEmbedAlbumArt = new System.Windows.Forms.CheckBox();
this.checkBoxCopyBasicTags = new System.Windows.Forms.CheckBox();
this.checkBoxCopyAlbumArt = new System.Windows.Forms.CheckBox();
this.groupBoxTagging = new System.Windows.Forms.GroupBox();
this.chkExtractLog = new System.Windows.Forms.CheckBox();
this.checkBoxCopyBasicTags = new System.Windows.Forms.CheckBox();
this.checkBoxWriteCUETags = new System.Windows.Forms.CheckBox();
this.checkBoxCopyUnknownTags = new System.Windows.Forms.CheckBox();
this.chkOverwriteTags = new System.Windows.Forms.CheckBox();
@@ -160,10 +164,7 @@ namespace JDP {
this.labelFormatDecoder = new System.Windows.Forms.Label();
this.labelFormatEncoder = new System.Windows.Forms.Label();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.groupBoxAlbumArt = new System.Windows.Forms.GroupBox();
this.chkExtractLog = new System.Windows.Forms.CheckBox();
this.numericUpDownMaxResolution = new System.Windows.Forms.NumericUpDown();
this.labelAlbumArtMaximumResolution = new System.Windows.Forms.Label();
this.checkBoxExtractAlbumArt = new System.Windows.Forms.CheckBox();
btnCancel = new System.Windows.Forms.Button();
this.grpGeneral.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -175,6 +176,8 @@ namespace JDP {
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage6.SuspendLayout();
this.groupBoxAlbumArt.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxResolution)).BeginInit();
this.groupBoxTagging.SuspendLayout();
this.tabPage2.SuspendLayout();
this.groupBoxARLog.SuspendLayout();
@@ -198,8 +201,6 @@ namespace JDP {
this.grpHDCD.SuspendLayout();
this.tabPage5.SuspendLayout();
this.groupBoxScriptConditions.SuspendLayout();
this.groupBoxAlbumArt.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxResolution)).BeginInit();
this.SuspendLayout();
//
// btnCancel
@@ -557,6 +558,59 @@ namespace JDP {
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Name = "tabPage6";
//
// groupBoxAlbumArt
//
this.groupBoxAlbumArt.Controls.Add(this.checkBoxExtractAlbumArt);
this.groupBoxAlbumArt.Controls.Add(this.labelAlbumArtMaximumResolution);
this.groupBoxAlbumArt.Controls.Add(this.numericUpDownMaxResolution);
this.groupBoxAlbumArt.Controls.Add(this.checkBoxEmbedAlbumArt);
this.groupBoxAlbumArt.Controls.Add(this.checkBoxCopyAlbumArt);
resources.ApplyResources(this.groupBoxAlbumArt, "groupBoxAlbumArt");
this.groupBoxAlbumArt.Name = "groupBoxAlbumArt";
this.groupBoxAlbumArt.TabStop = false;
//
// labelAlbumArtMaximumResolution
//
resources.ApplyResources(this.labelAlbumArtMaximumResolution, "labelAlbumArtMaximumResolution");
this.labelAlbumArtMaximumResolution.Name = "labelAlbumArtMaximumResolution";
//
// numericUpDownMaxResolution
//
this.numericUpDownMaxResolution.Increment = new decimal(new int[] {
100,
0,
0,
0});
resources.ApplyResources(this.numericUpDownMaxResolution, "numericUpDownMaxResolution");
this.numericUpDownMaxResolution.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.numericUpDownMaxResolution.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownMaxResolution.Name = "numericUpDownMaxResolution";
this.numericUpDownMaxResolution.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// checkBoxEmbedAlbumArt
//
resources.ApplyResources(this.checkBoxEmbedAlbumArt, "checkBoxEmbedAlbumArt");
this.checkBoxEmbedAlbumArt.Name = "checkBoxEmbedAlbumArt";
this.checkBoxEmbedAlbumArt.UseVisualStyleBackColor = true;
//
// checkBoxCopyAlbumArt
//
resources.ApplyResources(this.checkBoxCopyAlbumArt, "checkBoxCopyAlbumArt");
this.checkBoxCopyAlbumArt.Name = "checkBoxCopyAlbumArt";
this.checkBoxCopyAlbumArt.UseVisualStyleBackColor = true;
//
// groupBoxTagging
//
this.groupBoxTagging.Controls.Add(this.chkExtractLog);
@@ -570,11 +624,11 @@ namespace JDP {
this.groupBoxTagging.Name = "groupBoxTagging";
this.groupBoxTagging.TabStop = false;
//
// checkBoxEmbedAlbumArt
// chkExtractLog
//
resources.ApplyResources(this.checkBoxEmbedAlbumArt, "checkBoxEmbedAlbumArt");
this.checkBoxEmbedAlbumArt.Name = "checkBoxEmbedAlbumArt";
this.checkBoxEmbedAlbumArt.UseVisualStyleBackColor = true;
resources.ApplyResources(this.chkExtractLog, "chkExtractLog");
this.chkExtractLog.Name = "chkExtractLog";
this.chkExtractLog.UseVisualStyleBackColor = true;
//
// checkBoxCopyBasicTags
//
@@ -582,12 +636,6 @@ namespace JDP {
this.checkBoxCopyBasicTags.Name = "checkBoxCopyBasicTags";
this.checkBoxCopyBasicTags.UseVisualStyleBackColor = true;
//
// checkBoxCopyAlbumArt
//
resources.ApplyResources(this.checkBoxCopyAlbumArt, "checkBoxCopyAlbumArt");
this.checkBoxCopyAlbumArt.Name = "checkBoxCopyAlbumArt";
this.checkBoxCopyAlbumArt.UseVisualStyleBackColor = true;
//
// checkBoxWriteCUETags
//
resources.ApplyResources(this.checkBoxWriteCUETags, "checkBoxWriteCUETags");
@@ -1243,10 +1291,6 @@ namespace JDP {
this.columnHeader6});
this.listViewScriptConditions.FullRowSelect = true;
this.listViewScriptConditions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listViewScriptConditions.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
((System.Windows.Forms.ListViewItem)(resources.GetObject("listViewScriptConditions.Items"))),
((System.Windows.Forms.ListViewItem)(resources.GetObject("listViewScriptConditions.Items1"))),
((System.Windows.Forms.ListViewItem)(resources.GetObject("listViewScriptConditions.Items2")))});
resources.ApplyResources(this.listViewScriptConditions, "listViewScriptConditions");
this.listViewScriptConditions.MultiSelect = false;
this.listViewScriptConditions.Name = "listViewScriptConditions";
@@ -1295,51 +1339,11 @@ namespace JDP {
//
resources.ApplyResources(this.columnHeader2, "columnHeader2");
//
// groupBoxAlbumArt
// checkBoxExtractAlbumArt
//
this.groupBoxAlbumArt.Controls.Add(this.labelAlbumArtMaximumResolution);
this.groupBoxAlbumArt.Controls.Add(this.numericUpDownMaxResolution);
this.groupBoxAlbumArt.Controls.Add(this.checkBoxEmbedAlbumArt);
this.groupBoxAlbumArt.Controls.Add(this.checkBoxCopyAlbumArt);
resources.ApplyResources(this.groupBoxAlbumArt, "groupBoxAlbumArt");
this.groupBoxAlbumArt.Name = "groupBoxAlbumArt";
this.groupBoxAlbumArt.TabStop = false;
//
// chkExtractLog
//
resources.ApplyResources(this.chkExtractLog, "chkExtractLog");
this.chkExtractLog.Name = "chkExtractLog";
this.chkExtractLog.UseVisualStyleBackColor = true;
//
// numericUpDownMaxResolution
//
this.numericUpDownMaxResolution.Increment = new decimal(new int[] {
100,
0,
0,
0});
resources.ApplyResources(this.numericUpDownMaxResolution, "numericUpDownMaxResolution");
this.numericUpDownMaxResolution.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.numericUpDownMaxResolution.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownMaxResolution.Name = "numericUpDownMaxResolution";
this.numericUpDownMaxResolution.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// labelAlbumArtMaximumResolution
//
resources.ApplyResources(this.labelAlbumArtMaximumResolution, "labelAlbumArtMaximumResolution");
this.labelAlbumArtMaximumResolution.Name = "labelAlbumArtMaximumResolution";
resources.ApplyResources(this.checkBoxExtractAlbumArt, "checkBoxExtractAlbumArt");
this.checkBoxExtractAlbumArt.Name = "checkBoxExtractAlbumArt";
this.checkBoxExtractAlbumArt.UseVisualStyleBackColor = true;
//
// frmSettings
//
@@ -1371,6 +1375,9 @@ namespace JDP {
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage6.ResumeLayout(false);
this.groupBoxAlbumArt.ResumeLayout(false);
this.groupBoxAlbumArt.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxResolution)).EndInit();
this.groupBoxTagging.ResumeLayout(false);
this.groupBoxTagging.PerformLayout();
this.tabPage2.ResumeLayout(false);
@@ -1410,9 +1417,6 @@ namespace JDP {
this.grpHDCD.PerformLayout();
this.tabPage5.ResumeLayout(false);
this.groupBoxScriptConditions.ResumeLayout(false);
this.groupBoxAlbumArt.ResumeLayout(false);
this.groupBoxAlbumArt.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxResolution)).EndInit();
this.ResumeLayout(false);
}
@@ -1557,6 +1561,7 @@ namespace JDP {
private System.Windows.Forms.Label labelAlbumArtMaximumResolution;
private System.Windows.Forms.NumericUpDown numericUpDownMaxResolution;
private System.Windows.Forms.CheckBox chkExtractLog;
private System.Windows.Forms.CheckBox checkBoxExtractAlbumArt;
}
}

View File

@@ -87,6 +87,7 @@ namespace JDP {
checkBoxCopyBasicTags.Checked = _config.copyBasicTags;
checkBoxCopyUnknownTags.Checked = _config.copyUnknownTags;
checkBoxCopyAlbumArt.Checked = _config.copyAlbumArt;
checkBoxExtractAlbumArt.Checked = _config.extractAlbumArt;
checkBoxEmbedAlbumArt.Checked = _config.embedAlbumArt;
checkBoxARVerifyUseSourceFolder.Checked = _config.arLogToSourceFolder;
checkBoxARLogVerbose.Checked = _config.arLogVerbose;
@@ -147,6 +148,10 @@ namespace JDP {
item.Tag = script.Value;
listViewScripts.Items.Add(item);
}
ComponentResourceManager resources = new ComponentResourceManager(typeof(frmCUETools));
listViewScriptConditions.Items.Add(resources.GetString("rbActionVerify.Text").Replace("&", ""));
listViewScriptConditions.Items.Add(resources.GetString("rbActionVerifyAndEncode.Text").Replace("&", ""));
listViewScriptConditions.Items.Add(resources.GetString("rbActionEncode.Text").Replace("&", ""));
listViewScriptConditions.Items[0].Tag = CUEAction.Verify;
listViewScriptConditions.Items[1].Tag = CUEAction.VerifyAndConvert;
listViewScriptConditions.Items[2].Tag = CUEAction.Convert;
@@ -244,6 +249,7 @@ namespace JDP {
_config.copyBasicTags = checkBoxCopyBasicTags.Checked;
_config.copyUnknownTags = checkBoxCopyUnknownTags.Checked;
_config.copyAlbumArt = checkBoxCopyAlbumArt.Checked;
_config.extractAlbumArt = checkBoxExtractAlbumArt.Checked;
_config.embedAlbumArt = checkBoxEmbedAlbumArt.Checked;
_config.arLogToSourceFolder = checkBoxARVerifyUseSourceFolder.Checked;

File diff suppressed because it is too large Load Diff