Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

Updated code to pass through more characters un-encoded. This was required due to the downstream LyricsPlugin site being intolerant of encoded Extended Ascii. It also substantially improves cosmetics.

Tested with updated plugin url @44 in Lyricator.js and a large set of french language tracks with diacriticals in tags.

Re-tested abort cases to make sure they were still working.

@G-Diablo. Not a final fix. That needs to be made in Lyricator.js, but, a proof of concept. Good luck.

FYI: Current status of my Scripts\Auto\Lyricator.vbs:

Code: Select all

Option Explicit

Dim sPath : sPath = sdb.ApplicationPath & "Scripts\Auto\Lyricator.vbs"
Dim sHTML : sHTML = sdb.ApplicationPath & "Scripts\Lyricator\temp.html"
Dim sLoad : sLoad = sdb.ApplicationPath & "Scripts\Lyricator\loading.gif"

Const mmAnchorRight = 4
Const mmAnchorBottom = 8
Const mmAlignTop = 1
Const mmAlignBottom = 2
Const mmAlignClient = 5
Const mmListDropdown = 2
Const mmFormScreenCenter = 4

Sub Destroy
	SDB.Objects("LyricatorForm") = Nothing
	SDB.Objects("LyricatorWB") = Nothing
	SDB.Objects("LyricatorTracks") = Nothing
	SDB.Objects("LyricatorStatus") = Nothing
  Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
	
  fso.DeleteFile(sHTML)
End Sub

Sub OnClear(Btn)
	Dim tracks: Set tracks = SDB.Objects("LyricatorTracks")
  
	Dim i
	For i = 0 to tracks.count - 1
		tracks.Item(i).Lyrics = ""
		tracks.Item(i).UpdateDB
		tracks.Item(i).WriteTags
	Next
End Sub

Sub OnSave(Btn)
	Btn.Caption = SDB.Localize("Saving ...")
  Btn.Common.Enabled = False  

	Dim ini : Set ini = SDB.IniFile
	Dim TryAutoClose : TryAutoClose = ini.BoolValue("Lyricator", "TryAutoClose")

	Dim doc : Set doc = SDB.Objects("LyricatorWB").Interf.Document
	Dim tracks: Set tracks = SDB.Objects("LyricatorTracks")
	Dim status : Set status = SDB.Objects("LyricatorStatus")
  
  Dim cnt : cnt = 0
  
	Dim interval : interval = 1
	If tracks.count > 10000 Then
		interval = 100
	ElseIf tracks.count > 1000 Then
		interval = 25
	ElseIf tracks.count > 100 Then
		interval = 10
	End If
	
	Dim i
	For i = 0 to tracks.count - 1
		SDB.ProcessMessages

	  If (i + 1) Mod interval = 0 Then
			status.Caption = SDB.Localize("Writing " & (i+1) & "/" & (tracks.count+1) & " ...")
		End If
		
		Dim t : Set t = doc.getElementById(tracks.Item(i).ID)
		Dim d : Set d = t.getElementsByTagName("div")
		Dim c : Set c = d(0).getElementsByTagName("input")(0)
		
		If c.checked Then
			cnt = cnt + 1
			Dim l : l = Replace(d(3).innerHTML, "<BR>", vbNewLine)
			l = Replace(l, "<BR/>", vbNewLine)
			l = Replace(l, "<BR />", vbNewLine)
			tracks.Item(i).Lyrics = l
			tracks.Item(i).UpdateDB
			tracks.Item(i).WriteTags
		End If
		
	Next
	
	status.Caption = cnt & " Lyrics Saved"
	
	If TryAutoClose Then
		Destroy
	End If
End Sub

Sub OnCancel(Btn)
  Destroy
End Sub

Sub OnAbort(Btn)
	SDB.Objects("LyricatorWB") = Nothing

  Btn.Caption = SDB.Localize("C&lose")
  Btn.OnClickFunc = "OnCancel"
End Sub

