Lyricsplugin Search Script
-
- Posts: 70
- Joined: Tue Feb 12, 2008 7:11 pm
Whoops. I just wrote my own fix for the delay on this thing only to see someone else did the same thing already and posted it in this thread. Anyway, I wrote mine on whether lyrics was populated and noticed that lyrics is always an object, so IsObject(lyrics) is true whether it has accessible data or not. Future work on this code may want to use something like "NOT(lyrics IS Nothing)". Something to consider.
If I can find the time, I may start messing around with a batch lyric updater as well.
das
If I can find the time, I may start messing around with a batch lyric updater as well.
das
-
- Posts: 70
- Joined: Tue Feb 12, 2008 7:11 pm
OK, I gave it a shot. The right events and methods don't seem to be exposed to do this properly, and you can't even display lyrics in the track listing to know if you got it right. In fact, this is almost certainly not the correct interface to use for batch lyric updating ... but I did it anyway. It's a heck of a lot quicker to code this than write something as involved as the Batch Album script.
Anyway, here's the code. You should probably backup your database (twice ) since I've only been messing around with this for about ... well, since my last post 45 minutes ago. And maybe 2 of those minutes were spent testing it. This code is most certainly a "hack", and you may want to stick to just doing an album at a time until we see how this reacts to large file lists. Essentially, all I did was force the search dropdown to loop through every file and store the lyrics one-by-one. Depending on your connection speed, it should go rather quickly (and if you have the sounds turned on, you'll hear quite a bit of page-load clicking). When it's done, all the tracks will be automatically checked. There's no way I could see to preview what's going to happen when you click Auto-Tag, so there's some faith involved here, but it seems to work OK.
Proceed with caution
Edit: For fun, I threw in a second-chance routine. If it finds no lyrics and has a "(" or "[" somewhere other than the beginning of the track title, it tries a second time truncating the parenthetical. This works for most "live" or "acoustic" or "featuring" or whatever. It's possible this will find some false positives, but keep in mind that it only does it if it can't find lyrics otherwise, and it's still searching by artist. The false positive rate is likely extremely low.
Also, if there's an ampersand in the artist or title, the url string gets muddled, so I replace them with the word "and". The plugin server seems to respond more favorably that way.
das
Anyway, here's the code. You should probably backup your database (twice ) since I've only been messing around with this for about ... well, since my last post 45 minutes ago. And maybe 2 of those minutes were spent testing it. This code is most certainly a "hack", and you may want to stick to just doing an album at a time until we see how this reacts to large file lists. Essentially, all I did was force the search dropdown to loop through every file and store the lyrics one-by-one. Depending on your connection speed, it should go rather quickly (and if you have the sounds turned on, you'll hear quite a bit of page-load clicking). When it's done, all the tracks will be automatically checked. There's no way I could see to preview what's going to happen when you click Auto-Tag, so there's some faith involved here, but it seems to work OK.
Proceed with caution
Code: Select all
Dim Browser
Dim Tmr
Dim Current
Dim ResultCounter
Dim TryAgain
Sub StartSearch(Panel, SearchTerm, SearchArtist, SearchAlbum)
TryAgain = 0
Set Browser = SDB.UI.NewActiveX(Panel, "Shell.Explorer")
Browser.Common.Align = 5
Dim Tracks : Set Tracks = SDB.Tools.WebSearch.NewTracks
Dim Results : Set Results = SDB.NewStringList
For i = 0 to Tracks.Count-1
Results.Add Tracks.item(i).ArtistName & " - " & Tracks.item(i).Title
Next
SDB.Tools.WebSearch.SetSearchResults Results
If Results.Count > 0 Then
ResultCounter = 0
SDB.Tools.WebSearch.ResultIndex = ResultCounter
End If
End Sub
Sub ShowResult(ResultID)
If (ResultID >= 0) Then
Browser.SetHTMLDocument ""
With SDB.Tools.WebSearch
.TrackChecked(ResultID) = True
title = .NewTracks.Item(ResultID).Title
artist = .NewTracks.Item(ResultID).ArtistName
End With
Dim pos : pos = InStr(artist, ";")
If pos > 1 Then
artist = Mid(artist, 1, pos - 1)
End If
url = "http://www.lyricsplugin.com/plugin/?title=" & Escape(title) & "&artist=" & Escape(artist)
Browser.Interf.Navigate url
Set Tmr = SDB.CreateTimer(40)
Script.RegisterEvent Tmr, "OnTimer", "WebsiteLoaded"
End If
End Sub
Sub WebsiteLoaded(Timer)
Script.UnregisterEvents Tmr
Set Tmr = Nothing
If Len(Browser.Interf.LocationURL) < 10 Then ' A trick - wait until navigation to the search results page starts
Set Tmr = SDB.CreateTimer(40)
Script.RegisterEvent Tmr, "OnTimer", "WebsiteLoaded"
Exit Sub
End If
If Browser.Interf.ReadyState = 1 Or Browser.Interf.Busy Then
Set Tmr = SDB.CreateTimer(40)
Script.RegisterEvent Tmr, "OnTimer", "WebsiteLoaded"
Exit Sub
End If
Dim Doc : Set Doc = Browser.Interf.Document
If IsObject(Doc) Then
Set lyrics = Doc.getElementById("lyrics")
If Not(lyrics IS Nothing) Then
If lyrics.innerText = "" Then
Dim NewTitle : NewTitle = SDB.Tools.WebSearch.NewTracks.Item(ResultCounter).Title
Dim NewArtist : NewArtist = SDB.Tools.WebSearch.NewTracks.Item(ResultCounter).ArtistName
If TryAgain > 0 Or (InStr(NewTitle, "(") = 0 And InStr(NewTitle, "[") = 0) Then
TryAgain = 0
Else
TryAgain = 1
Dim pos : pos = 0
pos = InStr(NewTitle, "(")
If pos > 1 Then
NewTitle = Mid(NewTitle, 1, pos - 1)
End If
pos = InStr(NewTitle, "[")
If pos > 1 Then
NewTitle = Mid(NewTitle, 1, pos - 1)
End If
NewTitle = LTrim(RTrim(NewTitle))
Browser.SetHTMLDocument ""
url = "http://www.lyricsplugin.com/plugin/?title=" & Escape(NewTitle) & "&artist=" & Escape(NewArtist)
Browser.Interf.Navigate url
Set Tmr = SDB.CreateTimer(40)
Script.RegisterEvent Tmr, "OnTimer", "WebsiteLoaded"
Exit Sub
End If
End If
TryAgain = 0
SDB.Tools.WebSearch.NewTracks.Item(ResultCounter).Lyrics = lyrics.innerText
If ResultCounter < SDB.Tools.WebSearch.NewTracks.Count - 1 Then
ResultCounter = ResultCounter + 1
SDB.Tools.WebSearch.ResultIndex = ResultCounter
End If
End If
End If
End Sub
Sub FinishSearch(Panel)
Browser.Common.DestroyControl
Set Browser = Nothing
End Sub
Also, if there's an ampersand in the artist or title, the url string gets muddled, so I replace them with the word "and". The plugin server seems to respond more favorably that way.
das
Last edited by das Monkey on Sat Mar 01, 2008 11:17 am, edited 2 times in total.
-
- Posts: 1119
- Joined: Mon Apr 09, 2007 12:03 am
- Location: Boulder, Colorado, USA
Thanks Das!!!
Worked like a charm for me.
Not to worried about the accuracy aspect of auto tagging in bulk. The success rate with the LyricsPlugin is so high that I would imagine very few will get tagged wrong. And if a few do get the wrong lyric, its is no big deal to just fix them as they are encountered in normal Monkey usage.
Thanks, again.
Worked like a charm for me.
Not to worried about the accuracy aspect of auto tagging in bulk. The success rate with the LyricsPlugin is so high that I would imagine very few will get tagged wrong. And if a few do get the wrong lyric, its is no big deal to just fix them as they are encountered in normal Monkey usage.
Thanks, again.
D Rock
MediaMonkeyGoldv3.0.3.1183
Vista Home Basic|4thGen 20GPod
Zune Small Player Skin w/ Aqua 4 Player Mod
Backup | Last FM Node | Scrobbler DJ | TopTracks | StayInSameStyleDJ
RadioDJ | RadioFreeMonkey | PrettyPictures | MiniLyricsEmbedder
LyricsViewer | Lyricator | LyricsPlugin | VisualizationEmbedder | MonkeyRok
RightClickForWeb | WebSearchPanels | WebNodes | MagicNodes | FavoritesNodes
NowPlayingArtNode |AutoRateAccurate | TaggingInconsistencies
AdvancedDuplicateFind&Fix | CaseModify | PlayHistory&Stats | Etc...
MediaMonkeyGoldv3.0.3.1183
Vista Home Basic|4thGen 20GPod
Zune Small Player Skin w/ Aqua 4 Player Mod
Backup | Last FM Node | Scrobbler DJ | TopTracks | StayInSameStyleDJ
RadioDJ | RadioFreeMonkey | PrettyPictures | MiniLyricsEmbedder
LyricsViewer | Lyricator | LyricsPlugin | VisualizationEmbedder | MonkeyRok
RightClickForWeb | WebSearchPanels | WebNodes | MagicNodes | FavoritesNodes
NowPlayingArtNode |AutoRateAccurate | TaggingInconsistencies
AdvancedDuplicateFind&Fix | CaseModify | PlayHistory&Stats | Etc...
-
- Posts: 5559
- Joined: Wed Feb 07, 2007 11:07 pm
- Location: New Jersey, USA
- Contact:
The plugin is working like a charm for me also. I have one small question, does the original or the modified script take into account multiple artists which are separated by a ';'? If not, is there a way for the script to only query based on the first artist? I have over a 1000 that no site can find and over 90% of them are due to the multiple artists.
Nyn
Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
-
- Posts: 70
- Joined: Tue Feb 12, 2008 7:11 pm
drjboulder, happy to help. I just ran it on a batch of a few thousand tracks, and aside from a brief clog trying to change all those tags at once, it ran surprisingly smoothly.
nynaevelan, I tweaked the code a little bit for you (recopy it from the post above). I can't think of a single case where the artist name will legitimately have a semi-colon in it and only be found if it's included, so I didn't bother with a "try again" approach. I just truncate the artist name at the first semi-colon regardless. It may not solve all your problems, but it should snag more than a few and is unlikely to break anything else.
All my files are tagged now, so my motivation factor is significantly less , but if I get some time, maybe I'll write a brute force search that tries every artist in the list until if finds something.
Let me know if the change I made has helped. If not, we can try another approach.
das
nynaevelan, I tweaked the code a little bit for you (recopy it from the post above). I can't think of a single case where the artist name will legitimately have a semi-colon in it and only be found if it's included, so I didn't bother with a "try again" approach. I just truncate the artist name at the first semi-colon regardless. It may not solve all your problems, but it should snag more than a few and is unlikely to break anything else.
All my files are tagged now, so my motivation factor is significantly less , but if I get some time, maybe I'll write a brute force search that tries every artist in the list until if finds something.
Let me know if the change I made has helped. If not, we can try another approach.
das
-
- Posts: 5559
- Joined: Wed Feb 07, 2007 11:07 pm
- Location: New Jersey, USA
- Contact:
Hi Das:
It's working, it was able to find over 200 that it wasn't finding before but I have a lot of manual work ahead of me, but I'm a lot closer, thanks for the update.
Nyn
It's working, it was able to find over 200 that it wasn't finding before but I have a lot of manual work ahead of me, but I'm a lot closer, thanks for the update.
Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
Alright that is just awesome! Thanks so much.das Monkey wrote:OK, I gave it a shot.
MM Gold 3.0.3.1183 : Vista HP SP1 (x86) : Zen Stone (2GB)
Zekton: An original MM3 skin by Eyal.
Scripts in Use: Add/Remove PlayStat | Auto Album DJ | AutoRateAccurate | Backup
Case & Leading Zero Fixer | Classification & Genre Changer | Clean Scripts.ini | Clear
Field | Custom Report | Discogs Auto-Tag Web Search | Forget Crossfade | Invert
Selection/Select None | Last 100... | Lyricator | Lyrics to Instrumental | MonkeyRok
MusicBrainz Tagger | My Custom Nodes | Now Playing Art Node | Play History & Stats
Right Click for Reports | Right Click for Scripts | Right Click for Web | Stop After Current
WebNodes
I think I found a glitch:
I just tried to tag Bob Dylan - Masterpieces but when it got to Rainy Day Women #12 & 35 the script stalled and I couldn't tag any of the ones previously found. I went back and selected everything but that track and it worked fine.
I just tried to tag Bob Dylan - Masterpieces but when it got to Rainy Day Women #12 & 35 the script stalled and I couldn't tag any of the ones previously found. I went back and selected everything but that track and it worked fine.
MM Gold 3.0.3.1183 : Vista HP SP1 (x86) : Zen Stone (2GB)
Zekton: An original MM3 skin by Eyal.
Scripts in Use: Add/Remove PlayStat | Auto Album DJ | AutoRateAccurate | Backup
Case & Leading Zero Fixer | Classification & Genre Changer | Clean Scripts.ini | Clear
Field | Custom Report | Discogs Auto-Tag Web Search | Forget Crossfade | Invert
Selection/Select None | Last 100... | Lyricator | Lyrics to Instrumental | MonkeyRok
MusicBrainz Tagger | My Custom Nodes | Now Playing Art Node | Play History & Stats
Right Click for Reports | Right Click for Scripts | Right Click for Web | Stop After Current
WebNodes
-
- Posts: 1119
- Joined: Mon Apr 09, 2007 12:03 am
- Location: Boulder, Colorado, USA
It stalled on "#" for me, also had some song titles with [*] that it did not like. Was working from an auto play list. So, I just edited play list to exclude those.spacefish wrote:I think I found a glitch:
I just tried to tag Bob Dylan - Masterpieces but when it got to Rainy Day Women #12 & 35 the script stalled and I couldn't tag any of the ones previously found. I went back and selected everything but that track and it worked fine.
Managed to do about 1,700 songs. Still have around 800 with no lyrics.
Think that I shall not try synching my Ipod before work tomorrow!
D Rock
MediaMonkeyGoldv3.0.3.1183
Vista Home Basic|4thGen 20GPod
Zune Small Player Skin w/ Aqua 4 Player Mod
Backup | Last FM Node | Scrobbler DJ | TopTracks | StayInSameStyleDJ
RadioDJ | RadioFreeMonkey | PrettyPictures | MiniLyricsEmbedder
LyricsViewer | Lyricator | LyricsPlugin | VisualizationEmbedder | MonkeyRok
RightClickForWeb | WebSearchPanels | WebNodes | MagicNodes | FavoritesNodes
NowPlayingArtNode |AutoRateAccurate | TaggingInconsistencies
AdvancedDuplicateFind&Fix | CaseModify | PlayHistory&Stats | Etc...
MediaMonkeyGoldv3.0.3.1183
Vista Home Basic|4thGen 20GPod
Zune Small Player Skin w/ Aqua 4 Player Mod
Backup | Last FM Node | Scrobbler DJ | TopTracks | StayInSameStyleDJ
RadioDJ | RadioFreeMonkey | PrettyPictures | MiniLyricsEmbedder
LyricsViewer | Lyricator | LyricsPlugin | VisualizationEmbedder | MonkeyRok
RightClickForWeb | WebSearchPanels | WebNodes | MagicNodes | FavoritesNodes
NowPlayingArtNode |AutoRateAccurate | TaggingInconsistencies
AdvancedDuplicateFind&Fix | CaseModify | PlayHistory&Stats | Etc...
-
- Posts: 70
- Joined: Tue Feb 12, 2008 7:11 pm
Pounds are another query string key like the ampersand. Many of you probably know this already, but ampersands are used to indicate new elements in the list, and pounds are used to reference an anchor on the page. When I fixed the ampersand problem, I should have just fixed the pound too. It probably just needs to be replaced with an empty string. I'm not sure what the deal with the asterisk is. I'll take a look at it later today and post a fix.
drjboulder, could you post an example title/artist that isn't working right with the asterisk? Thanks.
das
drjboulder, could you post an example title/artist that isn't working right with the asterisk? Thanks.
das
-
- Posts: 70
- Joined: Tue Feb 12, 2008 7:11 pm
I tested a few combinations, and lyricsplugin.com seems able to handle the symbols, so I'm just escaping them in the url. Ampersands and pounds should work now. I'll mess around with a brute-force multi-artist script and see where that goes.
If anyone has scenarios that are not working, please post the specifics of the title/artist and how your tag is structured. I'm sure there are many scenarios I don't have in my collection and simply haven't thought of.
If anyone's interested, I also fixed Missing Lyrics Node to work with MM3 and added some code to ignore classical, film scores, podcasts, etc. I use the node in combination with this script to clean up my lyrics.
das
If anyone has scenarios that are not working, please post the specifics of the title/artist and how your tag is structured. I'm sure there are many scenarios I don't have in my collection and simply haven't thought of.
If anyone's interested, I also fixed Missing Lyrics Node to work with MM3 and added some code to ignore classical, film scores, podcasts, etc. I use the node in combination with this script to clean up my lyrics.
das
Works, thanks!das Monkey wrote:Ampersands and pounds should work now.
MM Gold 3.0.3.1183 : Vista HP SP1 (x86) : Zen Stone (2GB)
Zekton: An original MM3 skin by Eyal.
Scripts in Use: Add/Remove PlayStat | Auto Album DJ | AutoRateAccurate | Backup
Case & Leading Zero Fixer | Classification & Genre Changer | Clean Scripts.ini | Clear
Field | Custom Report | Discogs Auto-Tag Web Search | Forget Crossfade | Invert
Selection/Select None | Last 100... | Lyricator | Lyrics to Instrumental | MonkeyRok
MusicBrainz Tagger | My Custom Nodes | Now Playing Art Node | Play History & Stats
Right Click for Reports | Right Click for Scripts | Right Click for Web | Stop After Current
WebNodes