Cool, no harm done as long as you and Owyn work together. Either way, I hope you all get it up and running.Semmetju wrote:I just fixed it cause I needed it for myself.nynaevelan wrote:I agree, this is an active script with an active scripter, should it be taken over by someone else without his knowledge or consent??Vyper wrote:Has anyone touched base with Owyn since this is essentially his script now?
This is meant to be just a quick fix, and if Owyn wants to use my stuff, he is free to do so...
Lyricator - Batch Lyrics Updater v1.00 [OUTDATED]
-
nynaevelan
- Posts: 5559
- Joined: Wed Feb 07, 2007 11:07 pm
- Location: New Jersey, USA
- Contact:
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
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
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
that fix isn't working for me, it searches through songs, shows nothing on the right side, and i can't select any of the checkboxes
edit:
HttpRequest does not exist on my server, which i actually just set up a few days ago so it is running a very recent version of PHP.
i could probably install it easily but i will try to find another way as other people's servers may not have it either.
edit:
HttpRequest does not exist on my server, which i actually just set up a few days ago so it is running a very recent version of PHP.
i could probably install it easily but i will try to find another way as other people's servers may not have it either.
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
ok, your method does work, but it it necessary to install PECL which as i said people may not have, instead i changed the code to use file_get_contents which anyone with PHP can use.
also i added these lines to the JS:
if(l == '<a href="http://www.lyricsvip.com/" target="_blank">http://www.lyricsvip.com</a>') l='';
else if(l == '<br><br><br><a href="http://www.tunerankings.com/" target="_blank">www.tunerankings.com</a>') l='';
basically what was happening, if there are no lyrics that stupid link is put in as the lyrics, so instead if that happens i set the lyrics to nothing
also i added these lines to the JS:
if(l == '<a href="http://www.lyricsvip.com/" target="_blank">http://www.lyricsvip.com</a>') l='';
else if(l == '<br><br><br><a href="http://www.tunerankings.com/" target="_blank">www.tunerankings.com</a>') l='';
basically what was happening, if there are no lyrics that stupid link is put in as the lyrics, so instead if that happens i set the lyrics to nothing
Code: Select all
<?php
$artist = $_GET["artist"];
$title = $_GET["title"];
$html = file_get_contents("http://www.lyricsplugin.com/winamp03/plugin/?title=$title&artist=$artist", true);
$arr1 = explode("javascript:getContent(",$html);
$arr2 = explode(", ",$arr1[1]);
$a = implode(explode("'",$arr2[0]));
$t = implode(explode("'",$arr2[0]));
$time = implode(explode("'",$arr2[2]));
$arr3 = explode(")",$arr2[3]);
$check = implode(explode("'",$arr3[0]));
echo file_get_contents("http://www.lyricsplugin.com/winamp03/plugin/content.php?artist=$artist&title=$title&time=$time&check=$check", true, stream_context_create(array("http"=>array("header"=>"Referer: http://www.lyricsplugin.com/winamp03/plugin/?title=$title&artist=$artist"))));
?>Code: Select all
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
var currentTrack = -1;
var currentArtist = 0;
var currentTitle = 0;
var currentRequest = 0;
var cachedArtist;
var cachedTitle;
var cachedTrack;
var loading;
var status;
var tracks;
var rLyricsPlugin;
var rLyricsPluginA;
var rLyricsWiki;
var rLyricsSongs;
var aA = new Array();
var aT = new Array();
var aR = new Array();
var bruteForce = false;
var tryCleanupWhitespace = false;
var tryAllArtists = false;
var tryCommaArtists = false;
var tryRejectSingleLine = false;
var trySingleLineSearch = ''; var trySingleLineReplace = '';
var tryParensA = false; var tryParensT = false;
var tryBracketsA = false; var tryBracketsT = false;
var tryBracesA = false; var tryBracesT = false;
var tryQuotesA = false; var tryQuotesT = false;
var trySplitArrayA = ''; var trySplitArrayT = '';
var tryBlackListA = ''; var tryBlackListT = '';
var tryLyricsPlugin = false;
var tryLyricsWiki = false;
var tryLyricsSongs = false;
var bDebug = false;
var paused = false;
var init = function() {
if(tryLyricsPlugin) {
rLyricsPlugin = new Request({method:'get',url:'http://brian-server/lyrics.php',onSuccess:rSuccessLP,onException:rNextLP,onFailure:rNextLP,onCancel:rNextLP});
rLyricsPlugin.sendString = 'title=%title%&artist=%artist%';
rLyricsPlugin.name = 'Lyrics Plugin';
rLyricsPlugin.className = 'lyricsplugin';
aR.include(rLyricsPlugin);
}
if(tryLyricsWiki) {
rLyricsWiki = new Request({method:'get',url:'http://lyricwiki.org/api.php',onSuccess:rSuccessLW,onException:rNextLW,onFailure:rNextLW,onCancel:rNextLW});
rLyricsWiki.sendString = 'artist=%artist%&song=%title%&fmt=text';
rLyricsWiki.name = 'Lyrics Wiki';
rLyricsWiki.className = 'lyricswiki';
aR.include(rLyricsWiki);
}
if(tryLyricsSongs) {
rLyricsSongs = new Request({method:'get',url:'http://www.lyrics-songs.com/winamp.php',onSuccess:rSuccessLS,onException:rNextLS,onFailure:rNextLS,onCancel:rNextLS});
rLyricsSongs.sendString = 'musica=%title%&artista=%artist%';
rLyricsSongs.name = 'Lyrics Songs';
rLyricsSongs.className = 'lyricssongs';
aR.include(rLyricsSongs);
}
bruteForce = tryAllArtists || tryCommaArtists || tryParensA || tryBracketsA || tryBracesA || trySplitArrayA || tryParensT || tryBracketsT || tryBracesT || trySplitArrayT;
loading = new Asset.image('loading.gif');
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;});});
$('Popup').innerHTML = '<button onclick="updateLyrics();">Update Lyrics</button><button onclick="closeLyrics();">Close</button><br /><textarea id="PopupLyrics"></textarea>';
$('Header').innerHTML = '<button id="PauseButton" onclick="pause();">Pause</button><span id="GlobalStatus"></span>';
whatNext(null, null, null, true);
}
var rNextLP = function() { whatNext(''); }
var rNextLW = rNextLP;
var rNextLS = rNextLP;
var rSuccessLP = function(html, xml) {
var l = ''; var a = ''; var t = '';
try {
l = html.split('<div id="lyrics">')[1].split('</div>')[0].trim();
l = cleanupLyrics(l);
if(l) {
a = html.split('<div id="artist">')[1].split('</div>')[0].trim();
t = html.split('<div id="title">')[1].split('</div>')[0].trim();
}
} catch(ex) {}
whatNext(l, a, t);
}
var rSuccessLW = function(html, xml) {
var l = ''; var a = ''; var t = '';
try { l = html.replace('Not found', '').replace(/<[^>]*>/g, "").replace(/\n/g, '<br>'); l = cleanupLyrics(l); } catch(ex) {}
whatNext(l, a, t);
}
var rSuccessLS = function(html, xml) {
var l = ''; var a = ''; var t = '';
try {
l = html.split('<h2>')[1].split('<p>')[1].split('</p>')[0].trim();
l = cleanupLyrics(l);
if(l) {
a = html.split('<h2>')[1].split('</h2>')[0].replace(/<[^>]*>/gi, "").trim();
t = html.split('<h1>')[1].split('</h1>')[0].replace(/<[^>]*>/gi, "").trim();
}
} catch(ex) {}
whatNext(l, a, t);
}
var cleanupLyrics = function(l) {
l = l.replace(/\r/gi, '');
l = l.replace(/\<br[\s]*[\/]*\>/gi, '<br>');
l = l.replace(/[\s]+/g, ' ');
l = l.replace(/\<br\>\s/g, '<br>');
l = l.replace(/(\<br\>)*$/g, '');
if(tryCleanupWhitespace) {
l = l.replace(/\<br\>\<br\>(\<br\>)+/g, '<br><br>');
l = l.replace(/(\s)*\<br\>/g, '<br>');
}
if(tryRejectSingleLine || trySingleLineSearch) {
var a = l.split('<br>');
if(a.length <= 1 || (a.length == 2 && a[1].trim() == '')) {
if(tryRejectSingleLine) return false;
if(l.toUpperCase().indexOf(trySingleLineSearch.toUpperCase()) >= 0)
l = trySingleLineReplace;
}
}
if(l == '<a href="http://www.lyricsvip.com/" target="_blank">http://www.lyricsvip.com</a>') l='';
else if(l == '<br><br><br><a href="http://www.tunerankings.com/" target="_blank">www.tunerankings.com</a>') l='';
return l;
}
var searchSend = function(r, a, t) {
var s = r.sendString.replace('%artist%', escape(a)).replace('%title%', escape(t));// + '&random=' + $time();
r.send(s);
}
var lyricsPopulate = function(l, a, t) {
var e = $(tracks[currentTrack]);
if(l) {
loading.inject('hidden');
status.inject('hidden');
if(currentArtist || currentTitle || currentRequest || aR[currentRequest].name == 'Lyrics Songs') {
e.addClass(aR[currentRequest].className);
if(!a) a = aA[currentArtist];
if(!t) t = aT[currentTitle];
e.getElement('div[class=artist]').innerHTML += '<br/><i>' + a + '</i>';
e.getElement('div[class=title]').innerHTML += '<br/><i>' + t + '</i>';
}
e.getElement('div[class=lyrics]').innerHTML = l;
var c = e.getElement('input[type=checkbox]')
c.checked = true; c.disabled = false;
}
}
var lyricsFailed = function() {
loading.inject('hidden');
status.inject('hidden');
var e = $(tracks[currentTrack]);
e.getElement('input[type=checkbox]').checked = false;
e.addClass('disabled');
}
var reS = new RegExp("[']*", "g");
var reD = new RegExp("[\"]*", "g");
var mapTrim = function(e, i) { return e.trim(); }
var mapQuoteS = function(e, i) { return e.replace(reS, '').trim(); }
var mapQuoteD = function(e, i) { return e.replace(reD, '').trim(); }
var mapParens = function(e, i) { return e.replace(/\(.*?\)/g, '').trim(); }
var mapBrackets = function(e, i) { return e.replace(/\[.*?\]/g, '').trim(); }
var mapBraces = function(e, i) { return e.replace(/\{.*?\}/g, '').trim(); }
var buildBruteForce = function() {
aA.empty(); aT.empty();
aA.include(cachedArtist);
aT.include(cachedTitle);
var s; var sa;
if(tryAllArtists) {
s = cachedArtist.split(';');
s.each(function(e) { aA.include(e.trim()); });
}
if(tryCommaArtists) { aA.include(cachedArtist.replace(/([\w ]+), ([\w ]+)/g, "$2 $1")); } // Code from "datta"
if(tryQuotesA) { aA.merge(aA.map(mapQuoteS)); aA.merge(aA.map(mapQuoteD)); }
if(tryQuotesT) { aT.merge(aT.map(mapQuoteS)); aT.merge(aT.map(mapQuoteD)); }
if(tryParensA) aA.merge(aA.map(mapParens)); if(tryParensT) aT.merge(aT.map(mapParens));
if(tryBracketsA) aA.merge(aA.map(mapBrackets)); if(tryBracketsT) aT.merge(aT.map(mapBrackets));
if(tryBracesA) aA.merge(aA.map(mapBraces)); if(tryBracesT) aT.merge(aT.map(mapBraces));
if(trySplitArrayA) { sa = trySplitArrayA.split(';'); sa.each(function(e) { aA.each(function(e2) { aA.merge(e2.split(e).map(mapTrim)); }); }); }
if(trySplitArrayT) { sa = trySplitArrayT.split(';'); sa.each(function(e) { aT.each(function(e2) { aT.merge(e2.split(e).map(mapTrim)); }); }); }
if(tryBlackListA) { sa = tryBlackListA.split(';'); sa.each(function(e) { aA.remove(e); }); }
if(tryBlackListT) { sa = tryBlackListT.split(';'); sa.each(function(e) { aT.remove(e); }); }
if(tryAllArtists) {
aA.include('Various');
}
aA = aA.clean();
aT = aT.clean();
}
var cache = function() {
var c = $(tracks[currentTrack]);
if(c) {
cachedArtist = c.getElement('div[class=artist]').innerText;
cachedTitle = c.getElement('div[class=title]').innerText;
cachedTrack = c;
}
}
var newTrack = function() {
currentArtist = currentTitle = currentRequest = 0;
cache();
if(cachedTrack) loading.inject(cachedTrack.getElement('div[class=lyrics]'));
if(currentTrack < tracks.length)
$('GlobalStatus').innerHTML = 'Processing Track #' + (currentTrack + 1) + '/' + tracks.length;
}
var pauseL, pauseA, pauseT;
var whatNext = function(l, foundA, foundT, init) {
if(paused) {
pauseL = l;
pauseA = foundA;
pauseT = foundT;
$('PauseButton').disabled = false;
$('PauseButton').innerHTML = 'Resume';
return false;
}
var a; var t;
if(init) {
currentTrack = 0; newTrack();
a = cachedArtist; t = cachedTitle;
} else if (l) {
lyricsPopulate(l, foundA, foundT);
currentTrack++; newTrack();
a = cachedArtist; t = cachedTitle;
} else {
var failed = false;
if(bruteForce) {
if(!currentArtist && !currentTitle && !currentRequest) {
buildBruteForce();
if(cachedTrack) status.inject(cachedTrack.getElement('div[class=lyrics]'));
}
if(currentRequest < aR.length - 1) {
currentRequest++;
} else {
currentRequest = 0;
if(currentTitle < aT.length - 1) {
currentTitle++;
} else {
currentTitle = 0; currentArtist++;
}
}
if(currentArtist >= aA.length) {
failed = true;
} else {
a = aA[currentArtist]; t = aT[currentTitle];
}
} else {
failed = true;
}
if(failed) {
lyricsFailed();
currentTrack++; newTrack();
a = cachedArtist; t = cachedTitle;
} else {
status.innerHTML = 'Trying ' + a + ' - ' + t;
}
}
if(currentTrack < tracks.length) {
cachedTrack.scrollIntoView(false);
(function() {searchSend(aR[currentRequest], a, t)}).delay(10);
} else {
loading.remove();
status.remove();
$('PauseButton').disabled = true;
}
}
var currentPopup = -1;
var closeLyrics = function() {
currentPopup = -1;
var p = $('Popup');
var pl = $('PopupLyrics');
pl.value = '';
p.style.visibility = 'hidden';
return false;
}
var updateLyrics = function() {
var p = $('Popup');
var pl = $('PopupLyrics');
var l = pl.value.replace(/\r/g, '<br>');
$(currentPopup).getElement('div[class=lyrics]').innerHTML = cleanupLyrics(l);
closeLyrics();
}
var trackContextMenu = function() {
currentPopup = this.id;
var l = this.getElement('div[class=lyrics]');
var p = $('Popup');
var pl = $('PopupLyrics');
pl.value = l.innerHTML.replace(/\<br\>/gi, '\n');
p.style.visibility = 'visible';
p.style.top = document.body.scrollTop;
return false;
}
var trackClick = function() {
var c = this.getElement('input[type=checkbox]');
if(!c.disabled) c.checked = !c.checked;
if(!c.checked) this.addClass('unchecked'); else this.removeClass('unchecked');
}
var pause = function() {
var p = $('PauseButton');
if(p.innerHTML == 'Pause') {
p.disabled = true;
p.innerHTML = 'Pausing ...';
paused = true;
loading.inject('hidden');
status.inject('hidden');
} else {
paused = false;
p.innerHTML = 'Pause';
whatNext(pauseL, pauseA, pauseT);
}
}
var trackOver = function() { this.style.backgroundColor = '#fffff0'; }
var trackOut = function() { this.style.backgroundColor = ''; }
window.addEvent('domready', init);
var test = function() {
currentTrack = -1;
whatNext(null, null, null, true);
}
var debug = function(t) {
if(bDebug) $('Debug').innerHTML += currentTrack + '|' + t + '<br />';
}Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
So where do the two separate sets of codes go? I see the second one is lyricator.js in same folder but the first?
Barkoz
Barkoz
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
The first file needs to go on a webserver with php installed.
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.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
Ok, yeah forgot to mention that 
Not really a php-pro here or something
Not really a php-pro here or something
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
So does this mean we are still screwed (basically). I don't know a lot about web servers so having php installed or otherwise doesn't mean a lot to me. 
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
Yes, screwed unless you can host the file yourself or someone publicly hosts the file (I'm thinking about it).
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.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
I thought so, I don't have a web server and you probably do enough for all of us here. Wouldn't the developers be able to host the file if they were so inclined?
-
guest
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
There are lots of free PHP hosting services. Try x10hosting.com, just upload your php and you're good to go. I tried running the script locally, but it wasn't working (I suspected, but thought I'd try anyway). saddly, ISPs in my area block TCP redirects to stop residential customers from running webservers, otherwise I'd have hosted it my self. I tried Ripkins code on a hosted service, but it returned blanks, not sure if it's to do with the server or the script. I'll keep
-
guest
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
Tried with this:
http://mmlyrics-scan.x10.mx/lyric.php?t ... ist=danzig
Url returns proper results, but the script doesn't return the lyrics. Is there a delay needed somewhere?
In any event, one we get the script sorted out, the above address should work.
http://mmlyrics-scan.x10.mx/lyric.php?t ... ist=danzig
Url returns proper results, but the script doesn't return the lyrics. Is there a delay needed somewhere?
In any event, one we get the script sorted out, the above address should work.
-
guest
Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
Okay it works (sort of) Script needed a "?"
It finds some tracks, others it misses. A manual input of the URL works when the script doesn't find anything. Only works with single word titles, so there's a problem with the url parsing.
Code: Select all
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
var currentTrack = -1;
var currentArtist = 0;
var currentTitle = 0;
var currentRequest = 0;
var cachedArtist;
var cachedTitle;
var cachedTrack;
var loading;
var status;
var tracks;
var rLyricsPlugin;
var rLyricsPluginA;
var rLyricsWiki;
var rLyricsSongs;
var aA = new Array();
var aT = new Array();
var aR = new Array();
var bruteForce = false;
var tryCleanupWhitespace = false;
var tryAllArtists = false;
var tryCommaArtists = false;
var tryRejectSingleLine = false;
var trySingleLineSearch = ''; var trySingleLineReplace = '';
var tryParensA = false; var tryParensT = false;
var tryBracketsA = false; var tryBracketsT = false;
var tryBracesA = false; var tryBracesT = false;
var tryQuotesA = false; var tryQuotesT = false;
var trySplitArrayA = ''; var trySplitArrayT = '';
var tryBlackListA = ''; var tryBlackListT = '';
var tryLyricsPlugin = false;
var tryLyricsWiki = false;
var tryLyricsSongs = false;
var bDebug = false;
var paused = false;
var init = function() {
if(tryLyricsPlugin) {
rLyricsPlugin = new Request({method:'get',url:'http://mmlyrics-scan.x10.mx/lyric.php?',onSuccess:rSuccessLP,onException:rNextLP,onFailure:rNextLP,onCancel:rNextLP});
rLyricsPlugin.sendString = 'title=%title%&artist=%artist%';
rLyricsPlugin.name = 'Lyrics Plugin';
rLyricsPlugin.className = 'lyricsplugin';
aR.include(rLyricsPlugin);
}
if(tryLyricsWiki) {
rLyricsWiki = new Request({method:'get',url:'http://lyricwiki.org/api.php',onSuccess:rSuccessLW,onException:rNextLW,onFailure:rNextLW,onCancel:rNextLW});
rLyricsWiki.sendString = 'artist=%artist%&song=%title%&fmt=text';
rLyricsWiki.name = 'Lyrics Wiki';
rLyricsWiki.className = 'lyricswiki';
aR.include(rLyricsWiki);
}
if(tryLyricsSongs) {
rLyricsSongs = new Request({method:'get',url:'http://www.lyrics-songs.com/winamp.php',onSuccess:rSuccessLS,onException:rNextLS,onFailure:rNextLS,onCancel:rNextLS});
rLyricsSongs.sendString = 'musica=%title%&artista=%artist%';
rLyricsSongs.name = 'Lyrics Songs';
rLyricsSongs.className = 'lyricssongs';
aR.include(rLyricsSongs);
}
bruteForce = tryAllArtists || tryCommaArtists || tryParensA || tryBracketsA || tryBracesA || trySplitArrayA || tryParensT || tryBracketsT || tryBracesT || trySplitArrayT;
loading = new Asset.image('loading.gif');
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;});});
$('Popup').innerHTML = '<button onclick="updateLyrics();">Update Lyrics</button><button onclick="closeLyrics();">Close</button><br /><textarea id="PopupLyrics"></textarea>';
$('Header').innerHTML = '<button id="PauseButton" onclick="pause();">Pause</button><span id="GlobalStatus"></span>';
whatNext(null, null, null, true);
}
var rNextLP = function() { whatNext(''); }
var rNextLW = rNextLP;
var rNextLS = rNextLP;
var rSuccessLP = function(html, xml) {
var l = ''; var a = ''; var t = '';
try {
l = html.split('<div id="lyrics">')[1].split('</div>')[0].trim();
l = cleanupLyrics(l);
if(l) {
a = html.split('<div id="artist">')[1].split('</div>')[0].trim();
t = html.split('<div id="title">')[1].split('</div>')[0].trim();
}
} catch(ex) {}
whatNext(l, a, t);
}
var rSuccessLW = function(html, xml) {
var l = ''; var a = ''; var t = '';
try { l = html.replace('Not found', '').replace(/<[^>]*>/g, "").replace(/\n/g, '<br>'); l = cleanupLyrics(l); } catch(ex) {}
whatNext(l, a, t);
}
var rSuccessLS = function(html, xml) {
var l = ''; var a = ''; var t = '';
try {
l = html.split('<h2>')[1].split('<p>')[1].split('</p>')[0].trim();
l = cleanupLyrics(l);
if(l) {
a = html.split('<h2>')[1].split('</h2>')[0].replace(/<[^>]*>/gi, "").trim();
t = html.split('<h1>')[1].split('</h1>')[0].replace(/<[^>]*>/gi, "").trim();
}
} catch(ex) {}
whatNext(l, a, t);
}
var cleanupLyrics = function(l) {
l = l.replace(/\r/gi, '');
l = l.replace(/\<br[\s]*[\/]*\>/gi, '<br>');
l = l.replace(/[\s]+/g, ' ');
l = l.replace(/\<br\>\s/g, '<br>');
l = l.replace(/(\<br\>)*$/g, '');
if(tryCleanupWhitespace) {
l = l.replace(/\<br\>\<br\>(\<br\>)+/g, '<br><br>');
l = l.replace(/(\s)*\<br\>/g, '<br>');
}
if(tryRejectSingleLine || trySingleLineSearch) {
var a = l.split('<br>');
if(a.length <= 1 || (a.length == 2 && a[1].trim() == '')) {
if(tryRejectSingleLine) return false;
if(l.toUpperCase().indexOf(trySingleLineSearch.toUpperCase()) >= 0)
l = trySingleLineReplace;
}
}
if(l == '<a href="http://www.lyricsvip.com/" target="_blank">http://www.lyricsvip.com</a>') l='';
else if(l == '<br><br><br><a href="http://www.tunerankings.com/" target="_blank">www.tunerankings.com</a>') l='';
return l;
}
var searchSend = function(r, a, t) {
var s = r.sendString.replace('%artist%', escape(a)).replace('%title%', escape(t));// + '&random=' + $time();
r.send(s);
}
var lyricsPopulate = function(l, a, t) {
var e = $(tracks[currentTrack]);
if(l) {
loading.inject('hidden');
status.inject('hidden');
if(currentArtist || currentTitle || currentRequest || aR[currentRequest].name == 'Lyrics Songs') {
e.addClass(aR[currentRequest].className);
if(!a) a = aA[currentArtist];
if(!t) t = aT[currentTitle];
e.getElement('div[class=artist]').innerHTML += '<br/><i>' + a + '</i>';
e.getElement('div[class=title]').innerHTML += '<br/><i>' + t + '</i>';
}
e.getElement('div[class=lyrics]').innerHTML = l;
var c = e.getElement('input[type=checkbox]')
c.checked = true; c.disabled = false;
}
}
var lyricsFailed = function() {
loading.inject('hidden');
status.inject('hidden');
var e = $(tracks[currentTrack]);
e.getElement('input[type=checkbox]').checked = false;
e.addClass('disabled');
}
var reS = new RegExp("[']*", "g");
var reD = new RegExp("[\"]*", "g");
var mapTrim = function(e, i) { return e.trim(); }
var mapQuoteS = function(e, i) { return e.replace(reS, '').trim(); }
var mapQuoteD = function(e, i) { return e.replace(reD, '').trim(); }
var mapParens = function(e, i) { return e.replace(/\(.*?\)/g, '').trim(); }
var mapBrackets = function(e, i) { return e.replace(/\[.*?\]/g, '').trim(); }
var mapBraces = function(e, i) { return e.replace(/\{.*?\}/g, '').trim(); }
var buildBruteForce = function() {
aA.empty(); aT.empty();
aA.include(cachedArtist);
aT.include(cachedTitle);
var s; var sa;
if(tryAllArtists) {
s = cachedArtist.split(';');
s.each(function(e) { aA.include(e.trim()); });
}
if(tryCommaArtists) { aA.include(cachedArtist.replace(/([\w ]+), ([\w ]+)/g, "$2 $1")); } // Code from "datta"
if(tryQuotesA) { aA.merge(aA.map(mapQuoteS)); aA.merge(aA.map(mapQuoteD)); }
if(tryQuotesT) { aT.merge(aT.map(mapQuoteS)); aT.merge(aT.map(mapQuoteD)); }
if(tryParensA) aA.merge(aA.map(mapParens)); if(tryParensT) aT.merge(aT.map(mapParens));
if(tryBracketsA) aA.merge(aA.map(mapBrackets)); if(tryBracketsT) aT.merge(aT.map(mapBrackets));
if(tryBracesA) aA.merge(aA.map(mapBraces)); if(tryBracesT) aT.merge(aT.map(mapBraces));
if(trySplitArrayA) { sa = trySplitArrayA.split(';'); sa.each(function(e) { aA.each(function(e2) { aA.merge(e2.split(e).map(mapTrim)); }); }); }
if(trySplitArrayT) { sa = trySplitArrayT.split(';'); sa.each(function(e) { aT.each(function(e2) { aT.merge(e2.split(e).map(mapTrim)); }); }); }
if(tryBlackListA) { sa = tryBlackListA.split(';'); sa.each(function(e) { aA.remove(e); }); }
if(tryBlackListT) { sa = tryBlackListT.split(';'); sa.each(function(e) { aT.remove(e); }); }
if(tryAllArtists) {
aA.include('Various');
}
aA = aA.clean();
aT = aT.clean();
}
var cache = function() {
var c = $(tracks[currentTrack]);
if(c) {
cachedArtist = c.getElement('div[class=artist]').innerText;
cachedTitle = c.getElement('div[class=title]').innerText;
cachedTrack = c;
}
}
var newTrack = function() {
currentArtist = currentTitle = currentRequest = 0;
cache();
if(cachedTrack) loading.inject(cachedTrack.getElement('div[class=lyrics]'));
if(currentTrack < tracks.length)
$('GlobalStatus').innerHTML = 'Processing Track #' + (currentTrack + 1) + '/' + tracks.length;
}
var pauseL, pauseA, pauseT;
var whatNext = function(l, foundA, foundT, init) {
if(paused) {
pauseL = l;
pauseA = foundA;
pauseT = foundT;
$('PauseButton').disabled = false;
$('PauseButton').innerHTML = 'Resume';
return false;
}
var a; var t;
if(init) {
currentTrack = 0; newTrack();
a = cachedArtist; t = cachedTitle;
} else if (l) {
lyricsPopulate(l, foundA, foundT);
currentTrack++; newTrack();
a = cachedArtist; t = cachedTitle;
} else {
var failed = false;
if(bruteForce) {
if(!currentArtist && !currentTitle && !currentRequest) {
buildBruteForce();
if(cachedTrack) status.inject(cachedTrack.getElement('div[class=lyrics]'));
}
if(currentRequest < aR.length - 1) {
currentRequest++;
} else {
currentRequest = 0;
if(currentTitle < aT.length - 1) {
currentTitle++;
} else {
currentTitle = 0; currentArtist++;
}
}
if(currentArtist >= aA.length) {
failed = true;
} else {
a = aA[currentArtist]; t = aT[currentTitle];
}
} else {
failed = true;
}
if(failed) {
lyricsFailed();
currentTrack++; newTrack();
a = cachedArtist; t = cachedTitle;
} else {
status.innerHTML = 'Trying ' + a + ' - ' + t;
}
}
if(currentTrack < tracks.length) {
cachedTrack.scrollIntoView(false);
(function() {searchSend(aR[currentRequest], a, t)}).delay(10);
} else {
loading.remove();
status.remove();
$('PauseButton').disabled = true;
}
}
var currentPopup = -1;
var closeLyrics = function() {
currentPopup = -1;
var p = $('Popup');
var pl = $('PopupLyrics');
pl.value = '';
p.style.visibility = 'hidden';
return false;
}
var updateLyrics = function() {
var p = $('Popup');
var pl = $('PopupLyrics');
var l = pl.value.replace(/\r/g, '<br>');
$(currentPopup).getElement('div[class=lyrics]').innerHTML = cleanupLyrics(l);
closeLyrics();
}
var trackContextMenu = function() {
currentPopup = this.id;
var l = this.getElement('div[class=lyrics]');
var p = $('Popup');
var pl = $('PopupLyrics');
pl.value = l.innerHTML.replace(/\<br\>/gi, '\n');
p.style.visibility = 'visible';
p.style.top = document.body.scrollTop;
return false;
}
var trackClick = function() {
var c = this.getElement('input[type=checkbox]');
if(!c.disabled) c.checked = !c.checked;
if(!c.checked) this.addClass('unchecked'); else this.removeClass('unchecked');
}
var pause = function() {
var p = $('PauseButton');
if(p.innerHTML == 'Pause') {
p.disabled = true;
p.innerHTML = 'Pausing ...';
paused = true;
loading.inject('hidden');
status.inject('hidden');
} else {
paused = false;
p.innerHTML = 'Pause';
whatNext(pauseL, pauseA, pauseT);
}
}
var trackOver = function() { this.style.backgroundColor = '#fffff0'; }
var trackOut = function() { this.style.backgroundColor = ''; }
window.addEvent('domready', init);
var test = function() {
currentTrack = -1;
whatNext(null, null, null, true);
}
var debug = function(t) {
if(bDebug) $('Debug').innerHTML += currentTrack + '|' + t + '<br />';
}Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
ok, this fixes the issue with the spaces.
i think there is a better command to do it but i cant think of it right now
i think there is a better command to do it but i cant think of it right now
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$artist = str_replace(' ','%20',$_GET["artist"]);
$title = str_replace(' ','%20',$_GET["title"]);
$html = file_get_contents("http://www.lyricsplugin.com/winamp03/plugin/?title=$title&artist=$artist", true);
$arr1 = explode("javascript:getContent(",$html);
$arr2 = explode(", ",$arr1[1]);
$a = implode(explode("'",$arr2[0]));
$t = implode(explode("'",$arr2[0]));
$time = implode(explode("'",$arr2[2]));
$arr3 = explode(")",$arr2[3]);
$check = implode(explode("'",$arr3[0]));
echo $lyrics = file_get_contents("http://www.lyricsplugin.com/winamp03/plugin/content.php?artist=$artist&title=$title&time=$time&check=$check", true, stream_context_create(array("http"=>array("header"=>"Referer: http://www.lyricsplugin.com/winamp03/plugin/?title=$title&artist=$artist"))));
?>Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
I uploaded your new php file, and it's working great. It's somewhat slower than the original due to the redirect from the shitty free server I'm using, but it works. I'm averaging 1 track per second, and it's running fairly robustly. It's now on track 1270/9893 and so far everything is found and 100% correct.
For anyone who didn't have a php server, just use mine with the below file.
Here's the working file. Paste over the contents of Lyricator.js
Code: Select all
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
var currentTrack = -1;
var currentArtist = 0;
var currentTitle = 0;
var currentRequest = 0;
var cachedArtist;
var cachedTitle;
var cachedTrack;
var loading;
var status;
var tracks;
var rLyricsPlugin;
var rLyricsPluginA;
var rLyricsWiki;
var rLyricsSongs;
var aA = new Array();
var aT = new Array();
var aR = new Array();
var bruteForce = false;
var tryCleanupWhitespace = false;
var tryAllArtists = false;
var tryCommaArtists = false;
var tryRejectSingleLine = false;
var trySingleLineSearch = ''; var trySingleLineReplace = '';
var tryParensA = false; var tryParensT = false;
var tryBracketsA = false; var tryBracketsT = false;
var tryBracesA = false; var tryBracesT = false;
var tryQuotesA = false; var tryQuotesT = false;
var trySplitArrayA = ''; var trySplitArrayT = '';
var tryBlackListA = ''; var tryBlackListT = '';
var tryLyricsPlugin = false;
var tryLyricsWiki = false;
var tryLyricsSongs = false;
var bDebug = false;
var paused = false;
var init = function() {
if(tryLyricsPlugin) {
rLyricsPlugin = new Request({method:'get',url:'http://mmlyrics-scan.x10.mx/lyric.php?',onSuccess:rSuccessLP,onException:rNextLP,onFailure:rNextLP,onCancel:rNextLP});
rLyricsPlugin.sendString = 'title=%title%&artist=%artist%';
rLyricsPlugin.name = 'Lyrics Plugin';
rLyricsPlugin.className = 'lyricsplugin';
aR.include(rLyricsPlugin);
}
if(tryLyricsWiki) {
rLyricsWiki = new Request({method:'get',url:'http://lyricwiki.org/api.php',onSuccess:rSuccessLW,onException:rNextLW,onFailure:rNextLW,onCancel:rNextLW});
rLyricsWiki.sendString = 'artist=%artist%&song=%title%&fmt=text';
rLyricsWiki.name = 'Lyrics Wiki';
rLyricsWiki.className = 'lyricswiki';
aR.include(rLyricsWiki);
}
if(tryLyricsSongs) {
rLyricsSongs = new Request({method:'get',url:'http://www.lyrics-songs.com/winamp.php',onSuccess:rSuccessLS,onException:rNextLS,onFailure:rNextLS,onCancel:rNextLS});
rLyricsSongs.sendString = 'musica=%title%&artista=%artist%';
rLyricsSongs.name = 'Lyrics Songs';
rLyricsSongs.className = 'lyricssongs';
aR.include(rLyricsSongs);
}
bruteForce = tryAllArtists || tryCommaArtists || tryParensA || tryBracketsA || tryBracesA || trySplitArrayA || tryParensT || tryBracketsT || tryBracesT || trySplitArrayT;
loading = new Asset.image('loading.gif');
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;});});
$('Popup').innerHTML = '<button onclick="updateLyrics();">Update Lyrics</button><button onclick="closeLyrics();">Close</button><br /><textarea id="PopupLyrics"></textarea>';
$('Header').innerHTML = '<button id="PauseButton" onclick="pause();">Pause</button><span id="GlobalStatus"></span>';
whatNext(null, null, null, true);
}
var rNextLP = function() { whatNext(''); }
var rNextLW = rNextLP;
var rNextLS = rNextLP;
var rSuccessLP = function(html, xml) {
var l = ''; var a = ''; var t = '';
try {
l = html.split('<div id="lyrics">')[1].split('</div>')[0].trim();
l = cleanupLyrics(l);
if(l) {
a = html.split('<div id="artist">')[1].split('</div>')[0].trim();
t = html.split('<div id="title">')[1].split('</div>')[0].trim();
}
} catch(ex) {}
whatNext(l, a, t);
}
var rSuccessLW = function(html, xml) {
var l = ''; var a = ''; var t = '';
try { l = html.replace('Not found', '').replace(/<[^>]*>/g, "").replace(/\n/g, '<br>'); l = cleanupLyrics(l); } catch(ex) {}
whatNext(l, a, t);
}
var rSuccessLS = function(html, xml) {
var l = ''; var a = ''; var t = '';
try {
l = html.split('<h2>')[1].split('<p>')[1].split('</p>')[0].trim();
l = cleanupLyrics(l);
if(l) {
a = html.split('<h2>')[1].split('</h2>')[0].replace(/<[^>]*>/gi, "").trim();
t = html.split('<h1>')[1].split('</h1>')[0].replace(/<[^>]*>/gi, "").trim();
}
} catch(ex) {}
whatNext(l, a, t);
}
var cleanupLyrics = function(l) {
l = l.replace(/\r/gi, '');
l = l.replace(/\<br[\s]*[\/]*\>/gi, '<br>');
l = l.replace(/[\s]+/g, ' ');
l = l.replace(/\<br\>\s/g, '<br>');
l = l.replace(/(\<br\>)*$/g, '');
if(tryCleanupWhitespace) {
l = l.replace(/\<br\>\<br\>(\<br\>)+/g, '<br><br>');
l = l.replace(/(\s)*\<br\>/g, '<br>');
}
if(tryRejectSingleLine || trySingleLineSearch) {
var a = l.split('<br>');
if(a.length <= 1 || (a.length == 2 && a[1].trim() == '')) {
if(tryRejectSingleLine) return false;
if(l.toUpperCase().indexOf(trySingleLineSearch.toUpperCase()) >= 0)
l = trySingleLineReplace;
}
}
if(l == '<a href="http://www.lyricsvip.com/" target="_blank">http://www.lyricsvip.com</a>') l='';
else if(l == '<br><br><br><a href="http://www.tunerankings.com/" target="_blank">www.tunerankings.com</a>') l='';
return l;
}
var searchSend = function(r, a, t) {
var s = r.sendString.replace('%artist%', escape(a)).replace('%title%', escape(t));// + '&random=' + $time();
r.send(s);
}
var lyricsPopulate = function(l, a, t) {
var e = $(tracks[currentTrack]);
if(l) {
loading.inject('hidden');
status.inject('hidden');
if(currentArtist || currentTitle || currentRequest || aR[currentRequest].name == 'Lyrics Songs') {
e.addClass(aR[currentRequest].className);
if(!a) a = aA[currentArtist];
if(!t) t = aT[currentTitle];
e.getElement('div[class=artist]').innerHTML += '<br/><i>' + a + '</i>';
e.getElement('div[class=title]').innerHTML += '<br/><i>' + t + '</i>';
}
e.getElement('div[class=lyrics]').innerHTML = l;
var c = e.getElement('input[type=checkbox]')
c.checked = true; c.disabled = false;
}
}
var lyricsFailed = function() {
loading.inject('hidden');
status.inject('hidden');
var e = $(tracks[currentTrack]);
e.getElement('input[type=checkbox]').checked = false;
e.addClass('disabled');
}
var reS = new RegExp("[']*", "g");
var reD = new RegExp("[\"]*", "g");
var mapTrim = function(e, i) { return e.trim(); }
var mapQuoteS = function(e, i) { return e.replace(reS, '').trim(); }
var mapQuoteD = function(e, i) { return e.replace(reD, '').trim(); }
var mapParens = function(e, i) { return e.replace(/\(.*?\)/g, '').trim(); }
var mapBrackets = function(e, i) { return e.replace(/\[.*?\]/g, '').trim(); }
var mapBraces = function(e, i) { return e.replace(/\{.*?\}/g, '').trim(); }
var buildBruteForce = function() {
aA.empty(); aT.empty();
aA.include(cachedArtist);
aT.include(cachedTitle);
var s; var sa;
if(tryAllArtists) {
s = cachedArtist.split(';');
s.each(function(e) { aA.include(e.trim()); });
}
if(tryCommaArtists) { aA.include(cachedArtist.replace(/([\w ]+), ([\w ]+)/g, "$2 $1")); } // Code from "datta"
if(tryQuotesA) { aA.merge(aA.map(mapQuoteS)); aA.merge(aA.map(mapQuoteD)); }
if(tryQuotesT) { aT.merge(aT.map(mapQuoteS)); aT.merge(aT.map(mapQuoteD)); }
if(tryParensA) aA.merge(aA.map(mapParens)); if(tryParensT) aT.merge(aT.map(mapParens));
if(tryBracketsA) aA.merge(aA.map(mapBrackets)); if(tryBracketsT) aT.merge(aT.map(mapBrackets));
if(tryBracesA) aA.merge(aA.map(mapBraces)); if(tryBracesT) aT.merge(aT.map(mapBraces));
if(trySplitArrayA) { sa = trySplitArrayA.split(';'); sa.each(function(e) { aA.each(function(e2) { aA.merge(e2.split(e).map(mapTrim)); }); }); }
if(trySplitArrayT) { sa = trySplitArrayT.split(';'); sa.each(function(e) { aT.each(function(e2) { aT.merge(e2.split(e).map(mapTrim)); }); }); }
if(tryBlackListA) { sa = tryBlackListA.split(';'); sa.each(function(e) { aA.remove(e); }); }
if(tryBlackListT) { sa = tryBlackListT.split(';'); sa.each(function(e) { aT.remove(e); }); }
if(tryAllArtists) {
aA.include('Various');
}
aA = aA.clean();
aT = aT.clean();
}
var cache = function() {
var c = $(tracks[currentTrack]);
if(c) {
cachedArtist = c.getElement('div[class=artist]').innerText;
cachedTitle = c.getElement('div[class=title]').innerText;
cachedTrack = c;
}
}
var newTrack = function() {
currentArtist = currentTitle = currentRequest = 0;
cache();
if(cachedTrack) loading.inject(cachedTrack.getElement('div[class=lyrics]'));
if(currentTrack < tracks.length)
$('GlobalStatus').innerHTML = 'Processing Track #' + (currentTrack + 1) + '/' + tracks.length;
}
var pauseL, pauseA, pauseT;
var whatNext = function(l, foundA, foundT, init) {
if(paused) {
pauseL = l;
pauseA = foundA;
pauseT = foundT;
$('PauseButton').disabled = false;
$('PauseButton').innerHTML = 'Resume';
return false;
}
var a; var t;
if(init) {
currentTrack = 0; newTrack();
a = cachedArtist; t = cachedTitle;
} else if (l) {
lyricsPopulate(l, foundA, foundT);
currentTrack++; newTrack();
a = cachedArtist; t = cachedTitle;
} else {
var failed = false;
if(bruteForce) {
if(!currentArtist && !currentTitle && !currentRequest) {
buildBruteForce();
if(cachedTrack) status.inject(cachedTrack.getElement('div[class=lyrics]'));
}
if(currentRequest < aR.length - 1) {
currentRequest++;
} else {
currentRequest = 0;
if(currentTitle < aT.length - 1) {
currentTitle++;
} else {
currentTitle = 0; currentArtist++;
}
}
if(currentArtist >= aA.length) {
failed = true;
} else {
a = aA[currentArtist]; t = aT[currentTitle];
}
} else {
failed = true;
}
if(failed) {
lyricsFailed();
currentTrack++; newTrack();
a = cachedArtist; t = cachedTitle;
} else {
status.innerHTML = 'Trying ' + a + ' - ' + t;
}
}
if(currentTrack < tracks.length) {
cachedTrack.scrollIntoView(false);
(function() {searchSend(aR[currentRequest], a, t)}).delay(10);
} else {
loading.remove();
status.remove();
$('PauseButton').disabled = true;
}
}
var currentPopup = -1;
var closeLyrics = function() {
currentPopup = -1;
var p = $('Popup');
var pl = $('PopupLyrics');
pl.value = '';
p.style.visibility = 'hidden';
return false;
}
var updateLyrics = function() {
var p = $('Popup');
var pl = $('PopupLyrics');
var l = pl.value.replace(/\r/g, '<br>');
$(currentPopup).getElement('div[class=lyrics]').innerHTML = cleanupLyrics(l);
closeLyrics();
}
var trackContextMenu = function() {
currentPopup = this.id;
var l = this.getElement('div[class=lyrics]');
var p = $('Popup');
var pl = $('PopupLyrics');
pl.value = l.innerHTML.replace(/\<br\>/gi, '\n');
p.style.visibility = 'visible';
p.style.top = document.body.scrollTop;
return false;
}
var trackClick = function() {
var c = this.getElement('input[type=checkbox]');
if(!c.disabled) c.checked = !c.checked;
if(!c.checked) this.addClass('unchecked'); else this.removeClass('unchecked');
}
var pause = function() {
var p = $('PauseButton');
if(p.innerHTML == 'Pause') {
p.disabled = true;
p.innerHTML = 'Pausing ...';
paused = true;
loading.inject('hidden');
status.inject('hidden');
} else {
paused = false;
p.innerHTML = 'Pause';
whatNext(pauseL, pauseA, pauseT);
}
}
var trackOver = function() { this.style.backgroundColor = '#fffff0'; }
var trackOut = function() { this.style.backgroundColor = ''; }
window.addEvent('domready', init);
var test = function() {
currentTrack = -1;
whatNext(null, null, null, true);
}
var debug = function(t) {
if(bDebug) $('Debug').innerHTML += currentTrack + '|' + t + '<br />';
}Re: Lyricator - Batch Lyrics Updater v1.00 [MM3]
So You experts solved the problem, congratulations.
Could anyone now explain to the beginners how to solve the problem, step by step?
Thank you!
K.
Could anyone now explain to the beginners how to solve the problem, step by step?
Thank you!
K.