Sub Lyricator
	Dim ini : Set ini = SDB.IniFile
	Dim UI : Set UI = SDB.UI
  Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
	
	Dim TryAllArtists : TryAllArtists = ini.BoolValue("Lyricator", "TryAllArtists")
	Dim TryCommaArtists : TryCommaArtists = ini.BoolValue("Lyricator", "TryCommaArtists")
	Dim TryCleanupWhiteSpace : TryCleanupWhiteSpace = ini.BoolValue("Lyricator", "TryCleanupWhiteSpace")
	Dim TryRejectSingleLine : TryRejectSingleLine = ini.BoolValue("Lyricator", "TryRejectSingleLine")

	Dim TrySingleLineSearch : TrySingleLineSearch = ini.StringValue("Lyricator", "TrySingleLineSearch")
	Dim TrySingleLineReplace : TrySingleLineReplace = ini.StringValue("Lyricator", "TrySingleLineReplace")

	Dim TryParensA : TryParensA = ini.BoolValue("Lyricator", "TryParensA")
	Dim TryBracketsA : TryBracketsA = ini.BoolValue("Lyricator", "TryBracketsA")
	Dim TryBracesA : TryBracesA = ini.BoolValue("Lyricator", "TryBracesA")
	Dim TryQuotesA : TryQuotesA = ini.BoolValue("Lyricator", "TryQuotesA")
	Dim TrySplitArrayA : TrySplitArrayA = ini.StringValue("Lyricator", "TrySplitArrayA")
	Dim TryBlackListA : TryBlackListA = ini.StringValue("Lyricator", "TryBlackListA")

	Dim TryParensT : TryParensT = ini.BoolValue("Lyricator", "TryParensT")
	Dim TryBracketsT : TryBracketsT = ini.BoolValue("Lyricator", "TryBracketsT")
	Dim TryBracesT : TryBracesT = ini.BoolValue("Lyricator", "TryBracesT")
	Dim TryQuotesT : TryQuotesT = ini.BoolValue("Lyricator", "TryQuotesT")
	Dim TrySplitArrayT : TrySplitArrayT = ini.StringValue("Lyricator", "TrySplitArrayT")
	Dim TryBlackListT : TryBlackListT = ini.StringValue("Lyricator", "TryBlackListT")

	Dim TryLyricsPlugin : TryLyricsPlugin = ini.BoolValue("Lyricator", "TryLyricsPlugin")
	Dim TryLyricsWiki : TryLyricsWiki = ini.BoolValue("Lyricator", "TryLyricsWiki")
	Dim TryLyricsSongs : TryLyricsSongs = ini.BoolValue("Lyricator", "TryLyricsSongs")
	
	Dim TryAutoClose : TryAutoClose = ini.BoolValue("Lyricator", "TryAutoClose")

  Dim FormWidth : FormWidth = 800
  Dim FormHeight : FormHeight = 600

  Dim frmMain : Set frmMain = UI.NewForm
  frmMain.Common.SetRect 50, 50, FormWidth, FormHeight
  frmMain.Common.MinWidth = 200
  frmMain.Common.MinHeight = 150
  frmMain.FormPosition = mmFormScreenCenter
  frmMain.Caption = SDB.Localize("Lyricator")
  frmMain.StayOnTop = True
	frmMain.Common.Visible = True
	
  Dim WB : Set WB = UI.NewActiveX(frmMain, "Shell.Explorer")
  WB.Common.Align = mmAlignClient
  WB.Common.ControlName = "WB"
  
  WB.Interf.Navigate(sLoad)

  Dim pnlFooter : Set pnlFooter = UI.NewPanel(frmMain)
  pnlFooter.Common.Align = mmAlignBottom
  pnlFooter.Common.Height = 37

