<?php
set_time_limit(300000);
include_once('config.inc.php');
include_once('set_error_handling.php');
class TagCorrection
{
/******************************************************************************************************************
-Used to initialise variables.
/******************************************************************************************************************/
var $is_debug;
var $path_symbol;
var $album_art_folder;
/******************************************************************************************************************
-Class constructor. set path symbol to "/" if running on linux. set it to "\" if running on windows.
/******************************************************************************************************************/
function TagCorrection()
{
$this->is_debug=0;
$this->path_symbol="/";
$this->album_art_folder="/home/search/public_html/mp3management/album_art";
}
/******************************************************************************************************************
-Main function used to correct tags and download lyrics and artist information.
/******************************************************************************************************************/
function CorrectTags()
{
$stimer = explode(' ', microtime());
$stimer = $stimer[1] + $stimer[0];
$select_str="SELECT * FROM mp_id3_tags WHERE is_corrected=0";
$result=$this->safe_mysql_query($select_str);
$counter=0;
$artist_list=array();
$album_list=array();
$album_art_list=array();
$title_url_list=array();
$total_count=mysql_num_rows($result);
while ($row=mysql_fetch_assoc($result))
{
$is_lyrics=0;
$is_artist_details=0;
$id=$row['ID'];
$new_artist=$old_artist=$row['artist'];
$new_album=$old_album=$row['album'];
$new_title=$old_title=$row['title'];
$new_year=$old_year=$row['year'];
$new_album_art=$old_album_art=$row['album_art'];
$new_genre=$old_genre=$row['genre'];
$new_track=$old_track=$row['track'];
$title_url=$genre_url=$album=$artist=$album_art=$title=$genre=$is_artist_bio=$artist_biography="";
$insert_str=$artist_genre=$artist_image=$artist_top_albums=$artist_top_tracks=$similar_artists="";
$this->DebuggingMessage("<b>Row: ".($counter +1)."</b><br/><br/>");
if(isset($artist_list[$old_artist])===false)
{
if($old_artist!="")$artist=$this->CorrectArtistTag($old_artist);
if($artist!="")$new_artist=$artist;
$artist_list[$old_artist]=$new_artist;
sleep(1);
if($new_artist!="") $artist_genre=$this->GetArtistGenre($new_artist);
sleep(1);
$this->DebuggingMessage("artist_genre: ".$artist_genre."<br/>");
if($new_artist!="") $artist_top_tracks=$this->GetArtistTopTracks($new_artist);
sleep(1);
$this->DebuggingMessage("artist_top_tracks: ".$artist_top_tracks."<br/>");
if($new_artist!="") $artist_top_albums=$this->GetArtistTopAlbums($new_artist);
sleep(1);
$this->DebuggingMessage("artist_top_albums: ".$artist_top_albums."<br/>");
if($new_artist!="") list($similar_artists,$artist_image)=$this->GetSimilarArtists($new_artist);
sleep(1);
$this->DebuggingMessage("similar_artists: ".$similar_artists."<br/>");
$this->DebuggingMessage("artist_image: ".$artist_image."<br/>");
if($new_artist!="")
{
list($is_artist_bio,$artist_biography)=$this->GetArtistBiography($new_artist);
$insert_str=$this->SaveArtistInformation($new_artist,$artist_genre,$artist_top_tracks,$artist_top_albums,$similar_artists,$artist_image,$artist_biography);
}
sleep(1);
if($artist_genre!=""&&$artist_image!=""&&$artist_top_albums!=""&&$artist_top_tracks!=""&&$similar_artists!="")$is_artist_details=1;
$this->DebuggingMessage($insert_str."<br/>");
}
else $new_artist=$artist_list[$old_artist];
$this->DebuggingMessage("old_artist: ".$old_artist.", new_artist: ".$new_artist."<br/>");
if(isset($album_list[$old_album])===false || isset($title_url_list[$new_artist." ".$old_album])===false || isset($album_art_list[$old_album_art])===false)
{
if($old_album!="" && $new_artist!="")list($album,$album_art,$title_url)=$this->CorrectAlbumTag($new_artist,$old_album);
if($album!="")$new_album=$album;
if($album_art!="")$new_album_art=$album_art;
$album_list[$old_album]=$new_album;
$album_art_list[$old_album_art]=$new_album_art;
$title_url_list[$new_artist." ".$old_album]=$title_url;
sleep(1);
}
else
{
$new_album=$album_list[$old_album];
$new_album_art=$album_art_list[$old_album_art];
$title_url=$title_url_list[$new_artist." ".$old_album];
}
$this->DebuggingMessage("old_album: ".$old_album.", new_album: ".$new_album."<br/>");
$this->DebuggingMessage("old_album_art: ".$old_album_art.", new_album_art: ".$new_album_art."<br/>");
if($old_title!="")list($title,$year,$track,$genre_url)=$this->CorrectTitleTag($title_url,$old_title);
if($title!="")$new_title=$title;
if($year!="")$new_year=$year;
if($track!="")$new_track=$track;
sleep(1);
$this->DebuggingMessage("old_title: ".$old_title.", new_title: ".$new_title."<br/>");
$this->DebuggingMessage("old_year: ".$old_year.", new_year: ".$new_year."<br/>");
$this->DebuggingMessage("old_track: ".$old_track.", new_track: ".$new_track."<br/>");
if($genre_url!="")$genre=$this->CorrectGenreTag($genre_url);
if($genre!="")$new_genre=$genre;
sleep(1);
$this->DebuggingMessage("old_genre: ".$old_genre.", new_genre: ".$new_genre."<br/>");
$update_str="UPDATE mp_id3_tags SET artist='".mysql_escape_string($new_artist)."', album='".mysql_escape_string($new_album)."',title='".mysql_escape_string($new_title)."',year='".mysql_escape_string($new_year)."',track='".mysql_escape_string($new_track)."',album_art='".mysql_escape_string($new_album_art)."',is_corrected=1 WHERE id=".$id;
$this->safe_mysql_query($update_str);
$this->DebuggingMessage($update_str."<br/>");
$counter++;
if($this->InsertLyricsWicki($id,$new_artist,$new_title))$is_lyrics=1;
else if($this->InsertLyricsFly($id,$new_artist,$new_album,$new_title))$is_lyrics=1;
if(!isset($artist_list[$old_artist]))$artist_list[$old_artist]=$new_artist;
if(!isset($album_list[$old_album]))$album_list[$old_album]=$new_album;
if(!isset($album_art_list[$old_album_art]))$album_art_list[$old_album_art]=$new_album_art;
//if($counter==5)exit;
if($counter%1000==0)
{
$etimer = explode( ' ', microtime() );
$etimer = $etimer[1] + $etimer[0];
$time_taken=($etimer-$stimer);
$tagging_rate=$counter/$time_taken;
$time_remaining=($total_count-$counter)/$tagging_rate;
error_log("Tracks ".$counter." out of ".$total_count." tags have been corrected.
\nTime to completion : ".$time_remaining."sec\nTag Correction rate : ".$tagging_rate." tracks/sec", 1, "hide@address.com");
}
$update_str=$this->UpdateTagDetails($id,$is_artist_details,$is_lyrics,$is_artist_bio);
$this->DebuggingMessage($update_str."<br/><br/><br/>");
}
$this->DebuggingMessage('<br/><br/>Number of tags updated : '.$counter);
}
/******************************************************************************************************************
-Used to indicate if lyrics and artist information have been downloaded for the specifed song.
/******************************************************************************************************************/
function UpdateTagDetails($id,$is_artist_details,$is_lyrics)
{
$update_str="UPDATE mp_id3_tags SET is_lyrics=".$is_lyrics.",is_artist_details=".$is_artist_details.",is_artist_bio=".$artist_biography." WHERE ID=".$id;
safe_mysql_query($update_str);
return $update_str;
}
/******************************************************************************************************************
-Used to save artist information to database.
/******************************************************************************************************************/
function SaveArtistInformation($artist_name,$artist_genre,$artist_top_tracks,$artist_top_albums,$similar_artists,$artist_image)
{
$insert_str="INSERT INTO mp_id3_artists(name,top_tracks,top_albums,artist_genre,similar_artists,artist_image,created_on,artist_biography) VALUES('".mysql_escape_string($artist_name)."','".mysql_escape_string($artist_top_tracks)."','".mysql_escape_string($artist_top_albums)."','".mysql_escape_string($artist_genre)."','".mysql_escape_string($similar_artists)."','".mysql_escape_string($artist_image)."','".date("Y-m-d H:i:s")."','".mysql_escape_string($artist_biography)."')";
safe_mysql_query($insert_str);
return $insert_str;
}
/******************************************************************************************************************
-Used to get artist genre from audioscrobbler.com.
/******************************************************************************************************************/
function GetArtistGenre($new_artist)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/artist/".urlencode(htmlentities($new_artist))."/toptags.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
$artist_genre_list=array();
if(isset($index_array["NAME"]))
{
for($count=0;$count<count($index_array["NAME"]);$count++)
{
$artist_genre_list[]=$value_array[$index_array["NAME"][$count]]["value"];
}
return implode("*",$artist_genre_list);
}
return "";
}
/******************************************************************************************************************
-Used to get the list of top tracks by the specified artist from audioscrobbler.com.
/******************************************************************************************************************/
function GetArtistTopTracks($new_artist)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/artist/".urlencode(htmlentities($new_artist))."/toptracks.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
$top_tracks_list=array();
if(isset($index_array["NAME"]))
{
for($count=0;$count<count($index_array["NAME"]);$count++)
{
$top_tracks_list[]=$value_array[$index_array["NAME"][$count]]["value"];
}
return implode("*",$top_tracks_list);
}
return "";
}
/******************************************************************************************************************
-Used to get the list of top albums by the specified artist from audioscrobbler.com.
/******************************************************************************************************************/
function GetArtistTopAlbums($new_artist)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/artist/".urlencode(htmlentities($new_artist))."/topalbums.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
$top_albums_list=array();
if(isset($index_array["NAME"]))
{
for($count=0;$count<count($index_array["NAME"]);$count++)
{
$top_albums_list[]=$value_array[$index_array["NAME"][$count]]["value"];
}
return implode("*",$top_albums_list);
}
return "";
}
/******************************************************************************************************************
-Used to get the list of similar artists from audioscrobbler.com.
/******************************************************************************************************************/
function GetSimilarArtists($new_artist)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/artist/".urlencode(htmlentities($new_artist))."/similar.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
if(isset($index_array["SIMILARARTISTS"][0])&&isset($index_array["NAME"]))
{
$artist_image_url=$value_array[$index_array["SIMILARARTISTS"][0]]["attributes"]["PICTURE"];
$index=strrpos($artist_image_url,'/');
$image_name=substr($artist_image_url,$index+1);
if($image_name!="")
{
$image_name=mysql_escape_string(urldecode($image_name));
$file_str=@file_get_contents($artist_image_url);
$file_handle = fopen($this->album_art_folder.$this->path_symbol.$image_name, 'w');
fwrite($file_handle, $file_str);
fclose($file_handle);
$similar_artist_list=array();
for($count=0;$count<count($index_array["NAME"]);$count++)
{
$similar_artist_list[]=$value_array[$index_array["NAME"][$count]]["value"];
}
}
return array(implode("*",$similar_artist_list),$image_name);
}
else return array("","");
}
/******************************************************************************************************************
-Used to get the lyrics of all songs from lyricwiki and lyricsfly.com for which the lyrics were previously not found.
/******************************************************************************************************************/
function GetLyrics()
{
$select_str="SELECT * FROM mp_id3_lyrics WHERE lyrics='Not found'";
$result=$this->safe_mysql_query($select_str);
$counter=0;
while ($row=mysql_fetch_assoc($result))
{
$id=$row["ID"];
$temp_select_str="SELECT * FROM mp_id3_tags WHERE ID=".$id;
$temp_result=$this->safe_mysql_query($temp_select_str);
$temp_row=mysql_fetch_assoc($temp_result);
$artist=$temp_row["artist"];
$title=$temp_row["title"];
if($this->InsertLyricsWicki($id,$artist,$title))$counter++;
else if($this->InsertLyricsFly($id,$artist,$album,$title))$counter++;
}
echo '<br/><br/>Number of lyrics added : '.$counter;
}
/******************************************************************************************************************
-Used to get the lyrics of the specified song from lyricwiki.
/******************************************************************************************************************/
function InsertLyricsWicki($id,$artist,$title)
{
$result=$this->MakeSoapCall("getSong",array(urlencode(htmlentities($artist)),urlencode(htmlentities($title))));
if(isset($result['lyrics']))
{
$lyrics=$result['lyrics'];
//echo $lyrics;
$insert_str="INSERT INTO mp_id3_lyrics(track_id,lyrics,created_on) VALUES(".$id.", '".mysql_escape_string($lyrics)."','".date("Y-m-d H:i:s")."')";
$this->safe_mysql_query($insert_str);
$this->DebuggingMessage("Title lyrics : ".$lyrics."<br/>");
return true;
}
return false;
}
/******************************************************************************************************************
-Used to get the lyrics of the specified song from lyricsfly.com.
/******************************************************************************************************************/
function InsertLyricsFLy($id,$artist,$album,$title)
{
$response = @file_get_contents("http://lyricsfly.com/api/api.php?i=5b51b15f0e0831442&a=".urlencode(htmlentities($artist))."&t=".urlencode(htmlentities($title)));
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
$lyrics="";
if(isset($index_array["AL"]))
{
for($count=0;$count<count($index_array["AL"]);$count++)
{
$album_name=$value_array[$index_array["AL"][$count]]["value"];
$temp_likeness=$this->GetLikeness($album,$album_name);
if($temp_likeness>$likeness&&$temp_likeness>0)
{
$lyrics=$value_array[$index_array["TX"][$count]]["value"];
}
}
if($lyrics=="")$lyrics="Not found";
else
{
$insert_str="INSERT INTO mp_id3_lyrics(track_id,lyrics,created_on) VALUES(".$id.", '".mysql_escape_string($lyrics)."','".date("Y-m-d H:i:s")."')";
$this->safe_mysql_query($insert_str);
$this->DebuggingMessage("Title lyrics : ".$lyrics."<br/>");
return true;
}
}
return false;
}
/******************************************************************************************************************
-Used to display a debuggin message.
/******************************************************************************************************************/
function DebuggingMessage($message)
{
if($this->is_debug)echo $message;
flush();
}
/******************************************************************************************************************
-Used to execute the specified sql query.
/******************************************************************************************************************/
function safe_mysql_query($SQLquery)
{
$result = @mysql_query($SQLquery);
if (mysql_error())
{
die('<FONT COLOR="red">'.mysql_error().'</FONT><hr><TT>'.$SQLquery.'</TT>');
}
return $result;
}
/******************************************************************************************************************
-Used to get the correct name of an artist.
/******************************************************************************************************************/
function CorrectArtistTag($artist)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/artist/".urlencode(htmlentities($artist))."/toptracks.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
if(isset($index_array["MOSTKNOWNTRACKS"][0]))
{
$artist_name=$value_array[$index_array["MOSTKNOWNTRACKS"][0]]["attributes"]["ARTIST"];
return $artist_name;
}
else return "";
}
/******************************************************************************************************************
-Used to get the correct name of an album.
/******************************************************************************************************************/
function CorrectAlbumTag($artist,$album)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/artist/".urlencode(htmlentities($artist))."/topalbums.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
$match1="";
$match2="";
$title_url="";
$likeness=-100;
/*print_r($value_array);
echo "<br/><br/>";
print_r($index_array);
exit;*/
if(isset($index_array["NAME"]))
{
for($count=0;$count<count($index_array["NAME"]);$count++)
{
$album_name=$value_array[$index_array["NAME"][$count]]["value"];
$album_art=$value_array[$index_array["LARGE"][$count]]["value"];
$temp_likeness=$this->GetLikeness($album,$album_name);
if($temp_likeness>$likeness&&$temp_likeness>0)
{
$title_url=str_replace("http://www.last.fm/music/","",$value_array[$index_array["URL"][$count]]["value"]);
$title_url=str_replace("_/","",$title_url);
$likeness=$temp_likeness;
$match1=$album_name;
$match2=$album_art;
}
}
$index=strrpos($match2,'/');
$image_name=substr($match2,$index+1);
$image_name=mysql_escape_string(urldecode($image_name));
if($image_name!="")
{
$file_str=@file_get_contents($match2);
$file_handle = fopen($this->album_art_folder.$this->path_symbol.$image_name, 'w');
fwrite($file_handle, $file_str);
fclose($file_handle);
}
$match2=$image_name;
}
return array($match1,$match2,$title_url);
}
/******************************************************************************************************************
-Used to get the correct name of an title.
/******************************************************************************************************************/
function CorrectTitleTag($title_url,$title)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/album/".$title_url."/info.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
$track=0;
$match="";
$likeness=-100;
$release_date="";
$genre_url="";
if(is_array($value_array)&&count($value_array)>0)
{
$release_date=$value_array[$index_array["RELEASEDATE"][0]]["value"];
for($count=0,$counter=0;$count<count($index_array["TRACK"]);$count++)
{
if(isset($value_array[$index_array["TRACK"][$count]]["attributes"]["TITLE"]))
{
$title_name=$value_array[$index_array["TRACK"][$count]]["attributes"]["TITLE"];
$counter++;
}
else continue;
$temp_likeness=$this->GetLikeness($title,$title_name);
if($temp_likeness>$likeness&&$temp_likeness>0)
{
$track=$counter;
$likeness=$temp_likeness;
$match=$title_name;
$genre_url=str_replace("http://www.last.fm/music/","",$value_array[$index_array["URL"][$counter]]["value"]);
$genre_url=str_replace("_/","",$genre_url);
}
}
}
return array($match,$release_date,$track,$genre_url);
}
/******************************************************************************************************************
-Used to get the genre for the specified track and artist.
/******************************************************************************************************************/
function CorrectGenreTag($genre_url)
{
$response = @file_get_contents("http://ws.audioscrobbler.com/1.0/track/".$genre_url."/toptags.xml");
xml_parse_into_struct(xml_parser_create(),$response,$value_array,$index_array);
if(isset($index_array["NAME"][0])===false)return "";
else return $value_array[$index_array["NAME"][0]]["value"];
}
/******************************************************************************************************************
-Used to determine the how close two string are.
/******************************************************************************************************************/
function GetLikeness($original,$match)
{
$matches=0;
$original=strtolower($original);
$match=strtolower($match);
$char_pos=array();
$seq_length=0;
$last_index=0;
$is_seq=false;
for($count=0;$count<strlen($original);$count++)
{
$char=substr($original,$count,1);
$pos=strpos($match,$char,$last_index);
if($char==' '&&count($char_pos)==0)continue;
if($pos!==false)
{
$char_pos[]=$pos;
$matches++;
$last_index=$pos;
$char_pos_length=count($char_pos);
if($char_pos_length>1)
{
if($char_pos[$char_pos_length-1]==$char_pos[$char_pos_length-2]+1)$seq_length++;
else $seq_length=0;
}
$matches+=$seq_length;
if($seq_length>3)$is_seq=true;
}
}
if($is_seq==false)return 0;
else return $matches;
}
/******************************************************************************************************************
-Used to make a call to a remote function using soap.
/******************************************************************************************************************/
function MakeSoapCall($function_name,$parameters)
{
// Pull in the NuSOAP code
require_once('nusoap/lib/nusoap.php');
// Create the client instance
$client = new soapclient('http://lyricwiki.org/server.php?wsdl', true);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call($function_name, $parameters);
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
//echo '<h2>Result</h2><pre>';
//print_r($result);
//echo '</pre>';
}
}
return $result;
}
/******************************************************************************************************************
-Used to get the artist biography.
/******************************************************************************************************************/
function GetArtistBiography($artist)
{
for($count=0;$count<5;$count++)
{
$artist_name=GetArtistName($artist,$count);
$regex=GetRegex($count);
$url=GetUrl($count);
$index_list=GetIndexList($count);
$artist_biography=GetTextFromPage($url,$artist_name,$regex,$index_list);
}
$found=0;
if($artist_biography!="")
{
$found=1;
DebuggingMessage('Artist name : '.$artist."</br>Artist Biography : ".$artist_biography."<br/>");
}
return array($found,$artist_biography);
}
/******************************************************************************************************************
-Used to get the list of indexes of the matches array that contain usefull information.
/******************************************************************************************************************/
function GetIndexList($url_number)
{
$index_list=array();
if($url_number==0)$index_list[]=1;
else if($url_number==1){$index_list[]=3;$index_list[]=3;}
else if($url_number==2)$index_list[]=1;
else if($url_number==3)$index_list[]=2;
else if($url_number==4)$index_list[]=1;
if($url_number==0)$index_list[]=0;
else if($url_number==1)$index_list[]=0;
else if($url_number==2)$index_list[]=5000;
else if($url_number==3)$index_list[]=0;
else if($url_number==4)$index_list[]=0;
return $index_list;
}
/******************************************************************************************************************
-Used to get the of the website that contains the lyrics.
/******************************************************************************************************************/
function GetUrl($url_number)
{
if($url_number==0)$url='http://www.rollingstone.com/artists/artist_name/biography';
else if($url_number==1)$url='http://www.vh1.com/artists/az/artist_name/bio.jhtml';
else if($url_number==2)$url='http://www.mtv.com/music/artist/artist_name/artist.jhtml';
else if($url_number==3)$url='http://en.noomus.com/music/artist_name/';
else if($url_number==4)$url='http://www.xfm.co.uk/artists/artist_name/biography';
return $url;
}
/******************************************************************************************************************
-Used to get the artist biography text from the web page.
/******************************************************************************************************************/
function GetTextFromPage($url,$artist_name,$regex,$index_list)
{
$url=str_replace("artist_name",$artist_name,$url);
$text=file_get_contents($url);
$text=str_replace("\n","",$text);
$text=str_replace("\r","",$text);
preg_match($regex,$text,$matches,null,$index_list[count($index_list)-1]);
$text="";
for($count=0;$count<count($index_list)-1;$count++)$text.=$matches[$index_list[$count]];
return $text;
}
/******************************************************************************************************************
-Used to get the name of the artist for retrieving the web page.
/******************************************************************************************************************/
function GetArtistName($artist_name,$url_number)
{
if($url_number==0)
{
$artist_name=strtolower($artist_name);
$artist_name=str_replace("&","and",$artist_name);
$artist_name=str_replace(" ","",$artist_name);
$artist_name=preg_replace('/^[^a-b0-9]$/i','',$artist_name);
}
else if($url_number==1)
{
$artist_name=strtolower($artist_name);
$artist_name=str_replace("&","and",$artist_name);
$artist_name=str_replace(" ","_",$artist_name);
$artist_name=preg_replace('/^[^a-b0-9]$/i','',$artist_name);
}
else if($url_number==2)
{
$artist_name=strtolower($artist_name);
$artist_name=str_replace("&","and",$artist_name);
$artist_name=str_replace(" ","_",$artist_name);
$artist_name=preg_replace('/^[^a-b0-9]$/i','',$artist_name);
}
else if($url_number==3)
{
$artist_name=urlencode($artist_name);
}
else if($url_number==4)
{
$artist_name=strtolower($artist_name);
$artist_name=str_replace("&","and",$artist_name);
$artist_name=str_replace(" ","-",$artist_name);
$artist_name=preg_replace('/^[^a-b0-9]$/i','',$artist_name);
}
return $artist_name;
}
/******************************************************************************************************************
-Used to get the regular expression that will be used to extract the artist biography from the web page.
/******************************************************************************************************************/
function GetRegex($url_number)
{
if($url_number==0)$regex='/<p class=\"fullbiotext\">(.*).(.*)<\/p>/iU';
else if($url_number==1)$regex='/<span class="bioLong">(.*)<table border="0"(.*)<\/table>(.*).(.*)<\/span>/iU';
else if($url_number==2)$regex='/<div class=\"deck\">(.*).(.*)<\/div>/iU';
else if($url_number==3)$regex='/<img alt=(.*)>(.*)<div/iU';
else if($url_number==4)$regex='/<ul class=\"artist_nav\">.*(<p>.*)<div class=\"bookmark\">/iU';
return $regex;
}
/***************************************************************************************************************************************/
?>