PersonalTagEnhancer (AutoTagging)
-
- Posts: 367
- Joined: Sun Aug 28, 2005 10:43 pm
Any chance of getting a list of what "tags" script
Before I run this script is there any chance someone can list what it will be changing. What fields will it make these changes in?
A complete list is not necessary, but some examples of the major ones would be nice. I thought it would change any titles that started with "The " to titles that do not have "The " in the title. But I did not see any change.
-thanks for your time
-thefaceman
A complete list is not necessary, but some examples of the major ones would be nice. I thought it would change any titles that started with "The " to titles that do not have "The " in the title. But I did not see any change.
-thanks for your time
-thefaceman
These are the functions that can be applied:
ChangeCharacters:
- change underscore to space
- change "´" and "`" to "'"
FixBrackets:
- change square brackets to round brackets
- trim leading and trailing spaces inside round brackets (e.g. changes "( Radio Edit )" to "(Radio Edit)")
FixCommonWords (for all capitalisation variations, matches whole words only):
- use "ft." instead of "featuring", "features", "feat", "feat.", "ft", "Ft."
- use "pres." instead of "presenting", "presents", "pres", "Pres."
- use "vs." instead of "versus", "vs", "Vs."
- use uppercase DJ instead of other case variants
- change "its" to "it's", "dont" to "don't", "aint" to "ain't", "isnt" to "isn't", "cant" to "can't", ...
- change "RMX" to "remix"
FixWrongGenre:
- remove the genre if it is one of the following: "other", "unknown", "default", "genre", "misc"
Trim: trims leading and trailing spaces
This shows which functions are applied to which fields:
- Artist: FixCommonWords, ChangeCharacters, Trim
- AlbumArtist: FixCommonWords, ChangeCharacters, Trim
- Title: FixCommonWords, ChangeCharacters, FixBrackets, Trim
- Genre: FixWrongGenre, Trim
- Album: ChangeCharacters, Trim
If a song is a single (it is not part of an album: the Album field is empty), then the AlbumArtist field and track number will be emptied too.
Personally I always run PersonalTagEnhancer followed by the Case ("Case Modify") script.
ChangeCharacters:
- change underscore to space
- change "´" and "`" to "'"
FixBrackets:
- change square brackets to round brackets
- trim leading and trailing spaces inside round brackets (e.g. changes "( Radio Edit )" to "(Radio Edit)")
FixCommonWords (for all capitalisation variations, matches whole words only):
- use "ft." instead of "featuring", "features", "feat", "feat.", "ft", "Ft."
- use "pres." instead of "presenting", "presents", "pres", "Pres."
- use "vs." instead of "versus", "vs", "Vs."
- use uppercase DJ instead of other case variants
- change "its" to "it's", "dont" to "don't", "aint" to "ain't", "isnt" to "isn't", "cant" to "can't", ...
- change "RMX" to "remix"
FixWrongGenre:
- remove the genre if it is one of the following: "other", "unknown", "default", "genre", "misc"
Trim: trims leading and trailing spaces
This shows which functions are applied to which fields:
- Artist: FixCommonWords, ChangeCharacters, Trim
- AlbumArtist: FixCommonWords, ChangeCharacters, Trim
- Title: FixCommonWords, ChangeCharacters, FixBrackets, Trim
- Genre: FixWrongGenre, Trim
- Album: ChangeCharacters, Trim
If a song is a single (it is not part of an album: the Album field is empty), then the AlbumArtist field and track number will be emptied too.
Personally I always run PersonalTagEnhancer followed by the Case ("Case Modify") script.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
This is one of the scripts I use the most!
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
And so do I:Steegy wrote:If you have other personal enhancements that you would like to share, please do ...
Code: Select all
Function FixCommonWords(Tag)
Tag = ReplaceBadTagPortion(Tag, "ok", "OK")
Tag = ReplaceBadTagPortion(Tag, "tv", "TV")
Tag = ReplaceBadTagPortion(Tag, "youre", "you're")
Tag = ReplaceBadTagPortion(Tag, "youve", "you've")
Tag = ReplaceBadTagPortion(Tag, "didnt", "didn't")
Tag = ReplaceBadTagPortion(Tag, "wasnt", "wasn't")
Tag = ReplaceBadTagPortion(Tag, "wont", "won't")
Tag = ReplaceBadTagPortion(Tag, "havent", "haven't")
'Capitalization...
Tag = ReplaceBadTagPortion(Tag, "i", "I")
Tag = ReplaceBadTagPortion(Tag, "i'm", "I'm")
Tag = ReplaceBadTagPortion(Tag, "i'd", "I'd")
Tag = ReplaceBadTagPortion(Tag, "i'll", "I'll")
Tag = ReplaceBadTagPortion(Tag, "i've", "I've")
Function ChangeCharacters(Tag)
'Some more characters...
'These ARE NOT duplicates. They look like those already in the script, but have different codes...
Tag = Replace(Tag, "‘", "'", 1, -1, 1)
Tag = Replace(Tag, "’", "'", 1, -1, 1)
Tag = Replace(Tag, "…", "...", 1, -1, 1)
'Unneeded space before punctuation...
'Don't know if this goes here or in FixCommonWords...
Tag = Replace(Tag, " ?", "?", 1, -1, 1)
Tag = Replace(Tag, " !", "!", 1, -1, 1)
Tag = Replace(Tag, " ,", ",", 1, -1, 1)
Tag = Replace(Tag, " :", ":", 1, -1, 1)
Tag = Replace(Tag, " ...", "...", 1, -1, 1)
-
- Posts: 223
- Joined: Sun Apr 29, 2007 9:45 pm
I wanna change something in this script the part in the title for when editing remixes which contain curved brackets () in the title to [] how ever i want () brackets in the artist field to remain
I think this is the piece of code which needs to change
Function FixBrackets(Tag)
Tag = Replace(Tag, "[", "(", 1, -1, 1)
Tag = Replace(Tag, "]", ")", 1, -1, 1)
Tag = Replace(Tag, "( ", "(", 1, -1, 1)
Tag = Replace(Tag, " )", ")", 1, -1, 1)
FixBrackets = Tag
but im not sure how to get it to act the way I want that is to only convert ( to [ if its in the title field and leave the artist /album field alone.
I think this is the piece of code which needs to change
Function FixBrackets(Tag)
Tag = Replace(Tag, "[", "(", 1, -1, 1)
Tag = Replace(Tag, "]", ")", 1, -1, 1)
Tag = Replace(Tag, "( ", "(", 1, -1, 1)
Tag = Replace(Tag, " )", ")", 1, -1, 1)
FixBrackets = Tag
but im not sure how to get it to act the way I want that is to only convert ( to [ if its in the title field and leave the artist /album field alone.
From a quick look at the code, FixBrackets is only called for the Title field. So I don't understand what you mean.
See also here.
See also here.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
-
- Posts: 312
- Joined: Mon Apr 03, 2006 9:11 am
- Location: Denver, CO
Steegy-
Love this script, but I find myself running it then the Case Checker script afterwards. Is there a way to combine them? I'd like to keep the Albums & Artists intact but just run the CommonWords section with the following additions:
It > it
And > and
Or > or
A > a
An > an
The > the
But > but
For > for
Nor > nor
Ep > EP
Lp > LP
If i understand the code correctly, I'd just have the following example line in the file:
Tag = ReplaceBadTagPortion(Tag, " It", " it")
I put the space in there because if "It" appears at the beginning of the Tag I'd like to leave it capitalized. Am I sort of right on this? I may have some other terms I'd like to capitalize or change, so I want to make sure I have this sort of right before I go messing around!
Thanks again!
Love this script, but I find myself running it then the Case Checker script afterwards. Is there a way to combine them? I'd like to keep the Albums & Artists intact but just run the CommonWords section with the following additions:
It > it
And > and
Or > or
A > a
An > an
The > the
But > but
For > for
Nor > nor
Ep > EP
Lp > LP
If i understand the code correctly, I'd just have the following example line in the file:
Tag = ReplaceBadTagPortion(Tag, " It", " it")
I put the space in there because if "It" appears at the beginning of the Tag I'd like to leave it capitalized. Am I sort of right on this? I may have some other terms I'd like to capitalize or change, so I want to make sure I have this sort of right before I go messing around!
Thanks again!
MM Gold since 2006
I'd recommend leaving all case-related corrections over to the Case Modify script.
However, as you say (and as I use them), you can combine both scripts:
- open PersonalTagEnhancer.vbs
- add the relevant code from Case.vbs to PTE:
- In PTE, use the function "updateCase" on the fields of which you want to change the case, e.g. like
- Save the changes and launch the combined script.
The code above is taken from my edited version of the Case Modify script. You can edit it yourself, or take the code from your own copy of the Case.vbs file.
Cheers
Steegy
However, as you say (and as I use them), you can combine both scripts:
- open PersonalTagEnhancer.vbs
- add the relevant code from Case.vbs to PTE:
Code: Select all
Dim littleWordString
'littleWordString = "a|an|and|at|de|del|di|du|e|el|en|et|for" & _
' "|from|la|le|in|n|'n|n'|'n'|o'|'o'|of|or" & _
' "|por|the|to|un|une|und|with|y|'k"
Dim forceCapString
forceCapString = "AC|EBN|OZN|MCs|MC's|DJs|DJ's|JBs|JB's|10cc" & _
"|Mr|Mrs|Dr|Jr|Sr|Pt|St.|St|vs|ft|feat|pres" & _
"|aka|Vol|w/|ABC|ABCs|AC/|ASCII|ASCIII|ATV" & _
"|BTO|ELO|ELP|EMI|DuShon|FYC|INXS|MacArthur" & _
"|OMC|OMD|OMPS|PSI|PTA|REM|REO|Sgt|UB40|UK" & _
"|USA|USMC|UTFO|silence]|iiO|T's|OK|Km/h" & _
"|YMCA|USSR|LoungeDeluxe|M'n|TMF|MTV|NRG|DJ" & _
"|MC|H2O|AlexIsOnFire|PhD|dEUS|NOFX|'s|'n|'t" & _
"|ACDC|t'|ID&T|UR|'k|ATB|AR52|BAT 67|CD" & _
"|trance[]control|meets|JimTv|GDream|NY|ID|EP|TV|OST"
Dim res
Dim alphaNum, whiteSpace, isMc, vowels, romanNumerals, cardinal, isForeignPref
Set alphaNum = new regExp
Set whiteSpace = new regExp
Set isMc = new regExp
Set vowels = new regExp
Set romanNumerals = new RegExp
Set cardinal = new RegExp
Set isForeignPref = new RegExp
alphaNum.ignoreCase = True
alphaNum.pattern = "['`´A-Za-z0-9" & ChrW(192) & "-" & ChrW(65276) & "]"
whiteSpace.pattern = "^[\s,&]+$" 'include comma, ampersand, because we don't want to cap after these
isMc.ignoreCase = True
isMc.pattern = "^(O['`]|MC)" ' handle O'Brien and McHenry
isForeignPref.ignoreCase = True
isForeignPref.pattern = "^([dl]|dell)['`]" ' handle l', d' and dell'
vowels.ignoreCase = True
vowels.pattern = "[AEIOUY" & ChrW(192) & "-" & ChrW(601) & "]"
romanNumerals.ignoreCase = True
romanNumerals.pattern = "^M*(C(M|D)|D?C{0,3})(X(C|L)|L?X{0,3})(I(X|V)|V?I{0,3})$"
cardinal.ignoreCase = True
cardinal.pattern = "^\d*(1st|2nd|3rd|[0-9]th|[0-9]['`]?s)$" 'also handles years, like 1950s
Dim littleWordList
littleWordList = Split(littleWordString,"|")
Dim forceCapList
forceCapList = Split(forceCapString,"|")
Function uppercase(s)
If Left(s,1) = "'" And Len(s) > 1 Then
uppercase = Left(s,1)&UCase(Mid(s,2,1))&LCase(Mid(s,3))
Else
uppercase = UCase(Mid(s,1,1))&LCase(Mid(s,2))
End If
End Function
Function fixUp(s, prevChars, nextChar)
Dim forceIndex, littleIndex, i
Dim capMe, allCaps, foreignPref
Dim upcased, littleUpped, forceUpped
forceIndex = -1
littleIndex = -1
capMe = false
allCaps = false
upcased = UCase(s)
foreignPref = isForeignPref.test(s)
For i = 0 to UBound(forceCapList)
forceUpped = UCase(forceCapList(i))
If UCase(forceCapList(i)) = upcased Or forceUpped = upcased & nextChar Then
forceIndex = i
Exit For
End If
Next 'i
For i = 0 to UBound(littleWordList)
littleUpped = UCase(littleWordList(i))
If littleUpped = upcased Or littleUpped = upcased & nextChar Then
littleIndex = i
Exit For
End If
Next 'i
If forceIndex >= 0 Then
s = forceCapList(forceIndex)
Else
If Len(s) = 1 And nextChar = "." Then
' if it's a single character followed by a period (an initial), caps it
allCaps = True
ElseIf Not vowels.test(s) And Not cardinal.test(s) Then
' if it's all consonants, no vowels, and not a cardinal number, caps it
allCaps = True
ElseIf romanNumerals.test(s) And UCase(s) <> "MIX" And UCase(s) <> "MI" And UCase(s) <> "DI" Then
' if it's roman numerals (and not 'mix' or 'di' which are valid roman numerals), caps it
allCaps = True
ElseIf prevChars = "" Or (nextChar = "" And Not foreignPref) Then
'if it's the first or last word, cap it
capMe = True
ElseIf Not whiteSpace.test(prevChars) Or (nextChar <> "" And InStr(")}]",nextChar)) Then
' if it follows a punctuation mark (with or without spaces) or if it's before a close-bracket, cap it
capMe = True
ElseIf littleIndex < 0 And Not foreignPref Then
' if it's not on the 'little word' list, cap it
capMe = True
End If
If allCaps Then
s = UCase(s)
ElseIf capMe Then
s = uppercase(s)
Else
s = LCase(s)
End If
If isMc.Test(s) And Len(s) > 2 Then
' if it's Mc or O', cap the 3rd character (this assumes no names like McA)
s = Mid(s,1,2)&UCase(Mid(s,3,1))&LCase(Mid(s,4))
End If
If foreignPref Then
' if it's l', d' or dell', lowercase the first letter and uppercase the first letter after the apostrophe
Dim pos
pos = InStr(s,"'")
If pos < 1 Then
pos = InStr(s,"`")
End If
If pos > 0 And pos < Len(s) Then
s = Mid(s,1,pos)&UCase(Mid(s,pos+1,1))&LCase(Mid(s,pos+2))
End If
End If
End If
fixUp = s
End Function
Function updateCase(s)
Dim currentWord, result, fixed, theChar, lastNonWordChars
Dim forceIndex
Dim i
currentWord = ""
result = ""
lastNonWordChars = ""
For i = 1 to Len(s)
theChar = Mid(s,i,1)
If alphaNum.test(theChar) Then
currentWord = currentWord & theChar
Else
If currentWord <> "" Then
fixed = fixUp(currentWord,lastNonWordChars,theChar)
If Right(fixed,1) = theChar Then 'handle stuff like w/
fixed = Left(fixed,Len(fixed)-1)
lastNonWordChars = ""
Else
lastNonWordChars = theChar
End If
result = result & fixed
currentWord = ""
Else
lastNonWordChars = lastNonWordChars & theChar
End If
result = result & theChar
End If
Next 'i
If Len(currentWord) > 0 Then
result = result & fixUp(currentWord,lastNonWordChars,"")
End If
updateCase = result
End Function
Code: Select all
artist = updateCase(FixCommonWords(ChangeCharacters(Trim(itm.ArtistName))))
The code above is taken from my edited version of the Case Modify script. You can edit it yourself, or take the code from your own copy of the Case.vbs file.
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Sorry for the confusion, but here's my latest copy of the PTE script, with the Case Modify script added to it today (quick 'n' dirty):
The preview window now only shows tracks that have been changed, making it much faster if a lot of tracks are selected.
The progress indicator is fixed and I added the contributed fixes.
The preview window now only shows tracks that have been changed, making it much faster if a lot of tracks are selected.
The progress indicator is fixed and I added the contributed fixes.
Code: Select all
Option Explicit
'//////////////////////////////////////////////////////////////
'// PersonalTagEnhancer Updated on 2007-07-27 //
'//////////////////////////////////////////////////////////////
'// Made by Steegy aka RC (Ruben Castelein) //
'// //
'// Improvements contibuted by various people. THANKS! //
'// //
'// >>> Fixes most important tags using personal preferences //
'//////////////////////////////////////////////////////////////
'///////////////////////////////////////////////////
'// FORM CREATION AND CALLING OF ENHANCER METHODS //
'///////////////////////////////////////////////////
Sub PersonalTagEnhancer
Dim trackList
Set trackList = SDB.SelectedSongList
If trackList.count=0 Then
Set trackList = SDB.AllVisibleSongList
End If
If trackList.count=0 Then
SDB.MessageBox "Select tracks to be updated", mtError, Array(mbOk)
Exit Sub
End If
Dim UI
Set UI = SDB.UI
Dim DlgWidth
DlgWidth = 500
' Create the window to be shown
Dim Form
Set Form = UI.NewForm
Form.Common.SetRect 50, 50, DlgWidth, 400
Form.Common.MinWidth = 200
Form.Common.MinHeight = 150
Form.FormPosition = mmFormScreenCenter
Form.Caption = SDB.Localize("Personal Tag Enhancer")
Form.StayOnTop = True
' Create a web browser component
Dim WB
Set WB = UI.NewActiveX(Form, "Shell.Explorer")
WB.Common.Align = mmAlignClient ' Fill all client rectangle
WB.Common.ControlName = "WB"
Dim doc
Set doc = WB.Interf.Document
' Create a panel at the bottom of the window
Dim Foot
Set Foot = UI.NewPanel(Form)
Foot.Common.Align = mmAlignBottom
Foot.Common.Height = 35
' Create a button that saves the report
Dim Btn2
Set Btn2 = UI.NewButton(Foot)
Btn2.Caption = SDB.Localize("&Ok")
Btn2.Common.SetRect DlgWidth - 205, 6, 85, 25
Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom
Btn2.UseScript = Script.ScriptPath
Btn2.OnClickFunc = "OnOK"
Btn2.Default = true
' Create a button that closes the window
Dim Btn
Set Btn = UI.NewButton(Foot)
Btn.Caption = SDB.Localize("&Cancel")
Btn.Common.SetRect DlgWidth - 105, 6, 85, 25
Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom
Btn.UseScript = Script.ScriptPath
Btn.OnClickFunc = "OnCancel"
Btn.Cancel = True
Dim Progress
Set Progress = SDB.Progress
Progress.Text = SDB.Localize("Personal Tag Enhancer: Loading preview of track enhancements...")
Progress.MaxValue = trackList.count
Form.SavePositionName = "PTEWindow"
SDB.Objects("PTEForm") = Form ' Save reference to the form somewhere, otherwise it would simply disappear
doc.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbcrlf
doc.write "<html>" & vbcrlf
doc.write " <head>" & vbcrlf
doc.write " <title>" & SDB.Localize("Personal Tag Enhancer") & "</title>" & vbcrlf
doc.write " </head>" & vbcrlf
doc.write "<STYLE TYPE=text/css>" & vbcrlf
doc.write "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbcrlf
doc.write "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbcrlf
doc.write "P{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000;}" & vbcrlf
doc.write "TH{font-family:'Verdana',sans-serif; font-size:9pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbcrlf
doc.write "TD{font-family:'Verdana',sans-serif; font-size:8pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbcrlf
doc.write "TD.highlight{font-family:'Verdana',sans-serif; font-size:8pt; background-color:#FFFF77; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbcrlf
doc.write "TR.dark{background-color:#EEEEEE}" & vbcrlf
doc.write "TR.aleft TH{text-align:left}" & vbcrlf
doc.write "</STYLE>" & vbcrlf
doc.write " <body>" & vbcrlf
doc.write " <H1>" & SDB.Localize("Changes by personal preferences:") & "</H1>" & vbcrlf
doc.write " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
doc.write " <tr class=""aleft"">" & vbcrlf
doc.write " <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf
doc.write " <th>" & SDB.Localize("Title") & "</th>" & vbcrlf
doc.write " <th>" & SDB.Localize("Album") & "</th>" & vbcrlf
doc.write " <th>" & SDB.Localize("Album Artist") & "</th>" & vbcrlf
doc.write " <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf
doc.write " <th>" & SDB.Localize("Track#") & "</th>" & vbcrlf
doc.write " </tr>" & vbCrLf
Dim i, itm
Dim artist, album, title, albumArtist, genre, trackOrder
for i=0 to trackList.count-1
If Progress.Terminate Then
CloseDown
Exit Sub
End if
Progress.Value = i+1
Set itm = trackList.Item(i)
'///////////////////////////////////////////////////////////////////////
'//////////////////////////////////////////
'//////////////
artist = updateCase(FixCommonWords(ChangeCharacters(Trim(itm.ArtistName))))
'Dim CommaPosition : CommaPosition = InStr(artist, ",")
'artist = Mid(artist, CommaPosition + 1) & " " & Left(artist, CommaPosition - 1)
title = updateCase(FixCommonWords(FixBrackets(ChangeCharacters(Trim(itm.Title)))))
genre = updateCase(FixWrongGenre(Trim(itm.Genre)))
album = updateCase(ChangeCharacters(Trim(itm.AlbumName)))
If album = "" Then
albumArtist = ""
trackOrder = 0
Else
albumArtist = updateCase(FixCommonWords(ChangeCharacters(Trim(itm.AlbumArtistName))))
trackOrder = itm.trackOrder
End If
' //////////////
' //////////////////////////////////////////
'///////////////////////////////////////////////////////////////////////
Dim trackOrder_disp
If trackOrder = 0 Then
trackOrder_disp = ""
Else
trackOrder_disp = trackOrder
End If
Dim trackOrderItm_disp
If itm.trackOrder = 0 Then
trackOrderItm_disp = ""
Else
trackOrderItm_disp = itm.trackOrder
End If
Dim HasChanged : HasChanged = False
If artist <> "" And artist <> itm.artistName Then
holdArtist.add itm, artist
HasChanged = True
End If
If albumArtist <> "" And albumArtist <> itm.albumArtistName Then
holdAlbumArtist.add itm, albumArtist
HasChanged = True
End If
If title <> itm.title Then
holdTitle.add itm, title
HasChanged = True
End If
If album <> "" And album <> itm.albumName Then
holdAlbum.add itm, album
HasChanged = True
End If
If genre <> itm.genre Then
holdGenre.add itm, genre
HasChanged = True
End If
If trackOrder <> itm.trackOrder Then
holdTrackOrder.add itm, trackOrder
HasChanged = True
End If
If HasChanged Then
doc.write " <tr" & Style() & ">" & vbcrlf
doc.write outField(artist, itm.artistName)
doc.write outField(title, itm.title)
doc.write outField(album, itm.albumName)
doc.write outField(albumArtist, itm.albumArtistName)
doc.write outField(genre, itm.genre)
doc.write outField(trackOrder_disp, trackOrderItm_disp)
doc.write " </tr>" & vbcrlf
End If
next 'i
doc.write " </table>" & vbcrlf
doc.write " </body>" & vbcrlf
doc.write "</html>" & vbcrlf
doc.close
SDB.Objects("holdArtist") = holdArtist
SDB.Objects("holdAlbumArtist") = holdAlbumArtist
SDB.Objects("holdAlbum") = holdAlbum
SDB.Objects("holdTitle") = holdTitle
SDB.Objects("holdGenre") = holdGenre
SDB.Objects("holdTrackOrder") = holdTrackOrder
Form.Common.Visible = True ' Only show the form, don't wait for user input
End Sub
'//////////////////////
'// ENHANCER METHODS //
'//////////////////////
Function ChangeCharacters(Tag)
Tag = Replace(Tag, "_", " ", 1, -1, 1)
Tag = Replace(Tag, "´", "'", 1, -1, 1)
Tag = Replace(Tag, "`", "'", 1, -1, 1)
'Some more characters...
'These ARE NOT duplicates. They look like those already in the script, but have different codes...
Tag = Replace(Tag, "‘", "'", 1, -1, 1)
Tag = Replace(Tag, "’", "'", 1, -1, 1)
Tag = Replace(Tag, "…", "...", 1, -1, 1)
'Unneeded space before punctuation...
Tag = Replace(Tag, " ?", "?", 1, -1, 1)
Tag = Replace(Tag, " !", "!", 1, -1, 1)
Tag = Replace(Tag, " ,", ",", 1, -1, 1)
Tag = Replace(Tag, " :", ":", 1, -1, 1)
Tag = Replace(Tag, " ...", "...", 1, -1, 1)
Tag = Replace(Tag, " ", " ", 1, -1, 1)
ChangeCharacters = Tag
End Function
Function FixBrackets(Tag)
Tag = Replace(Tag, "[", "(", 1, -1, 1)
Tag = Replace(Tag, "]", ")", 1, -1, 1)
Tag = Replace(Tag, "( ", "(", 1, -1, 1)
Tag = Replace(Tag, " )", ")", 1, -1, 1)
FixBrackets = Tag
End Function
Function FixCommonWords(Tag)
Tag = ReplaceBadTagPortion(Tag, "featuring", "ft.")
Tag = ReplaceBadTagPortion(Tag, "features", "ft.")
Tag = ReplaceBadTagPortion(Tag, "feat", "ft.")
Tag = ReplaceBadTagPortion(Tag, "feat.", "ft.")
Tag = ReplaceBadTagPortion(Tag, "ft", "ft.")
Tag = ReplaceBadTagPortion(Tag, "Ft.", "ft.")
Tag = ReplaceBadTagPortion(Tag, "presenting", "pres.")
Tag = ReplaceBadTagPortion(Tag, "presents", "pres.")
Tag = ReplaceBadTagPortion(Tag, "pres", "pres.")
Tag = ReplaceBadTagPortion(Tag, "Pres.", "pres.")
Tag = ReplaceBadTagPortion(Tag, "versus", "vs.")
Tag = ReplaceBadTagPortion(Tag, "vs", "vs.")
Tag = ReplaceBadTagPortion(Tag, "Vs.", "vs.")
Tag = ReplaceBadTagPortion(Tag, "dj", "DJ")
Tag = ReplaceBadTagPortion(Tag, "Its", "It's") 'Good changes outweigh the bad ones (real "its")
Tag = ReplaceBadTagPortion(Tag, "RMX", "Remix")
Tag = ReplaceBadTagPortion(Tag, "dont", "don't")
Tag = ReplaceBadTagPortion(Tag, "aint", "ain't")
Tag = ReplaceBadTagPortion(Tag, "isnt", "isn't")
Tag = ReplaceBadTagPortion(Tag, "cant", "can't")
Tag = ReplaceBadTagPortion(Tag, "ill", "i'll") 'Good changes outweigh the bad ones (real "ill")
Tag = ReplaceBadTagPortion(Tag, "wouldnt", "wouldn't")
Tag = ReplaceBadTagPortion(Tag, "wouldve", "would've")
Tag = ReplaceBadTagPortion(Tag, "shouldnt", "shouldn't")
Tag = ReplaceBadTagPortion(Tag, "shouldve", "should've")
Tag = ReplaceBadTagPortion(Tag, "ok", "OK")
Tag = ReplaceBadTagPortion(Tag, "tv", "TV")
Tag = ReplaceBadTagPortion(Tag, "youre", "you're")
Tag = ReplaceBadTagPortion(Tag, "youve", "you've")
Tag = ReplaceBadTagPortion(Tag, "didnt", "didn't")
Tag = ReplaceBadTagPortion(Tag, "wasnt", "wasn't")
Tag = ReplaceBadTagPortion(Tag, "wont", "won't")
Tag = ReplaceBadTagPortion(Tag, "havent", "haven't")
Tag = ReplaceBadTagPortion(Tag, "lets", "let's")
Tag = ReplaceBadTagPortion(Tag, "hes", "he's")
Tag = ReplaceBadTagPortion(Tag, "shes", "she's")
'Capitalization... (The Case Checker script should do that. It's always recommended to use that script too.)
Tag = ReplaceBadTagPortion(Tag, "i", "I")
Tag = ReplaceBadTagPortion(Tag, "i'm", "I'm")
Tag = ReplaceBadTagPortion(Tag, "i'd", "I'd")
Tag = ReplaceBadTagPortion(Tag, "i'll", "I'll")
Tag = ReplaceBadTagPortion(Tag, "i've", "I've")
FixCommonWords = Tag
End Function
Function FixWrongGenre(Tag)
FixWrongGenre = Tag
Tag = LCase(Tag)
If Tag = "other" Or Tag = "unknown" Or Tag = "default" Or Tag = "genre" Or Tag = "misc" Then
FixWrongGenre = ""
End If
End Function
Function RemoveAccents(InputString)
Const AccentString = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÏÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóóôõöùúûüýÿ"
Const NonAccentStr = "AAAAAACEEEEIIIIINOOOOOUUUUYaaaaaaceeeeIIIIonoooooouuuuyy"
RemoveAccents = InputString
Dim i
For i = 1 To Len(AccentString)
RemoveAccents = Replace(RemoveAccents, Mid(AccentString, i, 1), Mid(NonAccentStr, i, 1))
Next
End Function
'/////////////////////////
'// HELPER FIX FUNCTION //
'/////////////////////////
Function ReplaceBadTagPortion(Tag, FromValue, ToValue)
If InStr(1, Tag, FromValue, 1) = 1 Then
Tag = Replace(Tag, FromValue & " ", ToValue & " ", 1, -1, 1)
Tag = Replace(Tag, FromValue & ")", ToValue & ")", 1, -1, 1)
End If
If InStrRev(Tag, FromValue, -1, 1) = Len(Tag) - Len(FromValue) + 1 Then
Tag = Replace(Tag, " " & FromValue, " " & ToValue, 1, -1, 1)
Tag = Replace(Tag, "(" & FromValue, "(" & ToValue, 1, -1, 1)
End If
Tag = Replace(Tag, " " & FromValue & " ", " " & ToValue & " ", 1, -1, 1)
Tag = Replace(Tag, "(" & FromValue & " ", "(" & ToValue & " ", 1, -1, 1)
Tag = Replace(Tag, " " & FromValue & ")", " " & ToValue & ")", 1, -1, 1)
Tag = Replace(Tag, "(" & FromValue & ")", "(" & ToValue & ")", 1, -1, 1)
ReplaceBadTagPortion = Tag
End Function
'//////////////////
'// DECLARATIONS //
'//////////////////
Public holdArtist, holdAlbum, holdTitle, holdAlbumArtist, holdGenre, holdTrackOrder
Set holdArtist = CreateObject("Scripting.Dictionary")
Set holdAlbum = CreateObject("Scripting.Dictionary")
Set holdTitle = CreateObject("Scripting.Dictionary")
Set holdAlbumArtist = CreateObject("Scripting.Dictionary")
Set holdGenre = CreateObject("Scripting.Dictionary")
Set holdTrackOrder = CreateObject("Scripting.Dictionary")
Const mmAnchorRight = 4
Const mmAnchorBottom = 8
Const mmAlignTop = 1
Const mmAlignBottom = 2
Const mmAlignClient = 5
Const mmListDropdown = 2
Const mmFormScreenCenter = 4
Public styleOn
Dim littleWordString
'littleWordString = "a|an|and|at|de|del|di|du|e|el|en|et|for" & _
' "|from|la|le|in|n|'n|n'|'n'|o'|'o'|of|or" & _
' "|por|the|to|un|une|und|with|y|'k"
Dim forceCapString
forceCapString = "AC|EBN|OZN|MCs|MC's|DJs|DJ's|JBs|JB's|10cc" & _
"|Mr|Mrs|Dr|Jr|Sr|Pt|St.|St|vs|ft|feat|pres" & _
"|aka|Vol|w/|ABC|ABCs|AC/|ASCII|ASCIII|ATV" & _
"|BTO|ELO|ELP|EMI|DuShon|FYC|INXS|MacArthur" & _
"|OMC|OMD|OMPS|PSI|PTA|REM|REO|Sgt|UB40|UK" & _
"|USA|USMC|UTFO|silence]|iiO|T's|OK|Km/h" & _
"|YMCA|USSR|LoungeDeluxe|M'n|TMF|MTV|NRG|DJ" & _
"|MC|H2O|AlexIsOnFire|PhD|dEUS|NOFX|'s|'n|'t" & _
"|ACDC|t'|ID&T|UR|'k|ATB|AR52|BAT 67|CD" & _
"|trance[]control|meets|JimTv|GDream|NY|ID|EP|TV|OST"
Dim res
Dim alphaNum, whiteSpace, isMc, vowels, romanNumerals, cardinal, isForeignPref
Set alphaNum = new regExp
Set whiteSpace = new regExp
Set isMc = new regExp
Set vowels = new regExp
Set romanNumerals = new RegExp
Set cardinal = new RegExp
Set isForeignPref = new RegExp
alphaNum.ignoreCase = True
alphaNum.pattern = "['`´A-Za-z0-9" & ChrW(192) & "-" & ChrW(65276) & "]"
whiteSpace.pattern = "^[\s,&]+$" 'include comma, ampersand, because we don't want to cap after these
isMc.ignoreCase = True
isMc.pattern = "^(O['`]|MC)" ' handle O'Brien and McHenry
isForeignPref.ignoreCase = True
isForeignPref.pattern = "^([dl]|dell)['`]" ' handle l', d' and dell'
vowels.ignoreCase = True
vowels.pattern = "[AEIOUY" & ChrW(192) & "-" & ChrW(601) & "]"
romanNumerals.ignoreCase = True
romanNumerals.pattern = "^M*(C(M|D)|D?C{0,3})(X(C|L)|L?X{0,3})(I(X|V)|V?I{0,3})$"
cardinal.ignoreCase = True
cardinal.pattern = "^\d*(1st|2nd|3rd|[0-9]th|[0-9]['`]?s)$" 'also handles years, like 1950s
Dim littleWordList
littleWordList = Split(littleWordString,"|")
Dim forceCapList
forceCapList = Split(forceCapString,"|")
'//////////////////////////
'// FORM ACTION HANDLERS //
'//////////////////////////
Sub CloseDown
Set holdAlbum = nothing
Set holdAlbumArtist = nothing
Set holdArtist = nothing
Set holdTitle = nothing
Set holdGenre = nothing
Set holdTrackOrder = nothing
SDB.Objects("PTEForm") = Nothing
SDB.Objects("holdArtist") = Nothing
SDB.Objects("holdAlbumArtist") = Nothing
SDB.Objects("holdAlbum") = Nothing
SDB.Objects("holdTitle") = Nothing
SDB.Objects("holdGenre") = Nothing
SDB.Objects("holdTrackOrder") = Nothing
End Sub
Sub OnCancel(Btn)
CloseDown
End Sub
Sub OnOK(Btn)
Set holdAlbum = SDB.Objects("holdAlbum")
Set holdAlbumArtist = SDB.Objects("holdAlbumArtist")
Set holdArtist = SDB.Objects("holdArtist")
Set holdTitle = SDB.Objects("holdTitle")
Set holdGenre = SDB.Objects("holdGenre")
Set holdTrackOrder = SDB.Objects("holdTrackOrder")
Dim itm, str, sql
Dim items, albumNames, artistNames
Set items = CreateObject("Scripting.Dictionary")
Set albumNames = CreateObject("Scripting.Dictionary")
Set artistNames = CreateObject("Scripting.Dictionary")
For Each itm In holdArtist
str = holdArtist.item(itm)
If Not items.exists(itm) Then
items.add itm, itm
End If
itm.artistName = str
If Not artistNames.exists(str) Then
sql = "UPDATE Artists SET Artists.Artist = " & SQLQStr(str) & " WHERE Artists.Artist= " & SQLQStr(Itm.ArtistName)
SDB.database.execSQL(sql)
' This will affect ALL instances of this artist, including album artist, and on other tracks.
artistNames.add str, str
End If
Next 'itm
For Each itm In holdAlbumArtist
str = holdAlbumArtist.item(itm)
If Not items.exists(itm) Then
items.add itm, itm
End If
itm.albumArtistName = str
If Not artistNames.exists(str) Then
sql = "UPDATE Artists SET Artists.Artist = " & SQLQStr(str) & " WHERE Artists.Artist= " & SQLQStr(Itm.ArtistName)
SDB.database.execSQL(sql)
artistNames.add str, str
End If
Next 'itm
For Each itm In holdAlbum
str = holdAlbum.item(itm)
If Not items.exists(itm) Then
items.add itm, itm
End If
itm.albumName = str
If Not albumNames.exists(str) Then
sql = "UPDATE Albums SET Albums.Album = " & SQLQStr(str) & " WHERE Albums.Album= " & SQLQStr(Itm.AlbumName)
SDB.database.execSQL(sql)
' This will affect ALL instances of this album, including other tracks.
albumNames.add str, str
End If
Next 'itm
For Each itm In holdTitle
str = holdTitle.item(itm)
If Not items.exists(itm) Then
items.add itm, itm
End If
itm.title = str
Next 'itm
For Each itm In holdGenre
str = holdGenre.item(itm)
If Not items.exists(itm) Then
items.add itm, itm
End If
itm.genre = str
Next 'itm
For Each itm In holdTrackOrder
str = holdTrackOrder.item(itm)
If Not items.exists(itm) Then
items.add itm, itm
End If
itm.trackOrder = str
Next 'itm
Dim list
Set list = SDB.NewSongList
For Each itm In items
list.Add(itm)
Next
list.UpdateAll
Set items = nothing
CloseDown
End Sub
'////////////////////////////////////
'// BASIC REPORT UTILITY FUNCTIONS //
'////////////////////////////////////
Function MapField(fld)
If fld="" Then
MapField = " "
Else
MapField = HtmlEncode(fld)
End If
End Function
Function outField (fixed, normal)
If fixed = normal Then
outField = "<td>" & MapField(normal) & "</td>" & vbcrlf
Else
outField = "<td class=""highlight"" title=""" & SDB.Localize("Old Value: ") & Chr(13) & HtmlEncode(normal) & """>" & MapField(fixed) & "</td>" & vbcrlf
End If
End Function
Function Style()
styleOn = Not styleOn
If styleOn Then
Style = ""
Else
Style = " class=""Dark"""
End If
End Function
Function SQLQStr(Str)
SQLQStr = "'" & Replace(Str, "'", "''") & "'"
End Function
Function QStr(Str)
QStr = """" & Str & """"
End Function
Function HtmlEncode(original)
Dim hold
original = Replace(original, "&", "&")
Dim i : i = 1
Dim length : length = Len(original)
Dim it, lt
Do While i <= length
lt = Mid(original, i, 1)
it = AscW(lt)
If it < 128 Then
hold = hold & lt
Else
hold = hold & "&#" & CStr(it) & ";"
End If
i = i + 1
Loop
hold = Replace(hold, " ", " ")
hold = Replace(hold, "<", "<")
hold = Replace(hold, ">", ">")
hold = Replace(hold, """", """)
HtmlEncode = hold
End Function
Function uppercase(s)
If Left(s,1) = "'" And Len(s) > 1 Then
uppercase = Left(s,1)&UCase(Mid(s,2,1))&LCase(Mid(s,3))
Else
uppercase = UCase(Mid(s,1,1))&LCase(Mid(s,2))
End If
End Function
Function fixUp(s, prevChars, nextChar)
Dim forceIndex, littleIndex, i
Dim capMe, allCaps, foreignPref
Dim upcased, littleUpped, forceUpped
forceIndex = -1
littleIndex = -1
capMe = false
allCaps = false
upcased = UCase(s)
foreignPref = isForeignPref.test(s)
For i = 0 to UBound(forceCapList)
forceUpped = UCase(forceCapList(i))
If UCase(forceCapList(i)) = upcased Or forceUpped = upcased & nextChar Then
forceIndex = i
Exit For
End If
Next 'i
For i = 0 to UBound(littleWordList)
littleUpped = UCase(littleWordList(i))
If littleUpped = upcased Or littleUpped = upcased & nextChar Then
littleIndex = i
Exit For
End If
Next 'i
If forceIndex >= 0 Then
s = forceCapList(forceIndex)
Else
If Len(s) = 1 And nextChar = "." Then
' if it's a single character followed by a period (an initial), caps it
allCaps = True
ElseIf Not vowels.test(s) And Not cardinal.test(s) Then
' if it's all consonants, no vowels, and not a cardinal number, caps it
allCaps = True
ElseIf romanNumerals.test(s) And UCase(s) <> "MIX" And UCase(s) <> "MI" And UCase(s) <> "DI" Then
' if it's roman numerals (and not 'mix' or 'di' which are valid roman numerals), caps it
allCaps = True
ElseIf prevChars = "" Or (nextChar = "" And Not foreignPref) Then
'if it's the first or last word, cap it
capMe = True
ElseIf Not whiteSpace.test(prevChars) Or (nextChar <> "" And InStr(")}]",nextChar)) Then
' if it follows a punctuation mark (with or without spaces) or if it's before a close-bracket, cap it
capMe = True
ElseIf littleIndex < 0 And Not foreignPref Then
' if it's not on the 'little word' list, cap it
capMe = True
End If
If allCaps Then
s = UCase(s)
ElseIf capMe Then
s = uppercase(s)
Else
s = LCase(s)
End If
If isMc.Test(s) And Len(s) > 2 Then
' if it's Mc or O', cap the 3rd character (this assumes no names like McA)
s = Mid(s,1,2)&UCase(Mid(s,3,1))&LCase(Mid(s,4))
End If
If foreignPref Then
' if it's l', d' or dell', lowercase the first letter and uppercase the first letter after the apostrophe
Dim pos
pos = InStr(s,"'")
If pos < 1 Then
pos = InStr(s,"`")
End If
If pos > 0 And pos < Len(s) Then
s = Mid(s,1,pos)&UCase(Mid(s,pos+1,1))&LCase(Mid(s,pos+2))
End If
End If
End If
fixUp = s
End Function
Function updateCase(s)
Dim currentWord, result, fixed, theChar, lastNonWordChars
Dim forceIndex
Dim i
currentWord = ""
result = ""
lastNonWordChars = ""
For i = 1 to Len(s)
theChar = Mid(s,i,1)
If alphaNum.test(theChar) Then
currentWord = currentWord & theChar
Else
If currentWord <> "" Then
fixed = fixUp(currentWord,lastNonWordChars,theChar)
If Right(fixed,1) = theChar Then 'handle stuff like w/
fixed = Left(fixed,Len(fixed)-1)
lastNonWordChars = ""
Else
lastNonWordChars = theChar
End If
result = result & fixed
currentWord = ""
Else
lastNonWordChars = lastNonWordChars & theChar
End If
result = result & theChar
End If
Next 'i
If Len(currentWord) > 0 Then
result = result & fixUp(currentWord,lastNonWordChars,"")
End If
updateCase = result
End Function
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
-
- Posts: 312
- Joined: Mon Apr 03, 2006 9:11 am
- Location: Denver, CO
Thanks a ton Steegy! This'll greatly ease my manual tagging!
-Brian
Edit: Just tried this and I think something's a little wonky. I tried to correct one tag:
Pillow of Your Bones - Chris Cornell
The new script tried to change it to the incorrect:
Pillow Of Your Bones - Chris Cornell.
I tried it on a couple of others and it still wanted to capitalize the lower-case words like this as well. Any ideas?
BTW - i really like how it just shows tags that are going to be changed instead of all of them.
-Brian
Edit: Just tried this and I think something's a little wonky. I tried to correct one tag:
Pillow of Your Bones - Chris Cornell
The new script tried to change it to the incorrect:
Pillow Of Your Bones - Chris Cornell.
I tried it on a couple of others and it still wanted to capitalize the lower-case words like this as well. Any ideas?
BTW - i really like how it just shows tags that are going to be changed instead of all of them.
MM Gold since 2006
@martialartsguy: Yes, like I said I posted my own edited copies of the scripts, using my preferences. To change the behaviour of the Case Modify part, you have to change the script settings to suit your own preferences.
For starters, you can remove the ' characters in front of these lines:That will make sure that some words are always in lowercase. You can also add/remove entries from these lists as you wish.
@masterstanf2k: Well, I merely copied the code from the Case Modify script in the PTE script, so I don't deserve any credit for this. However I appreciate it so thank you.
I said it was confusing didn't I? The last code post is the full script code. See the FAQ (Normal scripts that don't have an installer) for help on how to install it.
For starters, you can remove the ' characters in front of these lines:
Code: Select all
Dim littleWordString
'littleWordString = "a|an|and|at|de|del|di|du|e|el|en|et|for" & _
' "|from|la|le|in|n|'n|n'|'n'|o'|'o'|of|or" & _
' "|por|the|to|un|une|und|with|y|'k"
@masterstanf2k: Well, I merely copied the code from the Case Modify script in the PTE script, so I don't deserve any credit for this. However I appreciate it so thank you.
I said it was confusing didn't I? The last code post is the full script code. See the FAQ (Normal scripts that don't have an installer) for help on how to install it.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
-
- Posts: 312
- Joined: Mon Apr 03, 2006 9:11 am
- Location: Denver, CO
Here's the supposedly "grammatically correct" listings for capitalization in song titles, if anyone cares:
Code: Select all
Dim littleWordString
littleWordString = "a|an|the|and|but|or|nor|at|by|for|from|in|into" & _
"|of|off|on|onto|out|over|to|up|with|as|ft|pres|vs"
Dim forceCapString
forceCapString = "Beat Up|Blow Out|Break Down|Break Into|Break Up|Bring Up|Call Off|Call On|Call Up" & _
"|Carry On|Come Back|Come Down|Come On|Come Out|Come Over|Do Over|Fill In|Fill Out" & _
"|Find Out|Get Along|Get Around|Get By|Get Over|Get Through|Get Up|Give Back|Give Up" & _
"|Go Along|Go Away|Go On|Go Over|Hand In|Hang Up|Hold On|Keep On|Keep Up|Leave Out|Let Down" & _
"|Look For|Look Into|Look Like|Look Out|Look Over|Look Up|Make Out|Make Up|Pack Up|Pass Out" & _
"|Pick Out|Pick Up|Put Away|Put Off|Put On|Put Out|Put Up|Roll Over|Run Into|Run Out|Run Over" & _
"|Show Up|Take After|Take Back|Take Off|Take On|Take Up|Talk Back|Talk Over|Throw Away|Try On" & _
"|Turn Down|Turn In|Turn Off|Turn On|Use Up|Wait On|Mrs|Mr|Ms|Prof|Dr|Gen|Rep|Sen|St|Sr|Jr"