From 5d9b3f2d5bc8dc031e559f80abb406b8de14dc5c Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Mon, 7 Sep 2015 11:17:35 -0700 Subject: [PATCH] Fixes T224. Also adds the rebuild:tags Artisan command and a missing ffmpeg compilation flag. --- app/commands/RebuildTags.php | 76 +++++++++++++++++++++++++++++++++++ app/models/Entities/Track.php | 10 ++--- app/start/artisan.php | 1 + vagrant/install.sh | 4 +- 4 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 app/commands/RebuildTags.php diff --git a/app/commands/RebuildTags.php b/app/commands/RebuildTags.php new file mode 100644 index 00000000..edf1cc2c --- /dev/null +++ b/app/commands/RebuildTags.php @@ -0,0 +1,76 @@ +argument('trackId')) { + $track = Track::findOrFail($this->argument('trackId')); + $tracks = [$track]; + } else { + $tracks = Track::whereNotNull('published_at')->get(); + } + + foreach($tracks as $track) { + $this->comment('Rewriting tags for track #'.$track->id.'...'); + $track->updateTags(); + } + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('trackId', InputArgument::OPTIONAL, 'ID of the track to rebuild tags for.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array(); + } + +} diff --git a/app/models/Entities/Track.php b/app/models/Entities/Track.php index 8edf51bb..0e3ed7ff 100644 --- a/app/models/Entities/Track.php +++ b/app/models/Entities/Track.php @@ -456,7 +456,7 @@ } if ($this->cover !== NULL) { - $command .= '--artwork ' . $this->getCoverUrl() . ' '; + $command .= '--artwork ' . $this->cover->getFile() . ' '; } $command .= '--overWrite'; @@ -494,9 +494,9 @@ $tagWriter->tag_data['track'] = [$this->track_number]; } - if ($format == 'MP3' && $this->cover_id != NULL && is_file($this->cover->file)) { + if ($format == 'MP3' && $this->cover_id != NULL && is_file($this->cover->getFile())) { $tagWriter->tag_data['attached_picture'][0] = [ - 'data' => file_get_contents($this->cover->file), + 'data' => file_get_contents($this->cover->getFile()), 'picturetypeid' => 2, 'description' => 'cover', 'mime' => 'image/png' @@ -508,10 +508,10 @@ if ($tagWriter->WriteTags()) { if (!empty($tagWriter->warnings)) { - Log::warning('There were some warnings:
' . implode('

', $tagWriter->warnings)); + Log::warning('Track #'.$this->id.': There were some warnings:
' . implode('

', $tagWriter->warnings)); } } else { - Log::error('Failed to write tags!
' . implode('

', $tagWriter->errors)); + Log::error('Track #' . $this->id . ': Failed to write tags!
' . implode('

', $tagWriter->errors)); } } diff --git a/app/start/artisan.php b/app/start/artisan.php index 9a804152..89fb4519 100644 --- a/app/start/artisan.php +++ b/app/start/artisan.php @@ -13,5 +13,6 @@ Artisan::add(new MigrateOldData); Artisan::add(new RefreshCache); + Artisan::add(new RebuildTags); Artisan::add(new ImportMLPMA); Artisan::add(new ClassifyMLPMA); diff --git a/vagrant/install.sh b/vagrant/install.sh index 8832e0b2..d5f8d518 100755 --- a/vagrant/install.sh +++ b/vagrant/install.sh @@ -7,7 +7,7 @@ echo "Installing tagging tools..." sudo apt-get -qq install -y AtomicParsley flac vorbis-tools imagemagick echo "Installing ffmpeg dependencies.." -sudo apt-get -qq install -y pkg-config yasm libfaac-dev libmp3lame-dev libvorbis-dev +sudo apt-get -qq install -y pkg-config yasm libfaac-dev libmp3lame-dev libvorbis-dev libtheora-dev if type ffmpeg &>/dev/null; then @@ -18,7 +18,7 @@ else wget "https://ffmpeg.org/releases/ffmpeg-2.6.3.tar.bz2" tar -xjf "ffmpeg-2.6.3.tar.bz2" cd "ffmpeg-2.6.3" - ./configure --enable-gpl --enable-encoder=flac --enable-encoder=alac --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-nonfree + ./configure --enable-gpl --enable-encoder=flac --enable-encoder=alac --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaac --enable-nonfree make -j4 sudo make install fi