'  Dim btnClear : Set btnClear = UI.NewButton(pnlFooter)
'  btnClear.Caption = SDB.Localize("Clear")
'  btnClear.Common.SetRect FormWidth - 305, 6, 85, 25
'  btnClear.Common.Anchors = mmAnchorRight & mmAnchorBottom
'  btnClear.UseScript = sPath
'  btnClear.OnClickFunc = "OnClear"
'  btnClear.Default = true

  Dim lblStatus : Set lblStatus = UI.NewLabel(pnlFooter)
  lblStatus.Caption = ""
  lblStatus.Common.SetRect FormWidth - 450, 16, 120, 25
  lblStatus.Common.Anchors = mmAnchorRight + mmAnchorBottom

  Dim btnSave : Set btnSave = UI.NewButton(pnlFooter)
  btnSave.Caption = SDB.Localize("&Save")
  btnSave.Common.SetRect FormWidth - 280, 6, 120, 25
  btnSave.Common.Anchors = mmAnchorRight + mmAnchorBottom
  btnSave.UseScript = sPath
  btnSave.OnClickFunc = "OnSave"
  btnSave.Default = true

  Dim btnCancel : Set btnCancel = UI.NewButton(pnlFooter)
  btnCancel.Caption = SDB.Localize("C&lose")
  btnCancel.Common.SetRect FormWidth - 150, 6, 120, 25
  btnCancel.Common.Anchors = mmAnchorRight + mmAnchorBottom
  btnCancel.UseScript = sPath
  btnCancel.OnClickFunc = "OnCancel"
  btnCancel.Cancel = true

	btnSave.Caption = SDB.Localize("Loading ...")
  btnSave.Common.Enabled = False  

	btnCancel.Caption = SDB.Localize("Abort")
  btnCancel.OnClickFunc = "OnAbort"

	SDB.Objects("LyricatorStatus") = lblStatus
	SDB.Objects("LyricatorForm") = frmMain
	SDB.Objects("LyricatorWB") = WB

  Dim tracks : Set tracks = SDB.SelectedSongList
  
	Dim html : html = ""
	
	html = html & "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"
	html = html & "<html>"
	html = html & "	<head>"
	html = html & "		<script type=""text/javascript"" src=""moo.js""></script>"
	html = html & "		<script type=""text/javascript"" src=""lyricator.js""></script>"
	html = html & "		<link type=""text/css"" rel=""stylesheet"" href=""lyricator.css"" />"
	
	html = html & "<script type=""text/javascript"">"
	If TryAllArtists Then html = html & "tryAllArtists = true;" End If
	If TryCommaArtists Then html = html & "tryCommaArtists = true;" End If
	If TryCleanupWhiteSpace Then html = html & "tryCleanupWhiteSpace = true;" End If
	If TryRejectSingleLine Then html = html & "tryRejectSingleLine = true;" End If

	If TrySingleLineSearch <> "" Then html = html & "trySingleLineSearch = '" & TrySingleLineSearch & "';" End If
	If TrySingleLineReplace <> "" Then html = html & "trySingleLineReplace = '" & TrySingleLineReplace & "';" End If

	If TryParensA Then html = html & "tryParensA = true;" End If
	If TryBracketsA Then html = html & "tryBracketsA = true;" End If
	If TryBracesA Then html = html & "tryBracesA = true;" End If
	If TryQuotesA Then html = html & "tryQuotesA = true;" End If
	If TrySplitArrayA <> "" Then html = html & "trySplitArrayA = '" & TrySplitArrayA & "';" End If
	If TryBlackListA <> "" Then html = html & "tryBlackListA = '" & TryBlackListA & "';" End If

	If TryParensT Then html = html & "tryParensT = true;" End If
	If TryBracketsT Then html = html & "tryBracketsT = true;" End If
	If TryBracesT Then html = html & "tryBracesT = true;" End If
	If TryQuotesT Then html = html & "tryQuotesT = true;" End If
	If TrySplitArrayT <> "" Then html = html & "trySplitArrayT = '" & TrySplitArrayT & "';" End If
	If TryBlackListT <> "" Then html = html & "tryBlackListT = '" & TryBlackListT & "';" End If

	If TryLyricsPlugin Then html = html & "tryLyricsPlugin = true;" End If
	If TryLyricsWiki Then html = html & "tryLyricsWiki = true;" End If
	If TryLyricsSongs Then html = html & "tryLyricsSongs = true;" End If

	html = html & "</script>"
	html = html & "	</head>"
	html = html & "	<body>"
	html = html & "	<div id=""Header""></div>"
	html = html & "	<div id=""Popup""></div>"
	html = html & "	<div id=""Hidden""></div>"
	html = html & "	<div id=""Status""></div>"
	html = html & " <div id=""DataScroll"">"
	html = html & " <div id=""Data"">"

	Dim abort : abort = false
	Dim interval : interval = 1
	If tracks.count > 10000 Then
		interval = 100
	ElseIf tracks.count > 1000 Then
		interval = 25
	ElseIf tracks.count > 100 Then
		interval = 10
	End If
	
	Dim status : Set status = SDB.Objects("LyricatorStatus")
	  
	Dim i
	For i = 0 to tracks.count - 1
		SDB.ProcessMessages
		If SDB.Objects("LyricatorWB") is nothing Then 
			abort = true
			Exit For 
		End If

	  If (i + 1) Mod interval = 0 Then
			status.Caption = SDB.Localize("Loading " & (i+1) & "/" & (tracks.count) & " ...")
		End If

		With tracks.item(i)
			html = html & "<div id=""" & .ID & """ class=""track"">"
			html = html & "<div class=""checkbox""><input type=""checkbox"" disabled=""true"" /></div>"
			'Owyn Added EncodeUrl 
			html = html & "<div class=""artist"">" & EncodeUrl(.ArtistName)
			If TryAllArtists Then
				If .Conductor <> "" Then html = html & ";" & EncodeUrl(.Conductor) End If
				If .InvolvedPeople <> "" Then html = html & ";" & EncodeUrl(.InvolvedPeople) End If
				If .Lyricist <> "" Then html = html & ";" & EncodeUrl(.Lyricist) End If
				If .MusicComposer <> "" Then html = html & ";" & EncodeUrl(.MusicComposer) End If
				If .OriginalArtist <> "" Then html = html & ";" & EncodeUrl(.OriginalArtist) End If
				If .OriginalLyricist <> "" Then html = html & ";" & EncodeUrl(.OriginalLyricist) End If
			End If
			html = html & "</div>"
			html = html & "<div class=""title"">" & EncodeUrl(.Title) & "</div>"
			html = html & "<div class=""lyrics""></div>"
			html = html & "</div>"
		End With
	Next
	html = html & " </div>"
	html = html & " </div>"
	html = html & "	</body>"
	html = html & "</html>"

	status.Caption = ""
	SDB.ProcessMessages
	SDB.Objects("LyricatorTracks") = tracks
	
	html = Replace(html, ChrW(-257), "")

	Dim f : Set f = fso.OpenTextFile(sHTML, 2, true)
	f.WriteLine html
	f.close

	If Not abort Then
	  btnSave.Caption = SDB.Localize("&Save")
	  btnSave.Common.Enabled = True

	  btnCancel.Caption = SDB.Localize("C&lose")
	  btnCancel.OnClickFunc = "OnCancel"
	  
  	WB.Interf.Navigate(sHTML)
  End If
End Sub 

Function INIDefault(v, d)
	If v = "" Or v = "False" Then
	Debug v
		v = d
	End If
	INIDefault = v
End Function

Function Debug(s)
	Call SDB.MessageBox(s, mtInformation, Array(mbOk))
End Function

Sub OnStartUp
	Dim i : i = SDB.UI.AddOptionSheet("Lyricator", Script.ScriptPath, "InitSheet", "SaveSheet", -3)
End Sub

Sub InitSheet(Sheet)
	Dim UI : Set UI = SDB.UI
	Dim ini : Set ini = SDB.IniFile
	
	Dim TryAllArtists : TryAllArtists = ini.BoolValue("Lyricator", "TryAllArtists")
	Dim TryCommaArtists : TryCommaArtists = ini.BoolValue("Lyricator", "TryCommaArtists")
	Dim TryCleanupWhiteSpace : TryCleanupWhiteSpace = ini.BoolValue("Lyricator", "TryCleanupWhiteSpace")
	Dim TryRejectSingleLine : TryRejectSingleLine = ini.BoolValue("Lyricator", "TryRejectSingleLine")
	
	Dim TrySingleLineSearch : TrySingleLineSearch = ini.StringValue("Lyricator", "TrySingleLineSearch")
	Dim TrySingleLineReplace : TrySingleLineReplace = ini.StringValue("Lyricator", "TrySingleLineReplace")

	Dim TryParensA : TryParensA = ini.BoolValue("Lyricator", "TryParensA")
	Dim TryBracketsA : TryBracketsA = ini.BoolValue("Lyricator", "TryBracketsA")
	Dim TryBracesA : TryBracesA = ini.BoolValue("Lyricator", "TryBracesA")
	Dim TryQuotesA : TryQuotesA = ini.BoolValue("Lyricator", "TryQuotesA")
	Dim TrySplitArrayA : TrySplitArrayA = ini.StringValue("Lyricator", "TrySplitArrayA")
	Dim TryBlackListA : TryBlackListA = ini.StringValue("Lyricator", "TryBlackListA")

	Dim TryParensT : TryParensT = ini.BoolValue("Lyricator", "TryParensT")
	Dim TryBracketsT : TryBracketsT = ini.BoolValue("Lyricator", "TryBracketsT")
	Dim TryBracesT : TryBracesT = ini.BoolValue("Lyricator", "TryBracesT")
	Dim TryQuotesT : TryQuotesT = ini.BoolValue("Lyricator", "TryQuotesT")
	Dim TrySplitArrayT : TrySplitArrayT = ini.StringValue("Lyricator", "TrySplitArrayT")
	Dim TryBlackListT : TryBlackListT = ini.StringValue("Lyricator", "TryBlackListT")

	Dim TryLyricsPlugin : TryLyricsPlugin = ini.BoolValue("Lyricator", "TryLyricsPlugin")
	Dim TryLyricsWiki : TryLyricsWiki = ini.BoolValue("Lyricator", "TryLyricsWiki")
	Dim TryLyricsSongs : TryLyricsSongs = ini.BoolValue("Lyricator", "TryLyricsSongs")
	
	Dim TryAutoClose : TryAutoClose = ini.BoolValue("Lyricator", "TryAutoClose")

	Dim a : Set a = UI.NewGroupBox(Sheet) : a.Caption = "Artist Settings" : a.Common.SetRect 10, 10, 230, 210
	Dim t : Set t = UI.NewGroupBox(Sheet) : t.Caption = "Title Settings"  : t.Common.SetRect 250, 10, 230, 210
	Dim l : Set l = UI.NewGroupBox(Sheet) : l.Caption = "Lyrics" : l.Common.SetRect 10, 225, 230, 170
	Dim s : Set s = UI.NewGroupBox(Sheet) : s.Caption = "Sources"  : s.Common.SetRect 250, 225, 230, 90
	Dim g : Set g = UI.NewGroupBox(Sheet) : g.Caption = "General"  : g.Common.SetRect 250, 320, 230, 75
	Dim ls : Set ls = UI.NewGroupBox(l) : ls.Caption = "Single-Line Lyrics"  : ls.Common.SetRect 10, 50, 210, 110

  Dim e
  Set e = UI.NewCheckbox(a)
  e.Common.SetRect 15, 20, 250, 20
  e.Common.ControlName = "TryParensA"
  e.Common.Hint = "Remove anything within parentheses ()"
  e.Caption = Translate("Remove Within Parentheses")
  e.Checked = TryParensA

  Set e = UI.NewCheckbox(a)
  e.Common.SetRect 15, 40, 250, 20
  e.Common.ControlName = "TryBracketsA"
  e.Common.Hint = "Remove anything within brackets []"
  e.Caption = Translate("Remove Within Brackets")
  e.Checked = TryBracketsA

  Set e = UI.NewCheckbox(a)
  e.Common.SetRect 15, 60, 250, 20
  e.Common.ControlName = "TryBracesA"
  e.Common.Hint = "Remove anything within braces {}"
  e.Caption = Translate("Remove Within Braces")
  e.Checked = TryBracesA

  Set e = UI.NewCheckbox(a)
  e.Common.SetRect 15, 80, 250, 20
  e.Common.ControlName = "TryQuotesA"
  e.Common.Hint = "Ignore single- and double-quotation marks"
  e.Caption = Translate("Ignore Single/Double Quotes")
  e.Checked = TryQuotesA

  Set e = UI.NewCheckbox(a)
  e.Common.SetRect 15, 100, 250, 20
  e.Common.ControlName = "TryAllArtists"
  e.Common.Hint = "Attempt all artists (separated by semi-colon)"
  e.Caption = Translate("Attempt All Artists")
  e.Checked = TryAllArtists

  Set e = UI.NewCheckbox(a)
  e.Common.SetRect 15, 120, 250, 20
  e.Common.ControlName = "TryCommaArtists"
  e.Common.Hint = "Convert ""Surname, Name"" to ""Name Surname"""
  e.Caption = Translate("Fix Comma Surnames")
  e.Checked = TryCommaArtists

  Set e = UI.NewLabel(a)
  e.Alignment = 0
  e.Autosize = False
  e.Common.SetRect 15, 150, 200, 20
  e.Caption = Translate("Delimiter Array") & ":"
  
  Set e = ui.NewEdit(a)
  e.Common.SetRect 100, 147, 100, 17
  e.Common.ControlName = "TrySplitArrayA"
  e.Common.Hint = "Semi-colon-separated delimeter array"
  e.Text = TrySplitArrayA

  Set e = UI.NewLabel(a)
  e.Alignment = 0
  e.Autosize = False
  e.Common.SetRect 15, 180, 200, 20
  e.Caption = Translate("Black List") & ":"
  
  Set e = ui.NewEdit(a)
  e.Common.SetRect 100, 177, 100, 17
  e.Common.ControlName = "TryBlackListA"
  e.Common.Hint = "Semi-colon-separated Black List (ignore these words)"
  e.Text = TryBlackListA

  Set e = UI.NewCheckbox(t)
  e.Common.SetRect 15, 20, 250, 20
  e.Common.ControlName = "TryParensT"
  e.Common.Hint = "Remove anything within parentheses ()"
  e.Caption = Translate("Remove Within Parentheses")
  e.Checked = TryParensT

  Set e = UI.NewCheckbox(t)
  e.Common.SetRect 15, 40, 250, 20
  e.Common.ControlName = "TryBracketsT"
  e.Common.Hint = "Remove anything within brackets []"
  e.Caption = Translate("Remove Within Brackets")
  e.Checked = TryBracketsT

  Set e = UI.NewCheckbox(t)
  e.Common.SetRect 15, 60, 250, 20
  e.Common.ControlName = "TryBracesT"
  e.Common.Hint = "Remove anything within braces {}"
  e.Caption = Translate("Remove Within Braces")
  e.Checked = TryBracesT

  Set e = UI.NewCheckbox(t)
  e.Common.SetRect 15, 80, 250, 20
  e.Common.ControlName = "TryQuotesT"
  e.Common.Hint = "Ignore single- and double-quotation marks"
  e.Caption = Translate("Ignore Single/Double Quotes")
  e.Checked = TryQuotesT

  Set e = UI.NewLabel(t)
  e.Alignment = 0
  e.Autosize = False
  e.Common.SetRect 15, 150, 200, 20
  e.Caption = Translate("Delimiter Array") & ":"
  
  Set e = ui.NewEdit(t)
  e.Common.SetRect 100, 147, 100, 17
  e.Common.ControlName = "TrySplitArrayT"
  e.Common.Hint = "Semi-colon-separated delimeter array"
  e.Text = TrySplitArrayT
    
  Set e = UI.NewLabel(t)
  e.Alignment = 0
  e.Autosize = False
  e.Common.SetRect 15, 180, 200, 20
  e.Caption = Translate("Black List") & ":"
  
  Set e = ui.NewEdit(t)
  e.Common.SetRect 100, 177, 100, 17
  e.Common.ControlName = "TryBlackListT"
  e.Common.Hint = "Semi-colon-separated Black List (ignore these words)"
  e.Text = TryBlackListT

  Set e = UI.NewCheckbox(l)
  e.Common.SetRect 15, 20, 250, 20
  e.Common.ControlName = "TryCleanupWhiteSpace"
  e.Common.Hint = "Consolidate excess white-space (e.g. three or more line breaks)"
  e.Caption = Translate("Cleanup Whitespace")
  e.Checked = TryCleanupWhiteSpace

  Set e = UI.NewCheckbox(ls)
  e.Common.SetRect 15, 20, 250, 20
  e.Common.ControlName = "TryRejectSingleLine"
  e.Common.Hint = "Ignore lyrics that contain only one single line"
  e.Caption = Translate("Ignore")
  e.Checked = TryRejectSingleLine

  Set e = UI.NewLabel(ls)
  e.Alignment = 0
  e.Autosize = False
  e.Common.SetRect 15, 50, 200, 20
  e.Caption = Translate("Search String") & ":"
  
  Set e = ui.NewEdit(ls)
  e.Common.SetRect 100, 47, 100, 17
  e.Common.ControlName = "TrySingleLineSearch"
  e.Common.Hint = "Single-Line Search String"
  e.Text = TrySingleLineSearch

  Set e = UI.NewLabel(ls)
  e.Alignment = 0
  e.Autosize = False
  e.Common.SetRect 15, 80, 200, 20
  e.Caption = Translate("Replace String") & ":"
  
  Set e = ui.NewEdit(ls)
  e.Common.SetRect 100, 77, 100, 17
  e.Common.ControlName = "TrySingleLineReplace"
  e.Common.Hint = "Single-Line Replace String"
  e.Text = TrySingleLineReplace

  Set e = UI.NewCheckbox(s)
  e.Common.SetRect 15, 20, 250, 20
  e.Common.ControlName = "TryLyricsPlugin"
  e.Common.Hint = "Search using www.LyricsPlugin.com"
  e.Caption = Translate("www.LyricsPlugin.com")
  e.Checked = TryLyricsPlugin

  Set e = UI.NewCheckbox(s)
  e.Common.SetRect 15, 40, 250, 20
  e.Common.ControlName = "TryLyricsWiki"
  e.Common.Hint = "Search using www.LyricWiki.org"
  e.Caption = Translate("www.LyricWiki.org")
  e.Checked = TryLyricsWiki

  Set e = UI.NewCheckbox(s)
  e.Common.SetRect 15, 60, 250, 20
  e.Common.ControlName = "TryLyricsSongs"
  e.Common.Hint = "Search using www.Lyrics-Songs.com (Careful -- Slow with Many False Positives)"
  e.Caption = Translate("www.Lyrics-Songs.com (Unreliable!)")
  e.Checked = TryLyricsSongs

  Set e = UI.NewCheckbox(g)
  e.Common.SetRect 15, 20, 250, 20
  e.Common.ControlName = "TryAutoClose"
  e.Common.Hint = "Auto-Close when done saving lyrics"
  e.Caption = Translate("Auto-Close After Save")
  e.Checked = TryAutoClose
