thehammer wrote:Thanks for all the input and code snippets! I think I can get all of these in except the source order. The way the lookup happens iteratively makes it difficult to do what I think you are suggesting without a major rewrite. I'll have to think on that some more.
It might be difficult to implement configurable provider rankings, unless the user could assign a number to rank each provider (say from 1-20) and then have the tool iterate from 1 to 20, searching the corresponding provider. Kinda cheesy, but that might work.
On the other hand, if you agree with my assessment, you can simply rearrange the function calls to "hard code the ranking" so that the providers are called in the preferred sequence. (I
think I already have my copy of Lyricator resequenced. I can copy the source code here when i get home.
** done **)
** UPDATE: ** Here is the Lyricator.js function with the search calls sequenced by provider preference.
Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var init = function() {
// To add lyrics site add init check for when enabled
// The Lyrics providers vary in terms of success rate, turnaround speed, and text formatting.
// You can sequence the following function calls to suit your provider preferences.
if(tryLyricsMode) {
rLyricsMode = new Request({method:'get',onSuccess:rSuccessLyricsMode,onException:rNextLyricsMode,onFailure:rNextLyricsMode,onCancel:rNextLyricsMode});
rLyricsMode.host = 'http://www.lyricsmode.com/lyrics/%artistfirstchar%/%artist%/%title%.html';
rLyricsMode.sendString = '';
rLyricsMode.timeout = '20000';
rLyricsMode.delay = '50';
rLyricsMode.name = 'Lyrics Mode';
rLyricsMode.className = 'LyricsMode';
aR.include(rLyricsMode);
}
if(trySongColeta) {
rSongColeta = new Request({method:'get',onSuccess:rSuccessSongColeta,onException:rNextSongColeta,onFailure:rNextSongColeta,onCancel:rNextSongColeta});
rSongColeta.host = 'http://www.songcoleta.com/lyrics/%title%_(%artist%)';
rSongColeta.sendString = '';
rSongColeta.timeout = '20000';
rSongColeta.delay = '1000';
rSongColeta.name = 'SongColeta';
rSongColeta.className = 'SongColeta';
aR.include(rSongColeta);
}
if(tryLyrDB) {
rLyrDB = new Request({method:'get',onSuccess:rSuccessLyrDB,onException:rNextLyrDB,onFailure:rNextLyrDB,onCancel:rNextLyrDB});
rLyrDB.host = 'http://webservices.lyrdb.com/lookup.php?for=match&q=%artist%|%title%&agent=MediaMonkey';
rLyrDB.sendString = '';
rLyrDB.timeout = '20000';
rLyrDB.delay = '50';
rLyrDB.name = 'Lyr DB';
rLyrDB.className = 'LyrDB';
aR.include(rLyrDB);
}
if(tryHiplyrics) {
rHiplyrics = new Request({method:'get',onSuccess:rSuccessHiplyrics,onException:rNextHiplyrics,onFailure:rNextHiplyrics,onCancel:rNextHiplyrics});
rHiplyrics.host = 'http://www.hiplyrics.com/lyrics/%title%-by-%artist%-lyrics.html';
rHiplyrics.sendString = '';
rHiplyrics.timeout = '20000';
rHiplyrics.delay = '50';
rHiplyrics.name = 'hiplyrics';
rHiplyrics.className = 'hiplyrics';
aR.include(rHiplyrics);
}
if(tryGenius) {
rGenius = new Request({method:'get',onSuccess:rSuccessGenius,onException:rNextGenius,onFailure:rNextGenius,onCancel:rNextGenius});
rGenius.host = 'http://%genre%.genius.com/%artist%-%title%-lyrics';
rGenius.sendString = '';
rGenius.timeout = '20000';
rGenius.delay = '1000';
rGenius.name = 'Genius';
rGenius.className = 'Genius';
aR.include(rGenius);
}
if(trySeekALyric) {
rSeekALyric = new Request({method:'get',onSuccess:rSuccessSeekALyric,onException:rNextSeekALyric,onFailure:rNextSeekALyric,onCancel:rNextSeekALyric});
rSeekALyric.host = 'http://www.seekalyric.com/song/%artist%/%title%';
rSeekALyric.sendString = '';
rSeekALyric.timeout = '20000';
rSeekALyric.delay = '50';
rSeekALyric.name = 'Seek A Lyric';
rSeekALyric.className = 'SeekALyric';
aR.include(rSeekALyric);
}
if(tryELyrics) {
rELyrics = new Request({method:'get',onSuccess:rSuccessELyrics,onException:rNextELyrics,onFailure:rNextELyrics,onCancel:rNextELyrics});
rELyrics.host = 'http://www.elyrics.net/read/%artistfirstchar%/%artist%-lyrics/%title%-lyrics.html';
rELyrics.sendString = '';
rELyrics.timeout = '20000';
rELyrics.delay = '50';
rELyrics.name = 'ELyrics';
rELyrics.className = 'ELyrics';
aR.include(rELyrics);
}
if(tryMetroLyrics) {
rMetroLyrics = new Request({method:'get',onSuccess:rSuccessMetroLyrics,onException:rNextMetroLyrics,onFailure:rNextMetroLyrics,onCancel:rNextMetroLyrics});
rMetroLyrics.host = 'http://www.metrolyrics.com/%title%-lyrics-%artist%.html';
rMetroLyrics.sendString = '';
rMetroLyrics.timeout = '20000';
rMetroLyrics.delay = '50';
rMetroLyrics.name = 'Metro Lyrics';
rMetroLyrics.className = 'MetroLyrics';
aR.include(rMetroLyrics);
}
if(tryLetras) {
rLetras = new Request({method:'get',onSuccess:rSuccessLetras,onException:rNextLetras,onFailure:rNextLetras,onCancel:rNextLetras});
rLetras.host = 'http://letras.mus.br/winamp.php?artista=%artist%&musica=%title%';
rLetras.sendString = 'artista=%artist%&musica=%title%';
rLetras.timeout = '20000';
rLetras.delay = '50';
rLetras.name = 'Letras';
rLetras.className = 'Letras';
aR.include(rLetras);
}
if(tryAZLyrics) {
rAZLyrics = new Request({method:'get',onSuccess:rSuccessAZLyrics,onException:rNextAZLyrics,onFailure:rNextAZLyrics,onCancel:rNextAZLyrics});
rAZLyrics.host = 'http://www.azlyrics.com/lyrics/%artist%/%title%.html';
rAZLyrics.sendString = '';
rAZLyrics.timeout = '20000';
rAZLyrics.delay = '1000';
rAZLyrics.name = 'AZ Lyrics';
rAZLyrics.className = 'AZLyrics';
aR.include(rAZLyrics);
}
if(tryLyricWikia) {
rLyricWikia = new Request({method:'get',onSuccess:rSuccessLyricWikia,onException:rNextLyricWikia,onFailure:rNextLyricWikia,onCancel:rNextLyricWikia});
rLyricWikia.host = 'http://lyrics.wikia.com/%artist%:%title%';
rLyricWikia.sendString = '';
rLyricWikia.timeout = '20000';
rLyricWikia.delay = '50';
rLyricWikia.name = 'Lyrics Wiki';
rLyricWikia.className = 'LyricWikia';
aR.include(rLyricWikia);
}
if(tryMp3Lyrics) {
rMp3Lyrics = new Request({method:'get',onSuccess:rSuccessMp3Lyrics,onException:rNextMp3Lyrics,onFailure:rNextMp3Lyrics,onCancel:rNextMp3Lyrics});
rMp3Lyrics.host = 'http://www.mp3lyrics.org/%artist%/%title%';
rMp3Lyrics.sendString = '';
rMp3Lyrics.timeout = '20000';
rMp3Lyrics.delay = '50';
rMp3Lyrics.name = 'Mp3Lyrics';
rMp3Lyrics.className = 'Mp3Lyrics';
aR.include(rMp3Lyrics);
}
if(tryLyricstime) {
rLyricstime = new Request({method:'get',onSuccess:rSuccessLyricstime,onException:rNextLyricstime,onFailure:rNextLyricstime,onCancel:rNextLyricstime});
rLyricstime.host = 'http://www.lyricstime.com/%artist%-%title%-lyrics.html';
rLyricstime.sendString = '';
rLyricstime.timeout = '20000';
rLyricstime.delay = '50';
rLyricstime.name = 'lyricstime';
rLyricstime.className = 'lyricstime';
aR.include(rLyricstime);
}
bruteForce = tryAllArtists || tryCommaArtists || tryParensA || tryBracketsA || tryBracesA || trySplitArrayA || tryParensT || tryBracketsT || tryBracesT || trySplitArrayT;
loading = new Asset.image(loadinggif);
status = $('Status');
tracks = $$('div[class=track]');
if(!tracks.length) return;
tracks.each(
function(e) {
e.addEvent('click', trackClick);
e.addEvent('mouseover', trackOver);
e.addEvent('mouseout', trackOut);
e.addEvent('contextmenu', trackContextMenu);
}
)
$$('input[type=checkbox]').each(function(e) { e.addEvent('click', function() {if(!e.checked) e.parentNode.parentNode.addClass('unchecked'); else e.parentNode.parentNode.removeClass('unchecked'); window.event.cancelBubble = true;});});
$('Header').innerHTML = '<button id="PauseButton" onclick="pause();">Pause</button><span id="GlobalStatus"></span><span id="GlobalStats"></span><span id="GlobalHost"></span><br><br><span id="Legend">Legend: </span>';
// To add lyrics site create status html here to show when processing
if(tryAZLyrics) { $('Header').innerHTML += '<span class="textAZLyrics">AZLyrics</span> ' ; }
if(tryLyricWikia) { $('Header').innerHTML += '<span class="textLyricWikia">LyricWikia</span> ' ; }
if(tryLyrDB) { $('Header').innerHTML += '<span class="textLyrDB">LyrDB</span> ' ; }
if(tryLetras) { $('Header').innerHTML += '<span class="textLetras">Letras</span> ' ; }
if(tryLyricsMode) { $('Header').innerHTML += '<span class="textLyricsMode">LyricsMode</span> ' ; }
if(tryMp3Lyrics) { $('Header').innerHTML += '<span class="textMp3Lyrics">Mp3Lyrics</span> ' ; }
if(trySeekALyric) { $('Header').innerHTML += '<span class="textSeekALyric">SeekALyric</span> ' ; }
if(tryMetroLyrics) { $('Header').innerHTML += '<span class="textMetroLyrics">MetroLyrics</span> ' ; }
if(tryELyrics) { $('Header').innerHTML += '<span class="textELyrics">ELyrics</span> ' ; }
if(tryHiplyrics) { $('Header').innerHTML += '<span class="textHiplyrics">hiplyrics</span> ' ; }
if(tryLyricstime) { $('Header').innerHTML += '<span class="textLyricstime">lyricstime</span> ' ; }
if(trySongColeta) { $('Header').innerHTML += '<span class="textSongColeta">SongColeta</span> ' ; }
if(tryGenius) { $('Header').innerHTML += '<span class="textGenius">Genius</span> ' ; }
$('Popup').innerHTML = '<button onclick="updateLyrics();">Update Lyrics</button><button onclick="closeLyrics();">Cancel changes</button><br /><textarea id="PopupLyrics"></textarea>';
whatNext(null, null, null, true);
}