Code: Select all
'//////////////////////
'// ENHANCER METHODS //
'//////////////////////
Function ChangeCharacters(Tag)
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")
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
'/////////////////////////
'// 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
'//////////////////////////
'// 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 = " & rdQS(str) & " WHERE Artists.Artist= " & rdQS(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 = " & rdQS(str) & " WHERE Artists.Artist= " & rdQS(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 = " & rdQS(str) & " WHERE Albums.Album= " & rdQS(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 MapXML(original)
Dim hold
hold = Replace(original, "&", "&")
hold = Replace(hold, " ", " ")
hold = Replace(hold, "<", "<")
hold = Replace(hold, ">", ">")
hold = Replace(hold, """", """)
Dim i
i=1
While i<=Len(hold)
If (AscW(Mid(hold, i, 1))>127) Then
hold = Mid(hold, 1, i-1)+"&#"+CStr(AscW(Mid(hold, i, 1)))+";"+Mid(hold, i+1)
End If
i=i+1
WEnd
MapXML = hold
End Function
Function MapField(fld)
If fld="" Then
MapField = " "
Else
MapField = MapXML(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) & MapXML(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 rdQS(UnquotedString)
rdQS = "'" & Replace(UnquotedString, "'", "''") & "'"
End Function
If you have other personal enhancements that you would like to share, please do ...