End Sub

Sub SaveSheet(Sheet)
	Dim ini : Set ini = SDB.IniFile

  ini.BoolValue("Lyricator", "TryAllArtists") = Sheet.Common.ChildControl("TryAllArtists").Checked
  ini.BoolValue("Lyricator", "TryCommaArtists") = Sheet.Common.ChildControl("TryCommaArtists").Checked
  ini.BoolValue("Lyricator", "TryCleanupWhiteSpace") = Sheet.Common.ChildControl("TryCleanupWhiteSpace").Checked
  ini.BoolValue("Lyricator", "TryRejectSingleLine") = Sheet.Common.ChildControl("TryRejectSingleLine").Checked

  ini.StringValue("Lyricator", "TrySingleLineSearch") = Sheet.Common.ChildControl("TrySingleLineSearch").Text
  ini.StringValue("Lyricator", "TrySingleLineReplace") = Sheet.Common.ChildControl("TrySingleLineReplace").Text

  ini.BoolValue("Lyricator", "TryParensA") = Sheet.Common.ChildControl("TryParensA").Checked
  ini.BoolValue("Lyricator", "TryBracketsA") = Sheet.Common.ChildControl("TryBracketsA").Checked
  ini.BoolValue("Lyricator", "TryBracesA") = Sheet.Common.ChildControl("TryBracesA").Checked
  ini.BoolValue("Lyricator", "TryQuotesA") = Sheet.Common.ChildControl("TryQuotesA").Checked
  ini.StringValue("Lyricator", "TrySplitArrayA") = Sheet.Common.ChildControl("TrySplitArrayA").Text
  ini.StringValue("Lyricator", "TryBlackListA") = Sheet.Common.ChildControl("TryBlackListA").Text

  ini.BoolValue("Lyricator", "TryParensT") = Sheet.Common.ChildControl("TryParensT").Checked
  ini.BoolValue("Lyricator", "TryBracketsT") = Sheet.Common.ChildControl("TryBracketsT").Checked
  ini.BoolValue("Lyricator", "TryBracesT") = Sheet.Common.ChildControl("TryBracesT").Checked
  ini.BoolValue("Lyricator", "TryQuotesT") = Sheet.Common.ChildControl("TryQuotesT").Checked
  ini.StringValue("Lyricator", "TrySplitArrayT") = Sheet.Common.ChildControl("TrySplitArrayT").Text
  ini.StringValue("Lyricator", "TryBlackListT") = Sheet.Common.ChildControl("TryBlackListT").Text

  If Not Sheet.Common.ChildControl("TryLyricsPlugin").Checked And Not Sheet.Common.ChildControl("TryLyricsWiki").Checked And Not Sheet.Common.ChildControl("TryLyricsSongs").Checked Then
  	Debug "You Must Have One Lyric Server Checked" & vbnewline & vbnewline & "Defaulting to Lyrics Plugin"
  	Sheet.Common.ChildControl("TryLyricsPlugin").Checked = True
  End If
  
  ini.BoolValue("Lyricator", "TryLyricsPlugin") = Sheet.Common.ChildControl("TryLyricsPlugin").Checked
  ini.BoolValue("Lyricator", "TryLyricsWiki") = Sheet.Common.ChildControl("TryLyricsWiki").Checked
  ini.BoolValue("Lyricator", "TryLyricsSongs") = Sheet.Common.ChildControl("TryLyricsSongs").Checked

  ini.BoolValue("Lyricator", "TryAutoClose") = Sheet.Common.ChildControl("TryAutoClose").Checked
