You are here

function pmpapi_get_mp3_from_m3u in Public Media Platform API Integration 7

Attempts to crack an M3U and find first link to an MP3

Parameters

$url: A url pointing to an M3U

Return value

The first MP3 URL to be found in the M3U, FALSE if no MP3 is found, NULL if the file cannot be opened.

1 call to pmpapi_get_mp3_from_m3u()
pmpapi_pull_get_enclosure_url in pmpapi_pull/pmpapi_pull.module
Determines the URL of a given PMP enclosure object.

File

./pmpapi.module, line 686
Creates basic calls to the PMP API.

Code

function pmpapi_get_mp3_from_m3u($url) {
  $lines = file($url);
  if ($lines) {
    foreach ($lines as $line) {
      if (pmpapi_url_is_mp3($line)) {
        return $line;
      }
    }
  }
  else {
    return NULL;
  }
}