From 50bba983e3d267ac04255e8f32f19fe0ffd467dd Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Wed, 9 Sep 2015 19:08:46 -0700 Subject: [PATCH] T357: Support OGG Vorbis master files in the MLPMA importer. --- app/commands/ImportMLPMA.php | 35 ++++++++++++++++++++++ app/models/Commands/UploadTrackCommand.php | 3 ++ 2 files changed, 38 insertions(+) diff --git a/app/commands/ImportMLPMA.php b/app/commands/ImportMLPMA.php index 79f8571e..1bda93b1 100644 --- a/app/commands/ImportMLPMA.php +++ b/app/commands/ImportMLPMA.php @@ -154,6 +154,10 @@ class ImportMLPMA extends Command { } else if (Str::lower($file->getExtension()) === 'm4a') { 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]; } + /** + * @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]; + } + } diff --git a/app/models/Commands/UploadTrackCommand.php b/app/models/Commands/UploadTrackCommand.php index 69b05791..bc5f2cc0 100644 --- a/app/models/Commands/UploadTrackCommand.php +++ b/app/models/Commands/UploadTrackCommand.php @@ -86,6 +86,9 @@ } else if (Str::startsWith($audioObject->getAudioCodec(), 'aac')) { $masterFormat = 'AAC'; + } else if ($audioObject->getAudioCodec() === 'vorbis') { + $masterFormat = 'OGG Vorbis'; + } else { $validator->messages()->add('track', 'The track does not contain audio in a known lossy format.'); return CommandResponse::fail($validator);