From: <sa...@us...> - 2007-11-08 15:09:54
|
Revision: 1040 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1040&view=rev Author: saamand Date: 2007-11-08 07:09:51 -0800 (Thu, 08 Nov 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs Added Paths: ----------- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.Designer.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.resx trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.Designer.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.resx Removed Paths: ------------- trunk/plugins/MyLyrics/LyricsEngine/bin/ trunk/plugins/MyLyrics/LyricsEngine/obj/ trunk/plugins/MyLyrics/MusicDatabaseV8.db3 trunk/plugins/MyLyrics/MyLyric Windows Application/ Deleted: trunk/plugins/MyLyrics/MusicDatabaseV8.db3 =================================================================== (Binary files differ) Modified: trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs 2007-11-08 11:02:03 UTC (rev 1039) +++ trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs 2007-11-08 15:09:51 UTC (rev 1040) @@ -56,20 +56,6 @@ } - public static string LookUpLyricInDatabase(LyricsDatabase lyricDB, string artist, string title) - { - string lyricText = ""; - try - { - lyricText = lyricDB[CorrectKeyFormat(LyricUtil.CapatalizeString(artist), LyricUtil.CapatalizeString(title))].Lyrics; - return lyricText.Replace("\n", "\r\n"); - } - catch - { - return lyricText; - } - } - public static string CorrectKeyFormat(string artist, string title) { return artist + "-" + title; Added: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.Designer.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.Designer.cs (rev 0) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.Designer.cs 2007-11-08 15:09:51 UTC (rev 1040) @@ -0,0 +1,221 @@ +namespace MyLyrics +{ + partial class ExportTags + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.lbInfo = new System.Windows.Forms.Label(); + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.bw = new System.ComponentModel.BackgroundWorker(); + this.btStart = new System.Windows.Forms.Button(); + this.gbMusicDBSearchStats = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.lbSongsToSearch2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbSongsToSearch = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbTotalSongs2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbTotalSongs = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbLyricsFound2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbLyricsFound = new MediaPortal.UserInterface.Controls.MPLabel(); + this.btCancel = new System.Windows.Forms.Button(); + this.btClose = new System.Windows.Forms.Button(); + this.lbCurrentArtist = new System.Windows.Forms.Label(); + this.gbMusicDBSearchStats.SuspendLayout(); + this.SuspendLayout(); + // + // lbInfo + // + this.lbInfo.AutoSize = true; + this.lbInfo.Location = new System.Drawing.Point(10, 12); + this.lbInfo.Name = "lbInfo"; + this.lbInfo.Size = new System.Drawing.Size(30, 13); + this.lbInfo.TabIndex = 0; + this.lbInfo.Text = "[text]"; + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(13, 53); + this.progressBar.Maximum = 1000; + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(249, 23); + this.progressBar.Step = 1; + this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.progressBar.TabIndex = 1; + // + // bw + // + this.bw.WorkerReportsProgress = true; + this.bw.WorkerSupportsCancellation = true; + this.bw.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bw_DoWork); + this.bw.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bw_RunWorkerCompleted); + this.bw.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bw_ProgressChanged); + // + // btStart + // + this.btStart.Location = new System.Drawing.Point(13, 166); + this.btStart.Name = "btStart"; + this.btStart.Size = new System.Drawing.Size(66, 23); + this.btStart.TabIndex = 2; + this.btStart.Text = "Start"; + this.btStart.UseVisualStyleBackColor = true; + this.btStart.Click += new System.EventHandler(this.btStart_Click); + // + // gbMusicDBSearchStats + // + this.gbMusicDBSearchStats.Controls.Add(this.lbSongsToSearch2); + this.gbMusicDBSearchStats.Controls.Add(this.lbSongsToSearch); + this.gbMusicDBSearchStats.Controls.Add(this.lbTotalSongs2); + this.gbMusicDBSearchStats.Controls.Add(this.lbTotalSongs); + this.gbMusicDBSearchStats.Controls.Add(this.lbLyricsFound2); + this.gbMusicDBSearchStats.Controls.Add(this.lbLyricsFound); + this.gbMusicDBSearchStats.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.gbMusicDBSearchStats.Location = new System.Drawing.Point(13, 86); + this.gbMusicDBSearchStats.Name = "gbMusicDBSearchStats"; + this.gbMusicDBSearchStats.Size = new System.Drawing.Size(249, 71); + this.gbMusicDBSearchStats.TabIndex = 13; + this.gbMusicDBSearchStats.TabStop = false; + this.gbMusicDBSearchStats.Text = "Search stats"; + // + // lbSongsToSearch2 + // + this.lbSongsToSearch2.Location = new System.Drawing.Point(173, 31); + this.lbSongsToSearch2.Name = "lbSongsToSearch2"; + this.lbSongsToSearch2.Size = new System.Drawing.Size(65, 15); + this.lbSongsToSearch2.TabIndex = 33; + this.lbSongsToSearch2.Text = "-"; + // + // lbSongsToSearch + // + this.lbSongsToSearch.Location = new System.Drawing.Point(5, 30); + this.lbSongsToSearch.Name = "lbSongsToSearch"; + this.lbSongsToSearch.Size = new System.Drawing.Size(140, 16); + this.lbSongsToSearch.TabIndex = 32; + this.lbSongsToSearch.Text = "Songs left to search:"; + // + // lbTotalSongs2 + // + this.lbTotalSongs2.Location = new System.Drawing.Point(172, 15); + this.lbTotalSongs2.Name = "lbTotalSongs2"; + this.lbTotalSongs2.Size = new System.Drawing.Size(65, 15); + this.lbTotalSongs2.TabIndex = 21; + this.lbTotalSongs2.Text = "-"; + // + // lbTotalSongs + // + this.lbTotalSongs.Location = new System.Drawing.Point(4, 15); + this.lbTotalSongs.Name = "lbTotalSongs"; + this.lbTotalSongs.Size = new System.Drawing.Size(91, 15); + this.lbTotalSongs.TabIndex = 20; + this.lbTotalSongs.Text = "Total songs:"; + // + // lbLyricsFound2 + // + this.lbLyricsFound2.Location = new System.Drawing.Point(173, 46); + this.lbLyricsFound2.Name = "lbLyricsFound2"; + this.lbLyricsFound2.Size = new System.Drawing.Size(65, 15); + this.lbLyricsFound2.TabIndex = 15; + this.lbLyricsFound2.Text = "-"; + // + // lbLyricsFound + // + this.lbLyricsFound.Location = new System.Drawing.Point(5, 46); + this.lbLyricsFound.Name = "lbLyricsFound"; + this.lbLyricsFound.Size = new System.Drawing.Size(162, 15); + this.lbLyricsFound.TabIndex = 14; + this.lbLyricsFound.Text = "Lyrics exported:"; + // + // btCancel + // + this.btCancel.Location = new System.Drawing.Point(85, 166); + this.btCancel.Name = "btCancel"; + this.btCancel.Size = new System.Drawing.Size(66, 23); + this.btCancel.TabIndex = 14; + this.btCancel.Text = "Cancel"; + this.btCancel.UseVisualStyleBackColor = true; + this.btCancel.Click += new System.EventHandler(this.btCancel_Click); + // + // btClose + // + this.btClose.Location = new System.Drawing.Point(196, 166); + this.btClose.Name = "btClose"; + this.btClose.Size = new System.Drawing.Size(66, 23); + this.btClose.TabIndex = 15; + this.btClose.Text = "Close"; + this.btClose.UseVisualStyleBackColor = true; + this.btClose.Click += new System.EventHandler(this.btClose_Click); + // + // lbCurrentArtist + // + this.lbCurrentArtist.AutoSize = true; + this.lbCurrentArtist.Location = new System.Drawing.Point(10, 25); + this.lbCurrentArtist.Name = "lbCurrentArtist"; + this.lbCurrentArtist.Size = new System.Drawing.Size(71, 13); + this.lbCurrentArtist.TabIndex = 16; + this.lbCurrentArtist.Text = "[current artist]"; + // + // ExportTags + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(272, 193); + this.ControlBox = false; + this.Controls.Add(this.lbCurrentArtist); + this.Controls.Add(this.btClose); + this.Controls.Add(this.btCancel); + this.Controls.Add(this.gbMusicDBSearchStats); + this.Controls.Add(this.btStart); + this.Controls.Add(this.progressBar); + this.Controls.Add(this.lbInfo); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ExportTags"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Export lyrics to music tags"; + this.gbMusicDBSearchStats.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbInfo; + private System.Windows.Forms.ProgressBar progressBar; + private System.ComponentModel.BackgroundWorker bw; + private System.Windows.Forms.Button btStart; + private MediaPortal.UserInterface.Controls.MPGroupBox gbMusicDBSearchStats; + private MediaPortal.UserInterface.Controls.MPLabel lbSongsToSearch2; + private MediaPortal.UserInterface.Controls.MPLabel lbSongsToSearch; + private MediaPortal.UserInterface.Controls.MPLabel lbTotalSongs2; + private MediaPortal.UserInterface.Controls.MPLabel lbTotalSongs; + private MediaPortal.UserInterface.Controls.MPLabel lbLyricsFound2; + private MediaPortal.UserInterface.Controls.MPLabel lbLyricsFound; + private System.Windows.Forms.Button btCancel; + private System.Windows.Forms.Button btClose; + private System.Windows.Forms.Label lbCurrentArtist; + } +} \ No newline at end of file Added: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.cs (rev 0) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.cs 2007-11-08 15:09:51 UTC (rev 1040) @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using MediaPortal.Music.Database; +using MediaPortal.TagReader; +using System.Collections; +using System.Threading; +using System.IO; + +namespace MyLyrics +{ + public partial class ExportTags : Form + { + ArrayList artists; + List<Song> songs; + int totalSongsToSearch; + int totalSongsSearched; + + public ExportTags() + { + InitializeComponent(); + this.lbInfo.Text = "Press the 'Start'-button to begin the export"; + this.lbCurrentArtist.Text = "Note that the export cannot be undone"; + } + + private void btStart_Click(object sender, EventArgs e) + { + lbInfo.Text = string.Format("Currently exporting tags to the tracks of:"); + + btStart.Enabled = false; + btCancel.Enabled = true; + btClose.Enabled = false; + + MusicDatabase mDB = MusicDatabase.Instance; + artists = new ArrayList(); + songs = new List<Song>(); + mDB.GetArtists(0, "", ref artists); + artists.Sort(); + + progressBar.ResetText(); + progressBar.Enabled = true; + progressBar.Value = 0; + progressBar.Maximum = artists.Count; + totalSongsToSearch = mDB.GetTotalSongs(); + lbTotalSongs2.Text = totalSongsToSearch.ToString(); + + bw.RunWorkerAsync(); + } + + private void bw_DoWork(object sender, DoWorkEventArgs e) + { + MusicDatabase mDB = MusicDatabase.Instance; + int counter = 0; + + for (int i = 0; i < artists.Count; i++) + { + if (bw.CancellationPending) + { + return; + } + + string artist = (string)artists[i]; + Thread.Sleep(100); // Give the GUI thread some time to update + bw.ReportProgress(counter, artist); + try + { + mDB.GetSongsByArtist(artist, ref songs); + + foreach (Song song in songs) + { + string capArtist = LyricsEngine.LyricUtil.CapatalizeString(song.Artist); + string capTitle = LyricsEngine.LyricUtil.CapatalizeString(song.Title); + + if (DatabaseUtil.IsTrackInLyricsDatabase(MyLyricsSettings.LyricsDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_FOUND)) + { + if (!Path.GetExtension(song.FileName).Equals(".wma", StringComparison.InvariantCultureIgnoreCase)) + { + string lyric = MyLyricsSettings.LyricsDB[DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)].Lyrics; + bool test = TagReader.WriteLyrics(song.FileName, lyric); + ++counter; + } + } + } + } + catch (Exception e2) + { + string s = e2.Message; + } + } + } + + private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + MusicDatabase mDB = MusicDatabase.Instance; + string artist = e.UserState as string; + List<Song> songs = new List<Song>(); + mDB.GetSongsByArtist(artist, ref songs); + totalSongsSearched += songs.Count; + lbCurrentArtist.Text = artist; + progressBar.PerformStep(); + lbLyricsFound2.Text = e.ProgressPercentage.ToString(); + lbSongsToSearch2.Text = string.Format("{0}", totalSongsToSearch - totalSongsSearched); + } + + + private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + lbSongsToSearch2.Text = "0"; + + lbInfo.Text = "The export has ended."; + lbCurrentArtist.Text = string.Empty; + + btStart.Enabled = true; + btCancel.Enabled = false; + btClose.Enabled = true; + } + + private void btCancel_Click(object sender, EventArgs e) + { + bw.CancelAsync(); + progressBar.ResetText(); + progressBar.Value = 0; + } + + private void btClose_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} \ No newline at end of file Added: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.resx =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.resx (rev 0) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.resx 2007-11-08 15:09:51 UTC (rev 1040) @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="bw.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>24, -1</value> + </metadata> +</root> \ No newline at end of file Added: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.Designer.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.Designer.cs (rev 0) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.Designer.cs 2007-11-08 15:09:51 UTC (rev 1040) @@ -0,0 +1,221 @@ +namespace MyLyrics +{ + partial class ImportTags + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.lbInfo = new System.Windows.Forms.Label(); + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.bw = new System.ComponentModel.BackgroundWorker(); + this.btStart = new System.Windows.Forms.Button(); + this.gbMusicDBSearchStats = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.lbSongsToSearch2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbSongsToSearch = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbTotalSongs2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbTotalSongs = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbLyricsFound2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.lbLyricsFound = new MediaPortal.UserInterface.Controls.MPLabel(); + this.btCancel = new System.Windows.Forms.Button(); + this.btClose = new System.Windows.Forms.Button(); + this.lbCurrentArtist = new System.Windows.Forms.Label(); + this.gbMusicDBSearchStats.SuspendLayout(); + this.SuspendLayout(); + // + // lbInfo + // + this.lbInfo.AutoSize = true; + this.lbInfo.Location = new System.Drawing.Point(10, 12); + this.lbInfo.Name = "lbInfo"; + this.lbInfo.Size = new System.Drawing.Size(30, 13); + this.lbInfo.TabIndex = 0; + this.lbInfo.Text = "[text]"; + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(13, 53); + this.progressBar.Maximum = 1000; + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(249, 23); + this.progressBar.Step = 1; + this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.progressBar.TabIndex = 1; + // + // bw + // + this.bw.WorkerReportsProgress = true; + this.bw.WorkerSupportsCancellation = true; + this.bw.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bw_DoWork); + this.bw.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bw_RunWorkerCompleted); + this.bw.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bw_ProgressChanged); + // + // btStart + // + this.btStart.Location = new System.Drawing.Point(13, 166); + this.btStart.Name = "btStart"; + this.btStart.Size = new System.Drawing.Size(66, 23); + this.btStart.TabIndex = 2; + this.btStart.Text = "Start"; + this.btStart.UseVisualStyleBackColor = true; + this.btStart.Click += new System.EventHandler(this.btStart_Click); + // + // gbMusicDBSearchStats + // + this.gbMusicDBSearchStats.Controls.Add(this.lbSongsToSearch2); + this.gbMusicDBSearchStats.Controls.Add(this.lbSongsToSearch); + this.gbMusicDBSearchStats.Controls.Add(this.lbTotalSongs2); + this.gbMusicDBSearchStats.Controls.Add(this.lbTotalSongs); + this.gbMusicDBSearchStats.Controls.Add(this.lbLyricsFound2); + this.gbMusicDBSearchStats.Controls.Add(this.lbLyricsFound); + this.gbMusicDBSearchStats.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.gbMusicDBSearchStats.Location = new System.Drawing.Point(13, 86); + this.gbMusicDBSearchStats.Name = "gbMusicDBSearchStats"; + this.gbMusicDBSearchStats.Size = new System.Drawing.Size(249, 71); + this.gbMusicDBSearchStats.TabIndex = 13; + this.gbMusicDBSearchStats.TabStop = false; + this.gbMusicDBSearchStats.Text = "Search stats"; + // + // lbSongsToSearch2 + // + this.lbSongsToSearch2.Location = new System.Drawing.Point(173, 31); + this.lbSongsToSearch2.Name = "lbSongsToSearch2"; + this.lbSongsToSearch2.Size = new System.Drawing.Size(65, 15); + this.lbSongsToSearch2.TabIndex = 33; + this.lbSongsToSearch2.Text = "-"; + // + // lbSongsToSearch + // + this.lbSongsToSearch.Location = new System.Drawing.Point(5, 30); + this.lbSongsToSearch.Name = "lbSongsToSearch"; + this.lbSongsToSearch.Size = new System.Drawing.Size(140, 16); + this.lbSongsToSearch.TabIndex = 32; + this.lbSongsToSearch.Text = "Songs left to search:"; + // + // lbTotalSongs2 + // + this.lbTotalSongs2.Location = new System.Drawing.Point(172, 15); + this.lbTotalSongs2.Name = "lbTotalSongs2"; + this.lbTotalSongs2.Size = new System.Drawing.Size(65, 15); + this.lbTotalSongs2.TabIndex = 21; + this.lbTotalSongs2.Text = "-"; + // + // lbTotalSongs + // + this.lbTotalSongs.Location = new System.Drawing.Point(4, 15); + this.lbTotalSongs.Name = "lbTotalSongs"; + this.lbTotalSongs.Size = new System.Drawing.Size(91, 15); + this.lbTotalSongs.TabIndex = 20; + this.lbTotalSongs.Text = "Total songs:"; + // + // lbLyricsFound2 + // + this.lbLyricsFound2.Location = new System.Drawing.Point(173, 46); + this.lbLyricsFound2.Name = "lbLyricsFound2"; + this.lbLyricsFound2.Size = new System.Drawing.Size(65, 15); + this.lbLyricsFound2.TabIndex = 15; + this.lbLyricsFound2.Text = "-"; + // + // lbLyricsFound + // + this.lbLyricsFound.Location = new System.Drawing.Point(5, 46); + this.lbLyricsFound.Name = "lbLyricsFound"; + this.lbLyricsFound.Size = new System.Drawing.Size(162, 15); + this.lbLyricsFound.TabIndex = 14; + this.lbLyricsFound.Text = "Lyrics found in tags:"; + // + // btCancel + // + this.btCancel.Location = new System.Drawing.Point(85, 166); + this.btCancel.Name = "btCancel"; + this.btCancel.Size = new System.Drawing.Size(66, 23); + this.btCancel.TabIndex = 14; + this.btCancel.Text = "Cancel"; + this.btCancel.UseVisualStyleBackColor = true; + this.btCancel.Click += new System.EventHandler(this.btCancel_Click); + // + // btClose + // + this.btClose.Location = new System.Drawing.Point(196, 166); + this.btClose.Name = "btClose"; + this.btClose.Size = new System.Drawing.Size(66, 23); + this.btClose.TabIndex = 15; + this.btClose.Text = "Close"; + this.btClose.UseVisualStyleBackColor = true; + this.btClose.Click += new System.EventHandler(this.btClose_Click); + // + // lbCurrentArtist + // + this.lbCurrentArtist.AutoSize = true; + this.lbCurrentArtist.Location = new System.Drawing.Point(10, 25); + this.lbCurrentArtist.Name = "lbCurrentArtist"; + this.lbCurrentArtist.Size = new System.Drawing.Size(71, 13); + this.lbCurrentArtist.TabIndex = 16; + this.lbCurrentArtist.Text = "[current artist]"; + // + // ImportTags + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(272, 193); + this.ControlBox = false; + this.Controls.Add(this.lbCurrentArtist); + this.Controls.Add(this.btClose); + this.Controls.Add(this.btCancel); + this.Controls.Add(this.gbMusicDBSearchStats); + this.Controls.Add(this.btStart); + this.Controls.Add(this.progressBar); + this.Controls.Add(this.lbInfo); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportTags"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Import lyrics from music tags"; + this.gbMusicDBSearchStats.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbInfo; + private System.Windows.Forms.ProgressBar progressBar; + private System.ComponentModel.BackgroundWorker bw; + private System.Windows.Forms.Button btStart; + private MediaPortal.UserInterface.Controls.MPGroupBox gbMusicDBSearchStats; + private MediaPortal.UserInterface.Controls.MPLabel lbSongsToSearch2; + private MediaPortal.UserInterface.Controls.MPLabel lbSongsToSearch; + private MediaPortal.UserInterface.Controls.MPLabel lbTotalSongs2; + private MediaPortal.UserInterface.Controls.MPLabel lbTotalSongs; + private MediaPortal.UserInterface.Controls.MPLabel lbLyricsFound2; + private MediaPortal.UserInterface.Controls.MPLabel lbLyricsFound; + private System.Windows.Forms.Button btCancel; + private System.Windows.Forms.Button btClose; + private System.Windows.Forms.Label lbCurrentArtist; + } +} \ No newline at end of file Added: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.cs (rev 0) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.cs 2007-11-08 15:09:51 UTC (rev 1040) @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using MediaPortal.Music.Database; +using MediaPortal.TagReader; +using System.Collections; + +namespace MyLyrics +{ + public partial class ImportTags : Form + { + List<MusicTag> tags; + ArrayList artists; + List<Song> songs; + int totalSongsToSearch; + int totalSongsSearched; + + public ImportTags() + { + InitializeComponent(); + this.lbInfo.Text = "Press the 'Start'-button to begin the import"; + this.lbCurrentArtist.Text = string.Empty; + } + + private void btStart_Click(object sender, EventArgs e) + { + lbInfo.Text = string.Format("Currently checking music tags for:"); + + btStart.Enabled = false; + btCancel.Enabled = true; + btClose.Enabled = false; + + MusicDatabase mDB = MusicDatabase.Instance; + tags = new List<MusicTag>(); + artists = new ArrayList(); + songs = new List<Song>(); + mDB.GetArtists(0, "", ref artists); + artists.Sort(); + + progressBar.ResetText(); + progressBar.Enabled = true; + progressBar.Value = 0; + progressBar.Maximum = artists.Count; + totalSongsToSearch = mDB.GetTotalSongs(); + lbTotalSongs2.Text = totalSongsToSearch.ToString(); + + bw.RunWorkerAsync(); + } + + private void bw_DoWork(object sender, DoWorkEventArgs e) + { + MusicDatabase mDB = MusicDatabase.Instance; + int counter = 0; + + for (int i = 0; i < artists.Count; i++) + { + if (bw.CancellationPending) + { + return; + } + + string artist = (string)artists[i]; + bw.ReportProgress(counter, artist); + try + { + mDB.GetSongsByArtist(artist, ref songs); + + foreach (Song song in songs) + { + MusicTag tag = TagReader.ReadTag(song.FileName); + if (tag.Lyrics != string.Empty) + { + tags.Add(tag); + ++counter; + } + } + } + catch (Exception e2) + { + string s = e2.Message; + } + } + } + + private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + MusicDatabase mDB = MusicDatabase.Instance; + string artist = e.UserState as string; + List<Song> songs = new List<Song>(); + mDB.GetSongsByArtist(artist, ref songs); + totalSongsSearched += songs.Count; + lbCurrentArtist.Text = artist; + progressBar.PerformStep(); + lbLyricsFound2.Text = e.ProgressPercentage.ToString(); + lbSongsToSearch2.Text = string.Format("{0}", totalSongsToSearch - totalSongsSearched); + } + + + private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + lbSongsToSearch2.Text = "0"; + if (tags.Count > 0) + { + DialogResult dlgResult = MessageBox.Show(string.Format("{0} lyric were found in the search.{1}Do you want to import these into your lyrics database?", tags.Count, Environment.NewLine), "Import tags", MessageBoxButtons.YesNo); + if (dlgResult.Equals(DialogResult.Yes)) + { + foreach (MusicTag tag in tags) + { + string capArtist = LyricsEngine.LyricUtil.CapatalizeString(tag.Artist); + string capTitle = LyricsEngine.LyricUtil.CapatalizeString(tag.Title); + DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsSettings.LyricsDB, capArtist, capTitle, tag.Lyrics, "music tag"); + } + DatabaseUtil.SerializeLyricDB(); + } + } + + lbInfo.Text = "The search has ended."; + lbCurrentArtist.Text = string.Empty; + + btStart.Enabled = true; + btCancel.Enabled = false; + btClose.Enabled = true; + } + + private void btCancel_Click(object sender, EventArgs e) + { + bw.CancelAsync(); + progressBar.ResetText(); + progressBar.Value = 0; + } + + private void btClose_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} \ No newline at end of file Added: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.resx =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.resx (rev 0) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.resx 2007-11-08 15:09:51 UTC (rev 1040) @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="bw.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>24, -1</value> + </metadata> +</root> \ No newline at end of file Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-11-08 11:02:03 UTC (rev 1039) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-11-08 15:09:51 UTC (rev 1040) @@ -588,7 +588,7 @@ // 1) + 2) Check if LRC in music tag or Database - string lyricText = MyLyrics.DatabaseUtil.LookUpLyricInDatabase(LyricsDB, m_artist, m_title); + string lyricText = LyricsDB[CorrectKeyFormat(m_artist, m_title)].Lyrics; if ((CurrentTrackTag.Lyrics.Length != 0 && (lrc = new SimpleLRC(m_artist, m_title, CurrentTrackTag.Lyrics)).IsValid) || (lyricText.Length != 0 && (lrc = new SimpleLRC(m_artist, m_title, lyricText)).IsValid)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |