Merge branch 'feature/laravel_5.1' of ssh://phabricator.poniverse.net/diffusion/PF/pony-fm into feature/laravel_5.1

This commit is contained in:
Peter Deltchev 2015-09-12 14:58:30 -07:00
commit d3a79b2a74
3 changed files with 42 additions and 44 deletions

View file

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Album;
use App\Commands\UploadTrackCommand; use App\Commands\UploadTrackCommand;
use App\Genre; use App\Genre;
use App\Image; use App\Image;
@ -41,7 +42,7 @@ class ImportMLPMA extends Command
* *
* @var array * @var array
*/ */
protected $ignoredExtensions = ['db', 'jpg', 'png', 'txt']; protected $ignoredExtensions = ['db', 'jpg', 'png', 'txt', 'rtf', 'wma'];
/** /**
* Used to stop the import process when a SIGINT is received. * Used to stop the import process when a SIGINT is received.
@ -159,12 +160,13 @@ class ImportMLPMA extends Command
} elseif (Str::lower($file->getExtension()) === 'm4a') { } elseif (Str::lower($file->getExtension()) === 'm4a') {
list($parsedTags, $rawTags) = $this->getAtomTags($allTags); list($parsedTags, $rawTags) = $this->getAtomTags($allTags);
} else { } elseif (Str::lower($file->getExtension()) === 'ogg') {
if (Str::lower($file->getExtension()) === 'ogg') { list($parsedTags, $rawTags) = $this->getVorbisTags($allTags);
list($parsedTags, $rawTags) = $this->getVorbisTags($allTags);
}
}
} elseif (Str::lower($file->getExtension()) === 'flac') {
list($parsedTags, $rawTags) = $this->getVorbisTags($allTags);
}
//========================================================================================================== //==========================================================================================================
// Determine the release date. // Determine the release date.
@ -177,17 +179,17 @@ class ImportMLPMA extends Command
if ($taggedYear !== null && $modifiedDate->year === $taggedYear) { if ($taggedYear !== null && $modifiedDate->year === $taggedYear) {
$releasedAt = $modifiedDate; $releasedAt = $modifiedDate;
} elseif ($taggedYear !== null && Str::length((string)$taggedYear) !== 4) {
$this->error('This track\'s tagged year makes no sense! Using the track\'s last modified date...');
$releasedAt = $modifiedDate;
} elseif ($taggedYear !== null && $modifiedDate->year !== $taggedYear) {
$this->error('Release years don\'t match! Using the tagged year...');
$releasedAt = Carbon::create($taggedYear);
} else { } else {
if ($taggedYear !== null && $modifiedDate->year !== $taggedYear) { // $taggedYear is null
$this->error('Release years don\'t match! Using the tagged year...'); $this->error('This track isn\'t tagged with its release year! Using the track\'s last modified date...');
$releasedAt = Carbon::create($taggedYear); $releasedAt = $modifiedDate;
} else {
// $taggedYear is null
$this->error('This track isn\'t tagged with its release year! Using the track\'s last modified date...');
$releasedAt = $modifiedDate;
}
} }
// This is later used by the classification/publishing script to determine the publication date. // This is later used by the classification/publishing script to determine the publication date.
@ -275,18 +277,14 @@ class ImportMLPMA extends Command
if ($image['image_mime'] === 'image/png') { if ($image['image_mime'] === 'image/png') {
$extension = 'png'; $extension = 'png';
} elseif ($image['image_mime'] === 'image/jpeg') {
$extension = 'jpg';
} elseif ($image['image_mime'] === 'image/gif') {
$extension = 'gif';
} else { } else {
if ($image['image_mime'] === 'image/jpeg') { $this->error('Unknown cover art format!');
$extension = 'jpg';
} else {
if ($image['image_mime'] === 'image/gif') {
$extension = 'gif';
} else {
$this->error('Unknown cover art format!');
}
}
} }
// write temporary image file // write temporary image file
@ -387,23 +385,15 @@ class ImportMLPMA extends Command
*/ */
protected function getId3Tags($rawTags) protected function getId3Tags($rawTags)
{ {
if (array_key_exists('tags', $rawTags) && if (array_key_exists('tags', $rawTags) && array_key_exists('id3v2', $rawTags['tags'])) {
array_key_exists('id3v2', $rawTags['tags'])
) {
$tags = $rawTags['tags']['id3v2']; $tags = $rawTags['tags']['id3v2'];
} elseif (array_key_exists('tags', $rawTags) && array_key_exists('id3v1', $rawTags['tags'])) {
$tags = $rawTags['tags']['id3v1'];
} else { } else {
if ( $tags = [];
array_key_exists('tags', $rawTags) &&
array_key_exists('id3v1', $rawTags['tags'])
) {
$tags = $rawTags['tags']['id3v1'];
} else {
$tags = [];
}
} }
$comment = null; $comment = null;
if (isset($tags['comment'])) { if (isset($tags['comment'])) {
@ -441,7 +431,11 @@ class ImportMLPMA extends Command
*/ */
protected function getAtomTags($rawTags) protected function getAtomTags($rawTags)
{ {
$tags = $rawTags['tags']['quicktime']; if (array_key_exists('tags', $rawTags) && array_key_exists('quicktime', $rawTags['tags'])) {
$tags = $rawTags['tags']['quicktime'];
} else {
$tags = [];
}
$trackNumber = null; $trackNumber = null;
if (isset($tags['track_number'])) { if (isset($tags['track_number'])) {
@ -472,7 +466,11 @@ class ImportMLPMA extends Command
*/ */
protected function getVorbisTags($rawTags) protected function getVorbisTags($rawTags)
{ {
$tags = $rawTags['tags']['vorbiscomment']; if (array_key_exists('tags', $rawTags) && array_key_exists('vorbiscomment', $rawTags['tags'])) {
$tags = $rawTags['tags']['vorbiscomment'];
} else {
$tags = [];
}
$trackNumber = null; $trackNumber = null;
if (isset($tags['track_number'])) { if (isset($tags['track_number'])) {

View file

@ -59,8 +59,8 @@ return [
*/ */
'password' => [ 'password' => [
'email' => 'emails.password', 'email' => 'emails.auth.reminder',
'table' => 'password_resets', 'table' => 'password_reminders',
'expire' => 60, 'expire' => 60,
], ],

View file

@ -226,4 +226,4 @@ angular.module('ponyfm').factory('tracks', [
filterDef.promise() filterDef.promise()
self self
]) ])