End Sub

Function Translate(str)
  Translate = str
  Dim dic : Set dic = SDB.Objects("LyrDict")
  If Not (dic Is Nothing) Then
    If dic.Exists(str) Then
      Translate = dic.Item(str)
    End If
  End If
End Function

Sub Install()
	Dim iniFile : iniFile = SDB.ApplicationPath & "Scripts\Scripts.ini"
  Dim f : Set f = SDB.Tools.IniFileByPath(iniFile)
  If Not (f Is Nothing) Then
    f.StringValue("Lyricator", "Filename") = "Auto\Lyricator.vbs"
    f.StringValue("Lyricator", "Procname") = "Lyricator"
    f.StringValue("Lyricator", "Order") = "99"
    f.StringValue("Lyricator", "DisplayName") = "Lyricator"
    f.StringValue("Lyricator", "Description") = "Batch Import Lyrics"
    f.StringValue("Lyricator", "Language") = "VBScript"
    f.StringValue("Lyricator", "ScriptType") = "0"
    SDB.RefreshScriptItems
  End If

	Dim ini : Set ini = SDB.IniFile

  If Not ini.BoolValue("Lyricator", "TryAllArtists") Then ini.BoolValue("Lyricator", "TryAllArtists") = True End If
  If Not ini.BoolValue("Lyricator", "TryCommaArtists") Then ini.BoolValue("Lyricator", "TryCommaArtists") = True End If
  If Not ini.BoolValue("Lyricator", "TryCleanupWhiteSpace") Then ini.BoolValue("Lyricator", "TryCleanupWhiteSpace") = True End If
  If Not ini.BoolValue("Lyricator", "TryRejectSingleLine") Then ini.BoolValue("Lyricator", "TryRejectSingleLine") = False End If

  If ini.StringValue("Lyricator", "TrySingleLineSearch") = "" Then ini.StringValue("Lyricator", "TrySingleLineSearch") = "Instr" End If
  If ini.StringValue("Lyricator", "TrySingleLineReplace") = "" Then ini.StringValue("Lyricator", "TrySingleLineReplace") = "[Instrumental]" End If

  If Not ini.BoolValue("Lyricator", "TryParensA") Then ini.BoolValue("Lyricator", "TryParensA") = False End If
  If Not ini.BoolValue("Lyricator", "TryBracketsA") Then ini.BoolValue("Lyricator", "TryBracketsA") = False End If
  If Not ini.BoolValue("Lyricator", "TryBracesA") Then ini.BoolValue("Lyricator", "TryBracesA") = False End If
  If Not ini.BoolValue("Lyricator", "TryQuotesA") Then ini.BoolValue("Lyricator", "TryQuotesA") = False End If
  If ini.StringValue("Lyricator", "TrySplitArrayA") = "" Then ini.StringValue("Lyricator", "TrySplitArrayA") = "and;&" End If
  If ini.StringValue("Lyricator", "TryBlackListA") = "" Then ini.StringValue("Lyricator", "TryBlackListA") = "" End If

  If Not ini.BoolValue("Lyricator", "TryParensT") Then ini.BoolValue("Lyricator", "TryParensT") = True End If
  If Not ini.BoolValue("Lyricator", "TryBracketsT") Then ini.BoolValue("Lyricator", "TryBracketsT") = True End If
  If Not ini.BoolValue("Lyricator", "TryBracesT") Then ini.BoolValue("Lyricator", "TryBracesT") = True End If
  If Not ini.BoolValue("Lyricator", "TryQuotesT") Then ini.BoolValue("Lyricator", "TryQuotesT") = True End If
  If ini.StringValue("Lyricator", "TrySplitArrayT") = "" Then ini.StringValue("Lyricator", "TrySplitArrayT") = "" End If
  If ini.StringValue("Lyricator", "TryBlackListT") = "" Then ini.StringValue("Lyricator", "TryBlackListT") = "Medley" End If

  If Not ini.BoolValue("Lyricator", "TryLyricsPlugin") Then ini.BoolValue("Lyricator", "TryLyricsPlugin") = True End If
  If Not ini.BoolValue("Lyricator", "TryLyricsWiki") Then ini.BoolValue("Lyricator", "TryLyricsWiki") = True End If
  If Not ini.BoolValue("Lyricator", "TryLyricsSongs") Then ini.BoolValue("Lyricator", "TryLyricsSongs") = False End If

  If Not ini.BoolValue("Lyricator", "TryAutoClose") Then ini.BoolValue("Lyricator", "TryAutoClose") = True End If
