Metro Lyrics Parser

Everything PHP-related! Discuss scripts, host challenges, request a script, or just ask for plain old help.

Moderators: IRC Operators, Support Team

User avatar
Preppysob99
User
User
Posts: 50
Joined: Mon Jun 18, 2007 9:40 pm
Location: Inside of your mom ({})
Contact:

Metro Lyrics Parser

Postby Preppysob99 » Tue Dec 02, 2008 4:51 am

I made this parser to find lyrics for songs I like... I haven't completely tested it so I don't know if it will work with all songs... please inform me of any songs it does not work with and I'll fix it as soon as possible :wink:

Demo at http://scolat.com/misc/metro-lyrics-parser.php

Code: Select all

<?php
error_reporting(0);
if ($_GET['a'] && $_GET['t']) {
  $artist = str_replace("'","",strtolower(str_replace(" ","-",$_GET['a'])));
  $title = str_replace("'","",strtolower(str_replace(" ","-",$_GET['t'])));
  $start = '&#'; $end = '</div>';
  if ($file = file_get_contents("http://www.metrolyrics.com/".$title."-lyrics-".$artist.".html")) {
    $startpos = strpos($file, $start)+strlen($start);
    $lyrics = html_entity_decode("&#".substr($file, $startpos, strpos($file, $end, $startpos)-$startpos));
    $lyrics = preg_replace("/^<img (.*)/","",$lyrics);
    die("<h1>".stripslashes(str_replace("'","'",$_GET['t']))."</h1><h3>".stripslashes(str_replace("'","'",$_GET['a']))."</h3>" . str_replace(array("\n","\r"),"",$lyrics));
  }
  else {
    die("<h1 style=\"color: red;\">Error</h1><h2>Lyrics not found for ".$_GET['t']." by ".$_GET['a']."</h2>");
  }
}
else {
  die("<body bgcolor=\"white\"><center><h2>Metro Lyrics Parser</h2><form method=\"get\">Title: <input type=\"text\" name=\"t\" id=\"t\"><br />Artist: <input type=\"text\" name=\"a\" id=\"a\"><br /><input type=\"submit\" value=\"Get Lyrics\"></form></center></body>");
}
?>
Image
Image
Known on IRC as Scott_Dude25
User avatar
Tea
User
User
Posts: 1019
Joined: Fri Jul 25, 2008 3:42 pm
Location: #Coffey522
Contact:

Postby Tea » Tue Dec 02, 2008 10:38 pm

u leech dis i seen it at google b4
Image
^ made by the very lovely xrox <3
User avatar
Preppysob99
User
User
Posts: 50
Joined: Mon Jun 18, 2007 9:40 pm
Location: Inside of your mom ({})
Contact:

Postby Preppysob99 » Wed Dec 03, 2008 10:42 pm

Tea wrote:u leech dis i seen it at google b4

Haha sure, when most of the posts I see by you are leeched from others, I dont think you have any room to call people leechers.
And no, its not leeched I made it myself fool
Image

Image

Known on IRC as Scott_Dude25
LustraTheGoodMan
User
User
Posts: 334
Joined: Mon Nov 24, 2008 1:28 pm
Location: #lustra

Postby LustraTheGoodMan » Wed Dec 03, 2008 11:29 pm

Preppysob99 wrote:
Tea wrote:u leech dis i seen it at google b4

Haha sure, when most of the posts I see by you are leeched from others, I dont think you have any room to call people leechers.
And no, its not leeched I made it myself fool

plz ignore dat ****** ias been suckin his balls so he is happy 2nite. metro station ftw gd job.

only things i dislike:
file_get_contents
regex
Srankie
User
User
Posts: 963
Joined: Thu Mar 01, 2007 7:16 pm
Location: #godscript #msl HOLLAND

Postby Srankie » Thu Dec 04, 2008 3:02 pm

I don't get why everyone dislike regex, nothing wrong with is.

You could use fscokopen to, or curl since that's faster
Image
Image
User avatar
Preppysob99
User
User
Posts: 50
Joined: Mon Jun 18, 2007 9:40 pm
Location: Inside of your mom ({})
Contact:

Postby Preppysob99 » Thu Dec 04, 2008 10:21 pm

file_get_contents is EXACTLY the same as fopen, fread, and fclose successively, the regex is just to fix a bug with some results where an img tag is found inside the results.
From PHP.net itself: file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.
Image

Image

Known on IRC as Scott_Dude25
LustraTheGoodMan
User
User
Posts: 334
Joined: Mon Nov 24, 2008 1:28 pm
Location: #lustra

Postby LustraTheGoodMan » Fri Dec 05, 2008 9:15 am

Preppysob99 wrote:file_get_contents is EXACTLY the same as fopen, fread, and fclose successively, the regex is just to fix a bug with some results where an img tag is found inside the results.
From PHP.net itself: file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

yh i fort dat but den manacit i fink sed its for local files or somit.
Manacit2
User
User
Posts: 442
Joined: Fri Nov 24, 2006 2:39 am

Postby Manacit2 » Fri Dec 05, 2008 11:25 pm

LustraTheGoodMan wrote:
Preppysob99 wrote:file_get_contents is EXACTLY the same as fopen, fread, and fclose successively, the regex is just to fix a bug with some results where an img tag is found inside the results.
From PHP.net itself: file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

yh i fort dat but den manacit i fink sed its for local files or somit.


see file, not web page, thats why it is so un-customizable when it comes to URLs
ImageImage
may not be right, but it is a lot of the time!

Return to “PHP”

Who is online

Users browsing this forum: No registered users and 1 guest