INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Copy Lyrics from one song to another?  (Read 1413 times)

broncodan

  • World Citizen
  • ***
  • Posts: 212
Copy Lyrics from one song to another?
« on: June 09, 2009, 02:28:08 am »

Hi,

I have several songs that are the same (same artist and name) - one of the songs has the lyrics and the other one doesn't.  I want to copy the lyrics to the blank one.  I have several of these 3000+ so was hoping there was an easier or automatic way to do this. 

E.g.  - a smartlist or some other function?

Any help would be great.

Thanks.
Logged

eba

  • Galactic Citizen
  • ****
  • Posts: 351
Re: Copy Lyrics from one song to another?
« Reply #1 on: June 09, 2009, 07:07:53 am »

You could try the Scripting plugin, which would probably allow you to do that...

In fact, because I'm bored and haven't attempted a script for a while...
This should do it:

(I haven't tested this extensively so take no responsibility for it destroying your library...you may want to back it up first :))

Code: [Select]
using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {
        //Search for all song duplicates and sort.
        MediaCenter.IMJFilesAutomation files = mediaCenterInterface.Search("[Media Type]=Audio ~dup[artist],[name] ~sort[artist],[name],[lyrics]-d");
        
        //Check that at least one file has been found.
        if(files.GetNumberFiles()>0)
        {
            System.Console.WriteLine(files.GetNumberFiles() + " files found.");
            //Get the info on the first file.
            MediaCenter.IMJFileAutomation currentFile = files.GetFile(0);
            String name = currentFile.Get("Name",false);
            String artist = currentFile.Get("artist",false);
            String lyrics = currentFile.Get("Lyrics",false);
            
            System.Console.WriteLine("Copying lyrics...");
            //loop through all the files.
            int counter = 1;
            while(counter < files.GetNumberFiles())
            {
                currentFile = files.GetFile(counter);
                //see if this file is the same song as the last one
                if(currentFile.Get("Name",false)== name && currentFile.Get("Artist",false) == artist)
                {
                    //if it is, see if the lyrics field is blank.
                    //By removing this if statement you could make it overwrite regardless
                    //(to make sure that all duplicate songs have identical lyrics)
                    if(currentFile.Get("Lyrics",false) == "")
                    {
                        currentFile.Set("Lyrics",lyrics);
                    }
                }
                //if the song is not the same as the previous one, update the current song information.
                else
                {
                    name = currentFile.Get("Name",false);
                    artist = currentFile.Get("artist",false);
                    lyrics = currentFile.Get("Lyrics",false);
                }
                counter++;
            }  
        }
        else
        {
            System.Console.WriteLine("No files found.");
        }
    }
}

broncodan

  • World Citizen
  • ***
  • Posts: 212
Re: Copy Lyrics from one song to another?
« Reply #2 on: June 09, 2009, 04:52:20 pm »

Awesome.

 I didn't check all of them but I believe that took care of it.  Thanks for the help.
Logged
Pages: [1]   Go Up