Newbie-Script: Import lyrics from Evillyrics (check code,pls

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

Moderators: Peke, Gurus

Guest

Post by Guest »

How have you tweaked it, trixmoto?
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

Anonymous wrote:How have you tweaked it, trixmoto?
That was me.
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

When using this script, does it overwrite lyrics that already exist in MM?

I have a few songs where I have manually entered lyrics, because the evillyrics ones are wrong. If I run this script on my entire music database, will these song lyrics get overwritten?
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Yes, it overwrites anything in the lyrics field. One of my tweaks was to check if there were any contents before checking for the file so none were overwritten.
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.
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

I'd be very interested in that tweak!
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

This is the same script, with two exceptions.
1) Lyrics are not overwritten if they already exist.
2) Special characters are replaced by underscore (the same as EvilLyrics does).

Code: Select all

Sub EvilTagger

'This scripts imports the Lyrics from Evillyrics
'set the Evillyrics Cache options to "Cache organization ---> by first letter"
'
'Script will check if the lyrics.txt file of the selected songs exists
'and import it then to the lyrics tag
'Filename must be "Artist - Title.txt"
'Possible erros are strange characters in the Artist or Title Tag, e.g. "C'est la vie" or "ä/22*~"

'Here are the ini-Lines
'[Eviltagger]
'FileName=Eviltagger.vbs
'ProcName=Eviltagger
'Order=10
'DisplayName=EvilTagger
'Description=Import Lyrics from Evillyrics
'Language=VBScript
'ScriptType=0





DIM path, filename
DIM list, itm
DIM headline,lyrics, line
DIM msg, errorcounter, filecounter, msgtext

'######################################################
'Set the Errorcounter to his starting point
errorcounter = 0

'Set the Path to the Evillyrics Lyrics
'Evillyrics Options must be set to "Cache organization ---> by first letter"   --> see below
path = "C:\Programme\Evillyrics\Lyrics\"
'######################################################

' Get list of selected tracks from MediaMonkey
Set list = SDB.CurrentSongList
filecounter = list.count

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

   If itm.Lyrics = "" Then 'Trixmoto - ignore tracks with lyrics already
   
     '##################################################
     'set the headline of the Lyrics
     headline = itm.artistname & " - " & itm.title & CHR(10) &"___________________________________" & CHR(10)
     '##################################################
   
     ' Create Filename
     ' by adding the first letter of the artist to the path ("Cache organization ---> by first letter")
     'and then the Evillyrics scheme
     
     Dim cap : cap = UCase(Left(itm.ArtistName,1))
     If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",cap) = 0 Then
       cap = "_"
     End If
     Dim art : art = correctfilename(itm.ArtistName)
     Dim tit : tit = correctfilename(itm.Title)
     
     filename = path & "\" & cap &"\" & art & " - " & tit & ".txt"
     Set filesys = CreateObject("Scripting.FileSystemObject")
     If filesys.FileExists(filename) = true Then
          Set file = filesys.OpenTextFile(filename, 1, false)
        'add headline to the beginning of the Lyrics
        lyrics = headline
        Do while not file.AtEndOfStream
           line = file.ReadLine
           lyrics = lyrics & chr(10) & line
        Loop
        'write Lyrics to the Lyrics tag
        itm.lyrics = lyrics
     Else
       errorcounter = errorcounter +1
     End if  
   End If
Next
' Write all back to DB and update tags
list.UpdateAll


'#####################################################
'set the final message
msgtxt = filecounter - errorcounter & " of " & filecounter& " lyrics imported "
msgtxt = msgtxt & CHR(10)& CHR(10) & "check missing lyrics manually, e.g. filename versus artist, title tag"
'#####################################################

'final user information
Msg = SDB.MessageBox(msgtxt , mtInformation, Array(mbOk))

End sub 

Function correctfilename(str) 'Trixmoto - replaces special characters with underscore
  Dim i,cap
  For i = 1 To Len(str)
    cap = Mid(str,i,1)
    If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789. ",UCase(cap)) = 0 Then
      cap = "_"
    End If
    correctfilename = correctfilename&cap
  Next
End Function
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.
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

Thanks!
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

Hi guys,
I improved trixmoto's edition by moving the UpdateAll-function into to loop. Now only songs with a new lyric will be tagged. It's much faster now.

Big_Berny

Code: Select all

EDIT: removed - see below
Last edited by Big_Berny on Fri Oct 20, 2006 8:51 am, edited 1 time in total.
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

I get an error:
Object doesn't support this property or method: "itm.UpdateAll"
and it points to the line which contains
"itm.UpdateAll 'Big_Berny - moved into the loop "
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

Oups! Here's the new version which uses UpdateDB. It's better anyway.

Big_Berny

Code: Select all

see my last post
Last edited by Big_Berny on Wed Nov 15, 2006 3:31 am, edited 1 time in total.
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

I've noticed a fault in all versions.
This section:

Code: Select all

If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789. ",UCase(cap)) = 0 Then 
      cap = "_" 
    End If 
Doesn't account for characters like "Ö" which Eviltagger does save properly.
(Took me a while to figure out why Blue Öyster Cult tracks weren't being imported.)

Plus, if a song has "-" in the name, it gets saved as a space not an underscore.
The song title: "X-Ray Eyes" is treated by Evillyrics as "X Ray Eyes" not "X_Ray Eyes"

I'm sure there are a number of others.
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

This can easily be fixed. So let's find these specialcharacters which are not saved as underscore.

I found (additionally):
ÄÁÀÂÃËÉÈÊÏÍÌÎÖÓÒÔÕÜÚÙÛÑ¿

Any others?

And you're right: "-" gets " ".

Big_Berny
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

I've altered that last function as follows:

Code: Select all

Function correctfilename(str) 'Trixmoto - replaces special characters with underscore 
  Dim i,cap 
  For i = 1 To Len(str) 
    cap = Mid(str,i,1) 
    If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ÄÁÀÂÃËÉÈÊÏÍÌÎÖÓÒÔÕÜÚÙÛÑ¿. ",UCase(cap)) = 0 Then
      if cap = "-" then
         cap = " "
      else 
         cap = "_" 
      end if
    End If 
    correctfilename = correctfilename&cap 
  Next 
End Function
Also the special characters need to be inserted at the other point they are used in the code.

One thing I'm puzzled about: this section of the trixmoto's code:

Code: Select all

' Create Filename 
     ' by adding the first letter of the artist to the path ("Cache organization ---> by first letter") 
     'and then the Evillyrics scheme 
      
     Dim cap : cap = UCase(Left(itm.ArtistName,1)) 
     If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ÄÁÀÂÃËÉÈÊÏÍÌÎÖÓÒÔÕÜÚÙÛÑ¿",cap) = 0 Then 
       cap = "_" 
     End If 
     Dim art : art = correctfilename(itm.ArtistName) 
     Dim tit : tit = correctfilename(itm.Title) 
Why is that instr function there? Why not just pass that to the correctfilename code?
MeMeMe
Posts: 272
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe »

Ahhh, I figured it out what that bit's for.
I wonder if Evillyrics recognises special characters in creating folders (assuming there are any artists that start their names with those letters)?
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

Yes, it's the same for the folders. Just tested it.

By the way I just found out that a "-" gets replaced with "" (nothing) and not with a " " (space).

Big_Berny
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design
Post Reply