End Sub

' Code abstracted from Trixmoto's Monkey Rok script, Functions.vbs

Function EncodeUrl(sRawURL)
  'Const sValidChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\/:" 'Owyn
  Const sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  Const sDigit = "1234567890"
  Const sSafe = "$-_@.&+-"
  Const sExtra = "!*""'(),"
  Const sExtAscii = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
  Const sNonSpec = "\/:;#[]?"
  Dim sValidChars : sValidChars = sAlpha & sDigit & sSafe & sExtra & sExtAscii & sNonSpec
  Dim url : url = Replace(sRawURL,"+","%2B")
  If Len(url) > 0 Then
    Dim i : i = 1
    Do While i < Len(url)+1
      Dim s : s = Mid(url,i,1)
      If InStr(1,sValidChars,s,0) = 0 Then
        Dim d : d = AscW(s)
        If d < 0 Then
          d = d+65536
        End If      
        If d = 32 Or d > 65535 Then
          s = "+"
        Else
          If d < 128 Then
            s = DecToHex(d)
          ElseIf d < 2048 Then
            s = DecToUtf2(d)
          Else
            s = DecToUtf3(d)
          End If
        End If
      Else
        Select Case s
          Case "&"
            's = "%2526" 'Owyn
          Case "/"
            s = "%252F"
          Case "\"
            s = "%5C"
          Case ":"
            s = "%3A"
        End Select
      End If
      EncodeUrl = EncodeUrl&s
      i = i+1
    Loop
  End If
