You want the YME to do something, but it doesn't do it "out of the box"? Write it yourself. Sounded interesting, so I gave it a go.
As a test, I wanted to see if I could search my library for tracks who's metadata did not contain a URL for album art. (I'm kind of picky about little things like that. When I play a song, I want the album cover to be displayed.) Since the YME automatically attempted to update the metadata with this information when it created my library, I was curious to see how efficient it was.
I assumed that to create a plugin, I was going to have to brush the dust off of some of my old C++ books. It's been a while since I've written C++, but I was up for it. As it turns out, creating a plugin couldn't be easier. The Yahoo team was kind enough to expose almost the entire programming interface through COM components. Better yet, they have created a mechanism by which YME will host an HTML page thereby allowing you to create simple HTML forms and use Javascript to access the Engine's API.
Anyway, I didn't spend much time on it, but I did get some results. The image below is a screen capture of my plugin after if performed the search in my library.
So that you can see how little code I wrote, here's the entire source:
<HTML>
<BODY>
<script language="javascript" src="yme.js"></script>
<object classid="clsid:5F810AFC-BB5F-4416-BE63-E01DD117BD6C" height=90% width=100% id=datagrid VIEWASTEXT>
<PARAM NAME="CheckBoxes" VALUE="0">
<PARAM NAME="ShowAlways" VALUE="1">
<PARAM NAME="FullRowSel" VALUE="0">
</object>
<br><br>
<A href="javascript:startSearch()">Search</a><br>
<script>
datagrid.AddColumn("Artist", 150, 0, 0);
datagrid.AddColumn("Album", 150, 0, 0);
datagrid.AddColumn("Track Title", 150, 0, 0);
function startSearch()
{
mediaDatabase = window.external.MediaDatabase;
allMedia = mediaDatabase.GetAllMedia();
itemIndex = 0;
for( var i = 0; i < allMedia.Count; i++ )
{
media = allMedia.Item( i );
metaData = media.Metadata;
imageUrl = metaData.GetPredefinedValue( METADATA_IMAGE );
if( imageUrl == null || imageUrl.length == 0 )
{
datagrid.AddRow();
datagrid.SetRowData( itemIndex, 10 );
datagrid.SetElement( itemIndex, 0, metaData.GetPredefinedValue( METADATA_ARTIST ) );
datagrid.SetElement( itemIndex, 1, metaData.GetPredefinedValue( METADATA_ALBUM ) );
datagrid.SetElement( itemIndex, 2, metaData.GetPredefinedValue( METADATA_TITLE ) );
itemIndex++;
}
}
}
</script>
</BODY>
</HTML>
I also had to manually add a key to the registry that enabled the "Al's Plugin" item to show up in the left-hand navigation pane of the YME.
All in all, I am pretty impressed. I might just keep it around a little longer.
No comments:
Post a Comment