How make when upload check mp3 file cover. Windows Media Player has modification that it find MP3 Music Cover. I want like to make it. When Mp3 Music upload check uploaded music cover in internet. How make it?
Printable View
How make when upload check mp3 file cover. Windows Media Player has modification that it find MP3 Music Cover. I want like to make it. When Mp3 Music upload check uploaded music cover in internet. How make it?
I think I understand what you're asking, but I don't know if it's possible with PHP unless you find a database, which you have access to, containing the same amount of album covers that Windows Media Player recognizes...
I would use this ID3 Tag Reader class to extract the information of the file. Then I'd use that information and regular expressions and CURL to search Amazon.com and use those images. I'd only do that if it was a personal project for your use only, because I'm sure Amazon would frown upon you web scraping it's covers. In any case, I'd only attempt this if you're familiar with regular expressions.
I made with ID3 Tag but how make cover checker. Please help me
The only way to do that would be to have access to all of the cd covers needed, which I don't think many websites actually have, and the ones that do probably did it by hand. The reason WMP works is because it's connected to a database that has a lot of covers already stored on it. I don't know of any open databases that supply album art, so:
The easiest way to go would be to have the user upload the cover with the MP3 file, and then display the two files together.
(And be careful to not let users break copyright laws. If you use your site to share non-copyrighted music, then great! That could be an awesome site. If you have users submitting copyrighted music, you could wind up with a lawsuit. *shiver*)
Edit: Although, there is a chance that, if the music is streamed through WMP, you might be able to get it from WMP. I have never seen that done, though, and I am not sure if the pugin even has that capability. That's more of a question for microsoft.
The only way you can do this without access to a database of covers is to use web scraping to get them through retail sites. This is most likely violating their terms of service if you do so without asking them first.
For example, say you decided to get them off of Amazon.com. Amazon has an advanced music search page. By submitting the form with some content to see where it redirects you, you can get a url like this:
By removing some of the junk, you can get the url down to this:Code:http://www.amazon.com/gp/search/ref=sr_adv_m_pop/?search-alias=popular&unfiltered=1&field-keywords=&field-artist=Kanye+West&field-title=Graduation&field-label=&field-binding=&sort=relevancerank&Adv-Srch-Music-Album-Submit.x=20&Adv-Srch-Music-Album-Submit.y=8
It's easy to see how you could manipulate this url to search for any artist you want. To make a request to the page, you can use the CURL library. If you don't have the CURL library you can use the traditional fopen() and file_get_contents() functions. Here's an example of how you could get the contents of the search page using CURL:Code:http://www.amazon.com/gp/search/ref=sr_adv_m_pop/?search-alias=popular&field-artist=Kanye+West&field-title=Graduation&sort=relevancerank
Once you have the html, you can use preg_match() and regular expressions to find the link to the official product page. Then you'd do the same thing using CURL or fopen to get the contents of that page, and then find the album image's url. Regular expressions are a difficult concept to grasp if you've never worked with them before. It usually takes me a while to create the correct patterns to web scrape. I'd read up on them and then you should have an idea of how to do it.Code:<?php
$artist = "Kanye West";
$album = "Graduation";
$artist = str_replace(' ','+',$artist);
$album = str_replace(' ', '+', $album);
$url = "http://www.amazon.com/gp/search/ref=sr_adv_m_pop/?search-alias=popular";
// add artist
$url .= "&field-artist=" . $artist;
// add title
$url .= "&field-title=" . $album;
// add the rest
$url .= "&sort=relevancerank";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_URL, $url);
$html = curl_exec($ch);
// the html of the search result page is now contained within the variable $html
I never would have thought of that. Do a search, read the page resulting page, get the URL of the picture from the img tag, and display it. That's not a bad idea, but again, the other site won't like it. At best, they'll be mad because it steals their bandwidth. At worst, they'll be mad because your stealing their information.
But if you do use amazon, maybe you can make a deal with them and use the image as a link to their site so the user can buy the CD. (I think you would have better luck with another website, though. Big companies may not be interested unless your site hits it bit.)
Edit: Searching Google might be more legal (I don't know), but the resulting image may or may not be correct. Plus, the size would always vary.