Import XMCD 1.2 [MM2+3]

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Import XMCD 1.2 [MM2+3]

Post by trixmoto »

This is a script that has been requested...
DazB wrote:I have local copies of the XMCD files (Unix flavoured) for my CD collection which I want to add to MM without physically inserting 2K+ discs
The script imports .xmcd files created by FreeDB, and creates the tracks within your MM library. For more details of the file format, see here.

As always, the installer is available from my website. :)

Code: Select all

'
' MediaMonkey Script
'
' NAME: ImportXMCD 1.2
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 02/09/2007
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately
'
' FIXES: Fixed track titles don't necessarily contain artist names
'
' [ImportXMCD]
' FileName=ImportXMCD.vbs
' ProcName=ImportXMCD
' Order=30
' DisplayName=Import XMCD
' Description=Import tags from xmcd file
' Language=VBScript
' ScriptType=0
'

Option Explicit

Sub ImportXMCD
  'get filename
  Dim dlg : Set dlg = SDB.CommonDialog
  dlg.Filter = "XMCD file|*.*"
  dlg.Flags = cdlOFNOverwritePrompt + cdlOFNHideReadOnly + cdlOFNNoChangeDir
  dlg.InitDir = SDB.MyMusicPath
  dlg.ShowOpen
  If Not dlg.Ok Then 
    Exit Sub 
  End If

  'read file
  Dim alb : alb = ""
  Dim art : art = ""
  Dim yea : yea = ""
  Dim gen : gen = ""
  Dim tra : tra = 0
  Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  Dim txt : Set txt = fso.OpenTextFile(dlg.FileName,1,False)
  Do While Not txt.AtEndOfStream
    Dim str : str = Trim(txt.ReadLine)
    If Left(str,1) = "#" Then
      'comment
    Else
      Dim pos : pos = InStr(str,"=")
      If pos > 0 Then
        Dim tag : tag = Left(str,pos-1)
        Dim val : val = Mid(str,pos+1)
        Select Case Left(tag,4)
          Case "DTIT"
            art = Left(val,InStr(val," / ")-1) 
            alb = Mid(val,InStr(val," / ")+3)
          Case "DYEA"
            yea = val
          Case "DGEN"      
            gen = val
          Case "TTIT"
            tra = tra + 1
            Dim itm : Set itm = SDB.NewSongData
            itm.AlbumName = alb
            itm.AlbumArtistName = art
            itm.Year = yea
            itm.Genre = gen
            If InStr(val," / ") > 0 Then
              itm.Title = Mid(val,InStr(val," / ")+3)
              itm.ArtistName = Left(val,InStr(val," / ")-1)
            Else
              itm.Title = val
              itm.ArtistName = art
            End If
            itm.TrackOrder = tra
            itm.UpdateArtist
            itm.UpdateAlbum
            itm.UpdateDB           
        End Select        
      End If
    End If
  Loop
  txt.close
  Call SDB.MessageBox("ImportXMCD: "&tra&" tracks successfully created.",mtInformation,Array(mbOk))
End Sub
Last edited by trixmoto on Tue Sep 04, 2007 3:38 am, edited 1 time in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

New version (1.1) is now available to download from my website. Changes include...

- Fixed xmcd files don't necessarily have that extension
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
DazB
Posts: 409
Joined: Mon Jun 11, 2007 4:09 am
Location: Yorkshire, UK

Post by DazB »

Hi,

I would like to say a big thank you to trixmoto for looking into this.

There's a bit more to add to it yet though, so 'hold you horses' ;)

Daz
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

New version (1.2) is now available to download from my website. I have fixed the fact that the track details does not need to contain an artist name, so if it's doesn't then the album artist name is used.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

An MM3 installation package is now available from my website for this script.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
maxwelledison999
Posts: 4
Joined: Tue Jul 19, 2011 1:47 pm

Re: Import XMCD 1.2 [MM2+3]

Post by maxwelledison999 »

Hi,

I just installed the script and am getting the following errors:

First error dialogue:


Error #5 - VBScript runtime error
Invalid procedure call or argument: 'Left'
File "C:\Program Files(x86)\Mediamonkey\Scripts\ImportXMCD.vbs",Line:56, Column:12


Close the above then get:

Error happened during script execution:
Invalid procedure call or argument: 'Left'

I looked in the script and the 'Left' procedure is at that location. And Left is a valid VBScript procedure, so I don't know what the problem is. I was importing an xmcd from Freedb.

regards,
Stephen
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Import XMCD 1.2 [MM2+3]

Post by trixmoto »

Can you post the file contents of the file you were trying to import?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
~Maxx
Posts: 16
Joined: Thu Apr 07, 2011 11:21 pm

Re: Import XMCD 1.2 [MM2+3]

Post by ~Maxx »

I'm getting the same runtime error as above for certain xmcd files from freedb.org. Here is the most recent...

Code: Select all

# xmcd CD Database Entry
#
# Track frame offsets:
# 150
# 62025
# 96225
# 120750
# 144600
#
# Disc length: 2677 seconds
#
# Revision: 2
# Processed by: cddbd v1.5.2PL0 Copyright (c) Steve Scherf et al.
# Submitted via: tcd 2.0b
#
DISCID=3d0a7305
DTITLE=Pink Floyd - Wish you were here
DYEAR=
DGENRE=
TTITLE0=Shine you Crazy Diamond (Part I)
TTITLE1=Welcome To The Machine
TTITLE2=Have a Cigar
TTITLE3=Wish You Were Here
TTITLE4=Shine you Crazy Diamond (Part II)
EXTD=
EXTT0=
EXTT1=
EXTT2=
EXTT3=
EXTT4=
PLAYORDER=
I noticed that in the above xmcd file the artist and album title are separated by a "-", while in other xmcd files (which work properly with this script) these values are separated by a "/". I am not a coder by any stretch of the imagination - but I see that the term "left" in this script seems to refer to which side of the "/" the album artist is located on. So in order to fix things I could edit a line in the xmcd file from "DTITLE=Pink Floyd - Wish you were here" to "DTITLE=Pink Floyd / Wish you were here". Though this "case-by-case" solution is not quite as efficient as something the script author could come up with - it does work in a pinch. Really - the problem is that freedb.org does not have a rock solid standard for their xmcd files. 8) Something to watch out for...
~Maxx
Posts: 16
Joined: Thu Apr 07, 2011 11:21 pm

Re: Import XMCD 1.2 [MM2+3]

Post by ~Maxx »

Just an FYI. A friend of mine (at my request, and with the authors permission) has written a modified version of this script titled "Import XMCD Plus". It includes some rather handy refinements. I have posted it here in case anyone else is interested in using it.
Post Reply