End Function

Function BinToHex(strBin)
  Dim d : d = 0
  Dim i : i = 0
  For i = Len(strBin) To 1 Step -1
    Select Case Mid(strBin,i,1)
      Case "0"
        'do nothing
      Case "1"
        d = d + (2^(Len(strBin)-i))
      Case Else
        BinToHex = "00"
        Exit Function
    End Select
  Next
  BinToHex = DecToHex(d)
End Function

Function DecToBin(intDec,e)
  DecToBin = ""
  Dim d : d = intDec
  While e >= 1
    If d >= e Then
      d = d - e
      DecToBin = DecToBin&"1"
    Else
      DecToBin = DecToBin&"0"
    End If
    e = e / 2
  Wend
End Function

Function DecToHex(d)
  If d < 16 Then
    DecToHex = "%0"&CStr(Hex(d))
  Else
    DecToHex = "%"&CStr(Hex(d))
  End If
End Function

Function DecToUtf2(d)
  Dim b : b = DecToBin(d,1024)
  Dim a : a = "110"&Left(b,5)
  b = "10"&Mid(b,6)
  DecToUtf2 = BinToHex(a)&BinToHex(b)
End Function 

Function DecToUtf3(d)
  Dim b : b = DecToBin(d,32768)
  Dim a : a = "1110"&Left(b,4)
  Dim c : c = "10"&Mid(b,11,6)
  b = "10"&Mid(b,5,6)
  DecToUtf3 = BinToHex(a)&BinToHex(b)&BinToHex(c)
End Function 

Function DecToUtf4(d)
  Dim b : b = DecToBin(d,557056)
  Dim a : a = "11110"&Left(b,3)
  Dim c : c = "10"&Mid(b,10,6)
  Dim e : e = "10"&Mid(b,16,6)
  b = "10"&Mid(b,4,6)
  DecToUtf4 = BinToHex(a)&BinToHex(b)&BinToHex(c)&BinToHex(e)
