From 94878b4bd238dac69df38ba1fd1a34ebd443d21b Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 31 Jul 2012 17:57:17 +0200 Subject: [PATCH] Slightly hacky support for AAC on Google Drive. --- ext/clementine-tagreader/tagreaderworker.cpp | 14 +++++++++++++- src/internet/googledriveservice.cpp | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ext/clementine-tagreader/tagreaderworker.cpp b/ext/clementine-tagreader/tagreaderworker.cpp index 54fac4af0..ab6b8a614 100644 --- a/ext/clementine-tagreader/tagreaderworker.cpp +++ b/ext/clementine-tagreader/tagreaderworker.cpp @@ -623,11 +623,16 @@ bool TagReaderWorker::ReadGoogleDrive(const QUrl& download_url, download_url, title, size, access_token, network_); stream->Precache(); scoped_ptr tag; - if (mime_type == "audio/mpeg") { + if (mime_type == "audio/mpeg" && title.endsWith(".mp3")) { tag.reset(new TagLib::MPEG::File( stream, // Takes ownership. TagLib::ID3v2::FrameFactory::instance(), TagLib::AudioProperties::Accurate)); + } else if (mime_type == "audio/mpeg" && title.endsWith(".m4a")) { + tag.reset(new TagLib::MP4::File( + stream, + true, + TagLib::AudioProperties::Accurate)); } else if (mime_type == "application/ogg") { tag.reset(new TagLib::Ogg::Vorbis::File( stream, @@ -657,6 +662,13 @@ bool TagReaderWorker::ReadGoogleDrive(const QUrl& download_url, song->set_album(tag->tag()->album().toCString(true)); song->set_filesize(size); + if (tag->tag()->track() != 0) { + song->set_track(tag->tag()->track()); + } + if (tag->tag()->year() != 0) { + song->set_year(tag->tag()->year()); + } + song->set_type(pb::tagreader::SongMetadata_Type_STREAM); if (tag->audioProperties()) { diff --git a/src/internet/googledriveservice.cpp b/src/internet/googledriveservice.cpp index ad6438fbd..1ea995f41 100644 --- a/src/internet/googledriveservice.cpp +++ b/src/internet/googledriveservice.cpp @@ -103,7 +103,7 @@ void GoogleDriveService::ConnectFinished(google_drive::ConnectResponse* response s.setValue("refresh_token", response->refresh_token()); // Find any music files - ListFilesForMimeType("audio/mpeg"); // MP3 + ListFilesForMimeType("audio/mpeg"); // MP3/AAC ListFilesForMimeType("application/ogg"); // OGG ListFilesForMimeType("application/x-flac"); // FLAC }