INTERACT FORUM

Please login or register.

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

Author Topic: Can I create separate play lists based on comment field?  (Read 1451 times)

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Can I create separate play lists based on comment field?
« on: November 04, 2003, 01:44:20 am »

I create numbered play lists of my library to control from IR remotes, and I would like to cut down a bit on the work. Is it possible in any way (Media Center or otherwise) to create or export play lists based on the comment filed? I mean one list that contains all tracks marked with 123, named 123.m3u, one for 124 and so on. Can anybody help me with this?

Thanks a lot in advance!
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

Phydeaux

  • Regular Member
  • World Citizen
  • ***
  • Posts: 243
  • No comment... ;)
Re:Can I create separate play lists based on comment field?
« Reply #1 on: November 04, 2003, 04:47:16 am »

I'm not too sure what you're after...

You can always use a smartlist based on the comment field and then export that...

P.
Logged
"Evil will always triumph over Good because Good is dumb." -- Spaceballs

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re:Can I create separate play lists based on comment field?
« Reply #2 on: November 04, 2003, 05:01:18 am »

Yeah, but that would mean that I would have to do that for every single list. What I want to do, is to export the whole lot in one operation. In other words I let MC work for a while exporting one playlist for each comment number (which would be close to 3000 play lists for me now, I've got around 3000 albums).
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

JoshuaHorowitz

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 56
  • nothing more to say... other than that MC rocks!
Re:Can I create separate play lists based on comment field?
« Reply #3 on: November 04, 2003, 03:01:28 pm »

Here's an idea: Use an XSLT parser that can output mutilple files. I assumed that m3u playlists are just lists of filenames.

1: Make an empty folder to store everything in.
2: Install (and start, using the plug-in manager) scott_r's XML export plug-in (see http://yabb.jriver.com/interact/index.php?board=5;action=display;threadid=16536).
3: Make a playlist containing any files that have these special comment fields (perhaps just your whole library).
4: Export this playlist using the plug-in. To do this, look under the "Plug-ins" node at the bottom of the tree. Select "MCXMLExport". Select the playlist you prepared, and make sure only the fields "Comment" and "Filename" are selected under "Select Database Fields". Deselect any checkmark buttons on the right. Press Export, and save the resulting file as "export.xml" in the empty folder you prepared.
5: Download Instant Saxon from http://prdownloads.sourceforge.net/saxon/instant_saxon6_5_3.zip. Unzip the exe file to your previously-empty folder.
6: Copy the following code into Notepad and save the file as "style.xsl". Make sure that you don't save it with a ".txt" extension.
Code: [Select]
<?xml version="1.0"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:key name="comments" match="Field[@Name='Comment']" use="text()" />
<xsl:template match="MPL">
<xsl:apply-templates select="*/Field[generate-id(.)=generate-id(key('comments', text()))]" />
</xsl:template>
<xsl:template match="Field[@Name='Comment']">
<xsl:variable name="comment"><xsl:value-of select="text()"/></xsl:variable>
<xsl:document href="{text()}.m3u" method="text">
<xsl:for-each select="/*//Field[@Name='Filename' and ../Field[@Name='Comment' and text()=$comment]]">
<xsl:value-of select="text()"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:document>
</xsl:template>
</xsl:stylesheet>
6: Enter the MS-DOS command prompt. Navigate to your previously-empty directory. Execute "saxon export.xml style.xsl".

You should have a collection of properly named m3u files (in the folder, of course). I should note that this code is rather delicate though. If the input file is anything but an MCXMLExport-generated XML file with only Comment and Filename exported, it's quite prone to error. Also, I've assumed that the comments have no uglieness (strange symbols or spaces, etc.). Numbers should work fine. Try it.

Hope this helps, and I'd be happy to help if there are any issues!
Joshua
Logged

JoshuaHorowitz

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 56
  • nothing more to say... other than that MC rocks!
Re:Can I create separate play lists based on comment field?
« Reply #4 on: November 04, 2003, 03:05:01 pm »

You know what, in retrospect this looks pretty inelegant.
Tell me how it works though, if you're willing to try.

;D

Good luck!
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re:Can I create separate play lists based on comment field?
« Reply #5 on: November 04, 2003, 03:10:21 pm »

Inelegant? It looks downright scary to me! I might try it tomorrow if I get the time, but only after I have updated the backup of my system... (Don't take it personal, I do that before any larger changes).
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system
Pages: [1]   Go Up