by limex » Mon Jan 11, 2010 5:31 pm
I modded the script because ...
- '&' in the Search String (appearing very often in the Artist Tag) is destroying the search string. Webpages expect %26 instead to work
- I have many songs with brackets in the title. i.e. Madonna - Holiday (Megamix). But you don't want to be looking for exactly the Megamix. Madonna - Holiday would be sufficient in many cases. So I stripped the bracketed content.
Here you go:
Find the function ReplaceTokens inside Websearch.vbs and replace with the code below. Feel free to comment out the delete bracket feature.
Code: Select all
Function ReplaceTokens(ByVal URL, ByVal Song)
'limex: replace & with the code and delete everything inside brackets
Dim clean
Dim openbracket,closebracket, cleanleft, cleanright
With Song
clean = Replace(.ArtistName,"&","%26")
URL = Replace(URL, "%artist%", clean)
clean = Replace(.Title,"&","%26")
'delete brackets content start
'comment this section if feature is unwanted
openbracket = InStr (clean, "(")
closebracket = InStr (clean, ")")
If openbracket > 0 And closebracket > 1 And openbracket < closebracket Then
cleanleft = Trim(Left(clean, openbracket -1))
cleanright = Trim(Mid (clean, closebracket +1))
clean = Trim (cleanleft & " " & cleanright)
End If
'delete brackets content end
URL = Replace(URL, "%title%", clean)
clean = Replace(.AlbumName,"&","%26")
URL = Replace(URL, "%album%", clean)
clean = Replace(.AlbumArtistName,"&","%26")
URL = Replace(URL, "%albumartist%", clean)
End With
ReplaceTokens = URL
End Function
I modded the script because ...
- '&' in the Search String (appearing very often in the Artist Tag) is destroying the search string. Webpages expect %26 instead to work
- I have many songs with brackets in the title. i.e. Madonna - Holiday (Megamix). But you don't want to be looking for exactly the Megamix. Madonna - Holiday would be sufficient in many cases. So I stripped the bracketed content.
Here you go:
Find the function ReplaceTokens inside Websearch.vbs and replace with the code below. Feel free to comment out the delete bracket feature.
[code] Function ReplaceTokens(ByVal URL, ByVal Song)
'limex: replace & with the code and delete everything inside brackets
Dim clean
Dim openbracket,closebracket, cleanleft, cleanright
With Song
clean = Replace(.ArtistName,"&","%26")
URL = Replace(URL, "%artist%", clean)
clean = Replace(.Title,"&","%26")
'delete brackets content start
'comment this section if feature is unwanted
openbracket = InStr (clean, "(")
closebracket = InStr (clean, ")")
If openbracket > 0 And closebracket > 1 And openbracket < closebracket Then
cleanleft = Trim(Left(clean, openbracket -1))
cleanright = Trim(Mid (clean, closebracket +1))
clean = Trim (cleanleft & " " & cleanright)
End If
'delete brackets content end
URL = Replace(URL, "%title%", clean)
clean = Replace(.AlbumName,"&","%26")
URL = Replace(URL, "%album%", clean)
clean = Replace(.AlbumArtistName,"&","%26")
URL = Replace(URL, "%albumartist%", clean)
End With
ReplaceTokens = URL
End Function[/code]