import script

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

Moderators: Peke, Gurus

Felix Atagong
Posts: 81
Joined: Mon Apr 21, 2003 6:38 am
Location: Belgium
Contact:

import script

Post by Felix Atagong »

Hiya'all after a very long time! :-?

Has anyone tried to make an import script? I'm currently listening to an (excellent) blues anthology that has 100 songs and about 95 different artists but that is not present in the freedb database.

I can add the tracks automatically in the database giving each cd a name, but with each tracks titled as track1, track 2, and so on, and with each artist as 'unknown'.

I also have a text file listing the title and performer of every track that I can easily convert to Access.

Is it possible to write a script that will scan the MM database for every artist 'unknown' and that then will add the right performer and songtitle from the separate mdb file I have?

Just wondering...

NP: Century Of The Blues CD1 Mississippi Delta Pioneers
Felix Atagong
http://atagong.com
Lowlander
Posts: 56654
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Post by Lowlander »

That would be possible. You just need to figure out how to select the right artist/album/song for the right unknown artist in the DB. That is probably the biggest challenge.
AlanB

try this

Post by AlanB »

How much this will help depends on whether you can put together the bits that go around it.
It is also not elegant, so someone may have a tidier solution, but since there is nothing posted as yet, this might be of use...

I did something similar and just put together a quick vbs script for MM something like this in a file called Namer.vbs

Option Explicit
Sub Namer
Dim result
Dim names(6, 2) ' change first index to suit number of tracks
Dim list, itm, i, OldTitle, NewTitle, NewArtistName

names( 0,0) = "Natural Born Boogie"
names( 0,1) = "Humble Pie"
names( 1,0) = "(If Paradise Is) Half as Nice"
names( 1,1) = "Amen Corner"
names( 2,0) = "Lazy Sunday"
names( 2,1) = "Small Faces"
names( 3,0) = "Man of the World"
names( 3,1) = "Fleetwood Mac"
names( 4,0) = "(Call Me) Number One"
names( 4,1) = "Tremeloes"
names( 5,0) = "I'm the Urban Spaceman"
names( 5,1) = "Bonzo Dog Doo-Dah Band"

' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList

' The following 4 lines provide an alternative...
' If nothing is selected, then select all in current node
'Set list = SDB.SelectedSongList
'If list.count=0 Then
' Set list = SDB.AllVisibleSongList
'End If

' Process all selected tracks
For i = 0 To list.Count - 1
Set itm = list.Item(i)

itm.Title = Trim(names(i, 0))
itm.ArtistName = Trim(names(i, 1))
itm.UpdateDb
Next

End Sub


The list you edit in can be as long as you want, I had one with 175 tracks.

You will need something suitable in your .ini file to make the script available


[Namer]
FileName=Namer.vbs
ProcName=Namer
Order=1
DisplayName=Namer
Description=Names selected songs
Language=VBScript
ScriptType=1


Having set these up, backup your database (just in case it all goes horribly wrong).
Open MM, import the CD.
Now get the tracks in view, make sure they are in track number order and select them. Now run the script and job done.

Probably the tricky bit is getting from your track list to the name declaration format. I used an old macro editor which I am familiar with. If you are a programmer, you might have something similar. Alternatively, it ought to be possible to get the macro to read the information from a file in a simple format (which is probably what you have), but I don't have an example to help you.

You could probably do something similar using vb in Access.

Hope this is some help, AlanB
Guest

Post by Guest »

Using vba in Access itself had already crossed my mind, but I thought it was perhaps a little simplier in MM itself.
Thanks for the ideas!
Felix Atagong
Posts: 81
Joined: Mon Apr 21, 2003 6:38 am
Location: Belgium
Contact:

Post by Felix Atagong »

Anonymous wrote:Using vba in Access itself had already crossed my mind, but I thought it was perhaps a little simplier in MM itself.
Thanks for the ideas!
That was a post by me, I forget to log in, sorry.
Felix Atagong
http://atagong.com
Felix Atagong
Posts: 81
Joined: Mon Apr 21, 2003 6:38 am
Location: Belgium
Contact:

Post by Felix Atagong »

Lowlander wrote:That would be possible. You just need to figure out how to select the right artist/album/song for the right unknown artist in the DB. That is probably the biggest challenge.
Working album by album would be the easiest, I guess, then you only have to replace track1 by the songtitle and artist of track 1 and so on. Of course this only works when there is only 1 'unknown' album in the database at the time.
Felix Atagong
http://atagong.com
Felix Atagong
Posts: 81
Joined: Mon Apr 21, 2003 6:38 am
Location: Belgium
Contact:

Re: try this

Post by Felix Atagong »

AlanB wrote:I did something similar and just put together a quick vbs script for MM something like this in a file called Namer.vbs

[Namer]
ScriptType=1
AlanB, your script works just fine, I just changed ScriptType=1 to 0 to have your script available on the menu.

What I did (this could be helpful to others, I hope).
I scanned the CD booklet and OCR'd it using a freeware version of ABYY Finereader 5.0 Pro which I saved as an Excel sheet.

This gave me a string per track as follows (I placed it in the B column):
13 BARRELHOUSE BLUES - ED ANDREWS (as an example this title is on line 13 in my Excel sheet)

I then divided the title from the artist using the following formula's:
A column to give me the track number (to sort afterwards): =VALUE(LEFT(B13;C13))
C column used to find the position where the title starts: =FIND(" ";B13)
D column used to find the separator between title and artist: =FIND(" - ";B13)
E column the Title: =TRIM(PROPER(MID(B13;C13 + 1;D13 - C13 - 1)))
F column the Artist: =TRIM(PROPER(RIGHT(B13;LEN(B13) - D13 - 2)))

Then I wrote a small vba script in Excel to change the Title and artist into the format of your MM script
ATTENTION THIS IS AN EXCEL SCRIPT
Sub CD()
Dim x, y
y = 1
For x = 1 To 25 'there are 25 songs on the cd, so change to the right amount
Range("H" & y).FormulaR1C1 = "Names(" & x - 1 & ",0) = " & Chr(34) & Range("E" & x).Value & Chr(34)
y = y + 1
Range("H" & y).FormulaR1C1 = "Names(" & x - 1 & ",1) = " & Chr(34) & Range("F" & x).Value & Chr(34)
y = y + 1
Next x
End Sub


I then copied the list of 50 strings into your script.
It could have a lot of tidying up, but it works! :P
Thanks.
Felix Atagong
http://atagong.com
AlanB

ScriptType=?

Post by AlanB »

Felix

Thanks for the feedback, glad I could help.
I shall file your Excel script for future reference.

By the way, ScriptType=1 is on the files menu, but ScriptType=0 is on the Tools, Scripts menu, so take your pick.

Alan
Post Reply