INTERACT FORUM
More => Old Versions => Media Center 13 (Development Ended) => Topic started by: broncodan 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.
-
You could try the Scripting plugin (http://yabb.jriver.com/interact/index.php?topic=38693.0), 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 :))
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.");
}
}
}
-
Awesome.
I didn't check all of them but I believe that took care of it. Thanks for the help.