Hi, just in case you've already seen my code mods and wonder why I've deleted them, it's because I've been tinkering around and tidied the mods up quite considerably, so here's my re-modified code:
First off, my code for dealing with titles such as:
(12") Blue Monday where we need to remove the leading (12")<space> string before submitting the search query - this requires changes in two Subs: SearchText and SearchButton and the Function CleanSearchString
In SearchText() I changed line 317 which from
to
Code: Select all
sTrack = CleanSearchString(oSongData.title)
The second sub that requires changing is SearchButton(oPnl) changes are as follows:
Lines 1173 & 1174 were changed from
Code: Select all
sArt = oSongData.ArtistName
sTrack = oSongData.Title
To this
Code: Select all
sArt = CleanSearchString(oSongData.ArtistName)
sTrack = CleanSearchString(oSongData.Title)
For no other reason than to reduce calls to the CleanSearchString function I modified the Select Case block accordingly to this:
Code: Select all
Select Case engine
Case 1
url = "www.allmusic.com/search/all/" & URLEncodeUTF8(arttrack)
Case 2
url = "http://www.discogs.com/search?artist=" & URLEncodeUTF8(sArt) & "&track=" & URLEncodeUTF8(sTrack)
Case 3
url = "http://www.google.com/search?as_q=" & URLEncodeUTF8(arttrack)' & "&as_eq=lyrics"
Case 4
url = "http://www.last.fm/search?q=" & URLEncodeUTF8(arttrack)
Case 5
url = "http://www.musicbrainz.org/search?query=" & Chr(34) & URLEncodeUTF8(sTrack) & Chr(34) & "+AND+artist:" & Chr(34) & URLEncodeUTF8(sArt) & Chr(34) & "&type=recording"
Case 6
url = "http://www.45cat.com/45_search.php?sq=" & URLEncodeUTF8(arttrack)
Case Else
url = "http://www.discogs.com/search?q=" & URLEncodeUTF8(discogs)
End Select
The changes to the CleanSearchString function was quite dramatic so I've posted the whole function below:
Code: Select all
Function CleanSearchString(Text)
Dim sTrLen, sTrText
sTrText = Text
sTrText = Replace(sTrText,")", " ") 'remove parenthesis to avoid search errors (discogs bug)
sTrText = Replace(sTrText,"(", " ") 'also clean other unnecessary characters
sTrText = Replace(sTrText,"[", " ")
sTrText = Replace(sTrText,"]", " ")
sTrText = Replace(sTrText,"@", " ")
sTrText = Replace(sTrText,"_", " ")
sTrText = Replace(sTrText,"?", " ")
sTrText = Replace(sTrText,"-", " ")
sTrText = Replace(sTrText,",", "")
sTrText = Replace(sTrText,chr(34), "")
sTrText = Replace(sTrText,"`", "'") 'added by wxdude, fix accent grave --> apostrophe
sTrText = Replace(sTrText,"\B4", "'") 'added by wxdude. fix acute accent --> apostrophe
sTrText = Replace(sTrText," ", " ") 'added by wxdude. set double spaces to single
If left(sTrText,3) = " 12" Then
sTrLen = Len(sTrText) -4
CleanSearchString = Right(sTrText, sTrLen)
Exit Function
End If
CleanSearchString = sTrText
End Function
One change you may notice in the CleanSearchString function is that I removed line 1547 completely.
Code: Select all
CleanSearchString = Replace(CleanSearchString,".", " ")
I did this as the search would fail on a track such as H.O.L.L.A.N.D by The Bluebells (B side of I'm Falling), which would be queried as H O L L A N D
Changing the code to replace a period with a null value, this would then be queried as HOLLAND and the search completes successfully, so far I've had no trouble where an artist or title field has a period in them such D.J. - Feat. - R.E.M etc
---------
Here are my mods for writing the original date to the comments tag, this also leaves the original date field and comments tag blank instead of writing 9999 when no results are found. PLEASE NOTE as I only use the year in my date fields I made no changes to the day or month code, although I see no reason why the changes couldn't be expanded to include those fields.
All the changes are made in the sub, ProcessAlbum.
Each of the four lines 1137, 1141, 1147 & 1151 were changed from
Code: Select all
oSongList.item(i-1).year = newyear
to this
Code: Select all
If newyear <> 9999 Then oSongList.item(i-1).year = newyear
The following was added at line 1162 between the "End If" and "Next" statements
Code: Select all
If newyear <> 9999 Then oSongList.item(i-1).Comment = "Year of release: " & newyear
If oSongList.item(i-1).Comment <> "Year of release: " & newyear And oSongList.item(i-1).Comment <> "" Then oSongList.item(i-1).Comment = ""
Another point of interest, I'm not sure whether my mods are the cause but when processing a huge batch of tracks I very occasionally got an error which halted the script but without any information as to what caused the error. I've very crudely got around it by adding "On Error Resume Next" on line 76, so far with no obvious negative effects