End Function 
Edit:
Added ;#[]? to NonSpec characters.
Cogito cogito ergo cogito sum. (Ambrose Bierce)
I drink therefore I am. (Monty Python)
Vista 32bit Home Premium SP2 / MM3.2.1.1297 Gold / Last.Fm 1.0.2.22 / IE8
Dell Inspiron 530 (1.8 Core2 / 2GB)
Skin: Vitreous Blue
Scripts: Add/Remove Playstat|Advanced Duplicate Find & Fix|Album Art Tagger|Backup|Batch Art Finder|Calculate Cover Size|Case&Leading Zero Fixer|DB_Audit|DB_Clean|DB_Schema|Event Logger|Genre Finder|Lyricator|Magic Nodes|MM2VLC|Monkey Rok|MusicIP Tagger|PUID Generator|RegExp Find & Replace|Right Click for Scripts|Scriptreloader|SQL Viewer|Stats(Filtered)|Tagging Inconsistencies
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

Sirandar888 wrote:To those experiencing crashes using lyricator related to MSHTML.dll

Uninstall IE8 and lyricator will work again.
Ummm. I think you mean IE8RC1. I don't think the released version of IE8 causes this problem.
Cogito cogito ergo cogito sum. (Ambrose Bierce)
I drink therefore I am. (Monty Python)
Vista 32bit Home Premium SP2 / MM3.2.1.1297 Gold / Last.Fm 1.0.2.22 / IE8
Dell Inspiron 530 (1.8 Core2 / 2GB)
Skin: Vitreous Blue
Scripts: Add/Remove Playstat|Advanced Duplicate Find & Fix|Album Art Tagger|Backup|Batch Art Finder|Calculate Cover Size|Case&Leading Zero Fixer|DB_Audit|DB_Clean|DB_Schema|Event Logger|Genre Finder|Lyricator|Magic Nodes|MM2VLC|Monkey Rok|MusicIP Tagger|PUID Generator|RegExp Find & Replace|Right Click for Scripts|Scriptreloader|SQL Viewer|Stats(Filtered)|Tagging Inconsistencies
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

Cogito cogito ergo cogito sum. (Ambrose Bierce)
I drink therefore I am. (Monty Python)
Vista 32bit Home Premium SP2 / MM3.2.1.1297 Gold / Last.Fm 1.0.2.22 / IE8
Dell Inspiron 530 (1.8 Core2 / 2GB)
Skin: Vitreous Blue
Scripts: Add/Remove Playstat|Advanced Duplicate Find & Fix|Album Art Tagger|Backup|Batch Art Finder|Calculate Cover Size|Case&Leading Zero Fixer|DB_Audit|DB_Clean|DB_Schema|Event Logger|Genre Finder|Lyricator|Magic Nodes|MM2VLC|Monkey Rok|MusicIP Tagger|PUID Generator|RegExp Find & Replace|Right Click for Scripts|Scriptreloader|SQL Viewer|Stats(Filtered)|Tagging Inconsistencies
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Teknojnky »

If this script has been abandoned and taken over by someone actively working on it, it may be best to start a new thread by the current updater with reference to this thread and original author.

So that any new development isn't confused with the original etc.

What do you guys think?
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by trixmoto »

This is certainly what I did with the "Monkey Rok" script. :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

That's fine by me. If G-Diablo set's up the first post I can move relevant posts over to the new thread.
Cogito cogito ergo cogito sum. (Ambrose Bierce)
I drink therefore I am. (Monty Python)
Vista 32bit Home Premium SP2 / MM3.2.1.1297 Gold / Last.Fm 1.0.2.22 / IE8
Dell Inspiron 530 (1.8 Core2 / 2GB)
Skin: Vitreous Blue
Scripts: Add/Remove Playstat|Advanced Duplicate Find & Fix|Album Art Tagger|Backup|Batch Art Finder|Calculate Cover Size|Case&Leading Zero Fixer|DB_Audit|DB_Clean|DB_Schema|Event Logger|Genre Finder|Lyricator|Magic Nodes|MM2VLC|Monkey Rok|MusicIP Tagger|PUID Generator|RegExp Find & Replace|Right Click for Scripts|Scriptreloader|SQL Viewer|Stats(Filtered)|Tagging Inconsistencies
G-DIABLO
Posts: 27
Joined: Sun Dec 06, 2009 2:09 pm

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by G-DIABLO »

it's ok by me.
Owyn do you want to open new thread? or do you want me to do it?
if you decide to do it your self, you can just post the new link as response.
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

You are the one adopting the script, so you should open it.
I'll do the housekeeping when the new topic is available.
Cogito cogito ergo cogito sum. (Ambrose Bierce)
I drink therefore I am. (Monty Python)
Vista 32bit Home Premium SP2 / MM3.2.1.1297 Gold / Last.Fm 1.0.2.22 / IE8
Dell Inspiron 530 (1.8 Core2 / 2GB)
Skin: Vitreous Blue
Scripts: Add/Remove Playstat|Advanced Duplicate Find & Fix|Album Art Tagger|Backup|Batch Art Finder|Calculate Cover Size|Case&Leading Zero Fixer|DB_Audit|DB_Clean|DB_Schema|Event Logger|Genre Finder|Lyricator|Magic Nodes|MM2VLC|Monkey Rok|MusicIP Tagger|PUID Generator|RegExp Find & Replace|Right Click for Scripts|Scriptreloader|SQL Viewer|Stats(Filtered)|Tagging Inconsistencies
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

Work on bug fixes for this script has moved to a new topic by G-Diablo & Owyn.
Vyper
Posts: 845
Joined: Tue May 23, 2006 5:53 pm

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Vyper »

Can this thread be locked then? :)
Stop Button Freak
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

Locked. :D
Owyn
Posts: 2018
Joined: Fri Mar 21, 2008 10:55 am
Location: Canada

Re: Lyricator - Batch Lyrics Updater v0.9.6b [MM3]

Post by Owyn »

First bug fix release is now available here.
Locked