T357: Support OGG Vorbis master files in the MLPMA importer.

This commit is contained in:
Peter Deltchev 2015-09-09 19:08:46 -07:00
parent f656c3aadf
commit 50bba983e3
2 changed files with 38 additions and 0 deletions

View file

@ -154,6 +154,10 @@ class ImportMLPMA extends Command {
} else if (Str::lower($file->getExtension()) === 'm4a') { } else if (Str::lower($file->getExtension()) === 'm4a') {
list($parsedTags, $rawTags) = $this->getAtomTags($allTags); list($parsedTags, $rawTags) = $this->getAtomTags($allTags);
} else if (Str::lower($file->getExtension()) === 'ogg') {
list($parsedTags, $rawTags) = $this->getVorbisTags($allTags);
} }
@ -464,4 +468,35 @@ class ImportMLPMA extends Command {
$tags]; $tags];
} }
/**
* @param array $rawTags
* @return array
*/
protected function getVorbisTags($rawTags) {
$tags = $rawTags['tags']['vorbiscomment'];
$trackNumber = null;
if (isset($tags['track_number'])) {
$trackNumberComponents = explode('/', $tags['track_number'][0]);
$trackNumber = $trackNumberComponents[0];
}
var_dump($tags);
return [
[
'title' => isset($tags['title']) ? $tags['title'][0] : null,
'artist' => isset($tags['artist']) ? $tags['artist'][0] : null,
'band' => isset($tags['band']) ? $tags['band'][0] : null,
'album_artist' => isset($tags['album_artist']) ? $tags['album_artist'][0] : null,
'genre' => isset($tags['genre']) ? $tags['genre'][0] : null,
'track_number' => $trackNumber,
'album' => isset($tags['album']) ? $tags['album'][0] : null,
'year' => isset($tags['year']) ? (int) $tags['year'][0] : null,
'comments' => isset($tags['comments']) ? $tags['comments'][0] : null,
'lyrics' => isset($tags['lyrics']) ? $tags['lyrics'][0] : null,
],
$tags];
}
} }

View file

@ -86,6 +86,9 @@
} else if (Str::startsWith($audioObject->getAudioCodec(), 'aac')) { } else if (Str::startsWith($audioObject->getAudioCodec(), 'aac')) {
$masterFormat = 'AAC'; $masterFormat = 'AAC';
} else if ($audioObject->getAudioCodec() === 'vorbis') {
$masterFormat = 'OGG Vorbis';
} else { } else {
$validator->messages()->add('track', 'The track does not contain audio in a known lossy format.'); $validator->messages()->add('track', 'The track does not contain audio in a known lossy format.');
return CommandResponse::fail($validator); return CommandResponse::fail($validator);