Merge rPFf4f97acd9fc0: T357: Validate the length of a year correctly.

This commit is contained in:
Kelvin Zhang 2015-09-12 15:59:19 +01:00
parent 9468ced8c4
commit 616b6e9ccf

View file

@ -179,12 +179,10 @@ class ImportMLPMA extends Command
if ($taggedYear !== null && $modifiedDate->year === $taggedYear) {
$releasedAt = $modifiedDate;
} else {
if ($taggedYear !== null && (string)$taggedYear !== 4) {
} elseif ($taggedYear !== null && (string)Str::length($taggedYear) !== 4) {
$this->error('This track\'s tagged year makes no sense! Using the track\'s last modified date...');
$releasedAt = $modifiedDate;
} else {
if ($taggedYear !== null && $modifiedDate->year !== $taggedYear) {
} elseif ($taggedYear !== null && $modifiedDate->year !== $taggedYear) {
$this->error('Release years don\'t match! Using the tagged year...');
$releasedAt = Carbon::create($taggedYear);
@ -193,8 +191,6 @@ class ImportMLPMA extends Command
$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.
$parsedTags['released_at'] = $releasedAt->toDateTimeString();
@ -281,19 +277,15 @@ class ImportMLPMA extends Command
if ($image['image_mime'] === 'image/png') {
$extension = 'png';
} else {
if ($image['image_mime'] === 'image/jpeg') {
} elseif ($image['image_mime'] === 'image/jpeg') {
$extension = 'jpg';
} else {
if ($image['image_mime'] === 'image/gif') {
} elseif ($image['image_mime'] === 'image/gif') {
$extension = 'gif';
} else {
$this->error('Unknown cover art format!');
}
}
}
// write temporary image file
$imageFilename = $file->getFilename() . ".cover.$extension";
@ -393,22 +385,14 @@ class ImportMLPMA extends Command
*/
protected function getId3Tags($rawTags)
{
if (array_key_exists('tags', $rawTags) &&
array_key_exists('id3v2', $rawTags['tags'])
) {
if (array_key_exists('tags', $rawTags) && array_key_exists('id3v2', $rawTags['tags'])) {
$tags = $rawTags['tags']['id3v2'];
} else {
if (
array_key_exists('tags', $rawTags) &&
array_key_exists('id3v1', $rawTags['tags'])
) {
} elseif (array_key_exists('tags', $rawTags) && array_key_exists('id3v1', $rawTags['tags'])) {
$tags = $rawTags['tags']['id3v1'];
} else {
$tags = [];
}
}
$comment = null;